Security in serverless world

Yan Cui
Yan CuiSpeaker at Self
LONDON 18-19 OCT
2018
Security in the Serverless World
YAN CUI
Yan Cui
http://theburningmonk.com
@theburningmonk
Principal Engineer @
Security in serverless world
We’re hiring! Visit
engineering.dazn.com
to learn more.
follow @dazneng for
updates about the
engineering team
follow @dazneng for
updates about the
engineering team
We’re hiring! Visit
engineering.dazn.com
to learn more.
WE’RE HIRING!
AWS user since 2009
http://bit.ly/yubl-serverless
Shared Responsibility Model
Shared Responsibility Model
protection from OS attacks
Amazon automatically apply latest patches to host VMs
Security in serverless world
Security in serverless world
still have to patch your code
vulnerable code, 3rd party dependencies, etc.
Security in serverless world
https://snyk.io/blog/owasp-top-10-breaches
https://snyk.io/blog/owasp-top-10-breaches
Known Vulnerable Components cause 24% of the top 50 data breaches
https://snyk.io/blog/77-percent-of-sites-use-vulnerable-js-libraries
Security in serverless world
Security in serverless world
Security in serverless world
Security in serverless world
http://bit.ly/2topw5I
sanitise inputs & outputs
(standardise and encapsulate into shared lib)
Security in serverless world
http://bit.ly/2gSHtay
Broken Access Control
Insecure Direct Object Reference
Information Leakage
GraphQL Injection
http://bit.ly/2uKhGXF
http://bit.ly/2uKhGXF
Security in serverless world
app dependencies
is a
attack surface
BIGGER
than you think
your dependencies
your dependencies
transient dependencies
https://david-dm.org/request/request?view=tree
Security in serverless world
https://snyk.io
security updates are often
bundled with unrelated
feature and API changes
your security is as strong
as its weakest link
OS
Application
Dependencies
physical
infrastructure
NPM Authors
Container
runs in
runs in
runs in
has
hosted by published by
pushes to
Developers
develops uses
Users
guardsprotects
Networking
runs on
needs
Source Code
has
maintains
OS
Application
Dependencies
physical
infrastructure
NPM Authors
Container
runs in
runs in
runs in
has
hosted by published by
pushes to
Developers
develops uses
Users
guardsprotects
Networking
needs
runs on this is where an attacker will
target in a movie
Source Code
has
maintains
Security in serverless world
Security in serverless world
OS
Dependencies
physical
infrastructure
NPM Authors
Container
runs in
runs in
runs in
has
hosted by published by
pushes to
Developers
develops uses
Users
guardsprotects
Application
A9
Networking
runs on
needs
Source Code
has
maintains
A1, A3, …
people are often the WEAKEST link
in the security chain
Security in serverless world
OS
Dependencies
physical
infrastructure
NPM Authors
Container
runs in
runs in
runs in
has
hosted by published by
pushes to
Developers
develops uses
Users
guardsprotects
Application
phishing…
Networking
runs on
needs
Source Code
has
maintains
OS
Dependencies
physical
infrastructure
NPM Authors
Container
runs in
runs in
runs in
has
hosted by published by
pushes to
Developers
develops uses
Users
guardsprotects
Application
brute force, known
account leaks, …
Networking
runs on
needs
Source Code
has
maintains
OS
Dependencies
physical
infrastructure
NPM Authors
Container
runs in
runs in
runs in
has
hosted by published by
pushes to
Developers
develops uses
Users
guardsprotects
Application
brute force, known
account leaks, …
Networking
runs on
needs
Source Code
has
maintains
http://bit.ly/2sFDwYX
…obtained publish access to 14% of npm packages…
http://bit.ly/2sFDwYX
debug, request, react, co, express, moment, gulp, mongoose, mysql, bower,
browserify, electron, jasmine, cheerio, modernizr, redux, …
http://bit.ly/2sFDwYX
total downloads/month of the unique packages which I got
myself publish access to was 1 972 421 945, that’s
20% of the total number of d/m directly.
20% of all monthly NPM downloads…
brute force
known account leaks from other sources
leaked NPM credentials (github, etc.)
http://bit.ly/2sFDwYX
http://bit.ly/2sFDwYX
662 users had password “123456”
172 — “123”
124 — “password”
Security in serverless world
Security in serverless world
WTF!?!?
Security in serverless world
Security in serverless world
Security in serverless world
Security in serverless world
oh god, that was too easy…
Security in serverless world
Security in serverless world
compromised package is a
transient dependency
sigh…
still “works”…
Security in serverless world
Security in serverless world
npmjs.com/~hacktask
Security in serverless world
rm -rf /!!!
NPM default - get latest
“compatible” version, ie. 1.X.X
clean install (eg. on CI server) will
download the latest, compromised
package without any code change…
NPM default - get latest
“compatible” version, ie. 1.X.X
Security in serverless world
use npm shrinkwrap
or upgrade to NPM 5 or above
not specific to Node.js or NPM
the attackers are in…
the attackers are in…
what now?
Shared Responsibility Model
who can invoke the function?
what can the function access?
Least Privilege Principle
Security in serverless world
everything here
is trusted
Security in serverless world
sensitive data
http://bit.ly/2zHvbcB
always public
access is controlled via IAM
Security in serverless world
Security in serverless world
Security in serverless world
Security in serverless world
http://bit.ly/2lNInES
adds up to 10s to cold start!!
http://bit.ly/2lNInES
compromised servers allow
attacker to access all of
your sensitive data!
implement authentication
for internal APIs
Security in serverless world
always public
implement authentication with
API keys, Cognito, or custom
authorizer functions
use AWS_IAM
authentication for
internal APIs
Security in serverless world
minimise function’s access
Security in serverless world
Security in serverless world
Security in serverless world
requires developer discipline
Security in serverless world
Security in serverless world
Security in serverless world
AWS Lambda
docs
Write your Lambda function
code in a stateless style, and
ensure there is no affinity
between your code and the
underlying compute
infrastructure.
http://amzn.to/2jzLmkb
S3
AWS IoT
DynamoDB
RDS
EventStore
Elasticsearch Couchbase
Redshift
Neo4j
Google BigQuery
secure sensitive data both
at rest and in-transit
leverage server-side encryption
http://amzn.to/1N3Twb8
http://amzn.to/1xF41eX
http://amzn.to/2tgvFR2
Least Privilege Principle
Disposability is a virtue
AWS Lambda
docs
Delete old Lambda functions that
you are no longer using.
http://amzn.to/2jzLmkb
easier said than done…
identifying component
ownership in a big IT
organization is challenging
identifying ownership of
individual functions is
much harder
source: http://www.digitalattackmap.com
more likely to scale through
DoS attacks
DoS + per exec billing =
Denial of Wallet problem
have to choose between a
DoS and a DoW problem…
Security in serverless world
AWS Shield Advanced also gives you access to the AWS DDoS
Response Team (DRT) and protection against DDoS related
spikes in your ELB, CloudFront or Route 53 charges.
async sync
S3
SNS
SES
CloudFormation
CloudWatch Logs
CloudWatch Events
Scheduled Events
CodeCommit
AWS Config
http://amzn.to/2vs2lIg
Cognito
Alexa
Lex
API Gateway
streams
DynamoDB Stream
Kinesis Stream
Lambda handles retries
(twice, then DLQ)
http://bit.ly/2v7F2E4
DoS attack
2+ Retries+
?
DoS attack
Regex DoS attack
long Lambda timeout
2+ Retries+
?
Security in serverless world
Day 1
Day 2
Security in serverless world
no long-lived compromised servers
containers are reused, avoid
sensitive data in /tmp
https://www.puresec.io/function-shield
Security in serverless world
Security in serverless world
Security in serverless world
no accidentally exposed directories
Security in serverless world
Security in serverless world
Security in serverless world
http://bit.ly/2tlGTbc
monitor activities in
unused regions using
CloudWatch Events
Security in serverless world
set up billing alarms in unused regions
watertight compartments that can contain water in
the case of hull breach or other leaks
Michael Nygard
least privilege principle
per function policies
account level isolation
Recap
app dependencies
is a
attack surface
BIGGER
than you think
Security in serverless world
sanitise inputs and outputs
Least Privilege Principle
here’s your per function policy
NEXT!
S3
AWS IoT
DynamoDB
RDS
EventStore
Elasticsearch Couchbase
Redshift
Neo4j
Google BigQuery
encrypt data at rest
S3
AWS IoT
DynamoDB
RDS
EventStore
Elasticsearch Couchbase
Redshift
Neo4j
Google BigQuery
and in-transit
delete unused functions.
DoS DoW*
* Denial of Wallet
Security in serverless world
Security in serverless world
Security in serverless world
no server*
no OS attacks
no long lived compromised servers
* I know I know, there’s still a server somewhere, but it’s managed and secured by AWS engineers who can do a much better job of it
than most of us can; and the servers are ephemeral and short-lived
don’t be an unwilling bit miner
don’t be an unwilling bit miner
safeguard your credentials…
prod dev
compartmentalise breaches
people are often the WEAKEST link
in the security chain
LONDON 18-19 OCT
2018
[ Thank You!
@theburningmonk
theburningmonk.com ]
1 of 172

More Related Content

Similar to Security in serverless world(20)

Security in Serverless worldSecurity in Serverless world
Security in Serverless world
Yan Cui784 views
Security in serverless worldSecurity in serverless world
Security in serverless world
Yan Cui3.5K views
Container securityContainer security
Container security
Anthony Chow224 views
Google chrome sandboxGoogle chrome sandbox
Google chrome sandbox
Nephi Johnson2.4K views
Security Tips to run Docker in ProductionSecurity Tips to run Docker in Production
Security Tips to run Docker in Production
Gianluca Arbezzano2.9K views

Recently uploaded(20)

Liqid: Composable CXL PreviewLiqid: Composable CXL Preview
Liqid: Composable CXL Preview
CXL Forum120 views
ThroughputThroughput
Throughput
Moisés Armani Ramírez31 views
[2023] Putting the R! in R&D.pdf[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdf
Eleanor McHugh36 views
Tunable Laser (1).pptxTunable Laser (1).pptx
Tunable Laser (1).pptx
Hajira Mahmood21 views

Security in serverless world