www.securing.pl
Pawel Rzepa
Serverless security: attack & defense www.securing.pl #whoami - - PowerPoint PPT Presentation
www.securing.pl Pawel Rzepa Serverless security: attack & defense www.securing.pl #whoami Senior Security Consultant in - Pentesting - Cloud security assessment Blog: https://medium.com/@rzepsky @Rzepsky
www.securing.pl
Pawel Rzepa
www.securing.pl
#whoami Senior Security Consultant in
Blog: https://medium.com/@rzepsky @Rzepsky www.linkedin.com/in/pawel-rzepa
www.securing.pl
www.securing.pl
ht https:// //myblog. g.com
WELC ELCOME ME TO TO MY MY BLO LOG
HT HTML, CSS, CSS, JS JS
www.securing.pl
www.securing.pl
ht https:// //myblog. g.com
[C [Course] ] How to ma make yo your do dog love yo you?
PAYMEN ENT PROVIDER ER
Ne New pu purch chase we web-ho hook Se Send e-ma mail to to cu customer Gen Gener erate da daily re report rt HT HTML, CSS, CSS, JS JS
www.securing.pl
Ge Get con
pa payment Se Send e-m
Ge Generate da dail ily repor
WordPress + PHP?)
you’ll have
(based on your assumptions of the traffic)
(patch management, latency etc.)
www.securing.pl
FaaS on the example of Lambda
P O S T / c
f i r m a t i
H T T P / 1 . 1 event event
PAY AYMEN ENT PROVI VIDER ER
www.securing.pl
www.securing.pl
www.securing.pl
ht http: p://w //www.lamb ambdas ashe hell.com/ m/
www.securing.pl
www.securing.pl
Meet Bob
My apps aren’t public, so there is no need to put them in security review process
www.securing.pl
Bob uses Serverless Framework
www.securing.pl
Create the PoC app where internal candidates can submit their CVs
www.securing.pl
www.securing.pl
https://github.com/OWASP/Serverless-Goat
www.securing.pl
www.securing.pl
Don’t use shared function IAM role
www.securing.pl
Use per-function IAM role
www.securing.pl
Azure Functions are deployed as App Service
www.securing.pl
All functions share the same environment
www.securing.pl
www.securing.pl
www.securing.pl
www.securing.pl
www.securing.pl
www.securing.pl
Defense
serverless ss-i
am-ro roles-pe per-fu function (ht https:/ ://bit. bit.ly/2 /2MzjdYh)
serverless ss-re reqval alidat ator-pl plugin (ht https: s://b //bit.ly/2 /2Xq Xqay0k)
www.securing.pl
In GCP by default all Cloud Functions in a Google Cloud project share the same runtime service account (with Editor role :0 ) – create unique service account to each function In Azure apply RBAC to assign limited permissions to resource
access to other resources.
www.securing.pl
www.securing.pl
Files uploaded to the particular S3 bucket should be automatically renamed with some prefix
test-new.png event
s3: { s3SchemaVersion: '1.0', configurationId: 'f67747b9-c02c-4e54-8e49-2dba5060d555', bucket: { name: 'serverless-security-demo',
arn: 'arn:aws:s3:::serverless-security-demo' },
key: 'test-new.png', size: 20, eTag: '3de8f8b0dc94b8c2230fab9ec0ba0506', sequencer: '005E88ACC4D5810265' }
www.securing.pl
www.securing.pl
tu
www.securing.pl
Bob writes a proof-of-concept
www.securing.pl
tu
www.securing.pl
www.securing.pl
How to defend?
Private Subnet
allow all outbound traffic)
resources, then use VPC endpoint policies to control the access Private subnet
www.securing.pl
tu
www.securing.pl
In 2018 NPM EventStream package was found malicious…
www.securing.pl
www.securing.pl
www.securing.pl
dependency
became deprecated…. F u l l s t
y : h t t p s : / / b i t . l y / 2 U l m v m q
Ad Added the mali alicious us pac ackag kage: flatmap-stream@0.1.1
www.securing.pl
www.securing.pl
Defense
Dependency-Track)
www.securing.pl
Only some extensions should be scanned
www.securing.pl
www.securing.pl
Regular expression Denial of Service (ReDoS)
www.securing.pl
www.securing.pl
Denial of Wallet
timeout in AWS Lambda is 15 minutes
No big differences between
www.securing.pl
ht http: p:// //re redos-ch check cker.su surge.sh sh
www.securing.pl
Defense
www.securing.pl
The Lambda function should create a new entry in DynamoDB
www.securing.pl
Why you shouldn’t store secrets in environment variables
www.securing.pl
www.securing.pl
Example of default bucket policy created by Serverless Framework
www.securing.pl
$ cat compiled-cloudformation-template.json (...) "Environment": { "Variables": { "HOST_DB": "1.2.3.4", ”DB_PORT": "3306", "USER": "db_user", "PASS": ” \(8cW:$W ", "DB": "test_db" } (...)
www.securing.pl
Defense
reference them:
db_pass: ${ssm:/path/to/db_pass~true}
www.securing.pl www.securing.pl
www.securing.pl
www.securing.pl
https://[region]-[App Engine name].cloudfunctions.net/[function name] https://[random].execute-api.[region].amazonaws.com/[API endpoint name] http(s)://[App Service name].azurewebsites.net/api/[function name]
www.securing.pl
www.securing.pl
www.securing.pl
Let’s stay in touch!!!
pawel.rz .rzepa@ pa@securi ring.pl .pl
Rzepsk sky
https:/ ://www.l www.lin inkedin in.c .com/i /in/p n/pawel-rz rzepa pa-5326965b 5326965b/
pawel.rzepa@securing.pl