154
the Many-Faced Threats to the serverless world

Security in serverless world

  • Upload
    yan-cui

  • View
    2.353

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Security in serverless world

the Many-Faced Threatsto the serverless world

Page 2: Security in serverless world

hi, I’m Yan Cui

Page 3: Security in serverless world
Page 4: Security in serverless world
Page 5: Security in serverless world
Page 6: Security in serverless world
Page 7: Security in serverless world

AWS user since 2009

Page 8: Security in serverless world
Page 9: Security in serverless world
Page 10: Security in serverless world

apr, 2016

Page 11: Security in serverless world

nov, 2016

Page 12: Security in serverless world

recording: https://www.youtube.com/watch?v=s4L5wjFlFzA

slides: http://bit.ly/2tHYFAM

blog posts: http://theburningmonk.com/yubls-road-to-serverless-architecture

Page 13: Security in serverless world

Lambda is PCI DSS compliant!

https://aws.amazon.com/compliance/services-in-scope

Page 14: Security in serverless world

Shared Responsibility Model

Page 15: Security in serverless world

Shared Responsibility Model

Page 16: Security in serverless world

protection from OS attacksAmazon automatically apply latest patches to host VMs

Page 17: Security in serverless world
Page 18: Security in serverless world

still have to patch your codevulnerable code, 3rd party dependencies, etc.

Page 19: Security in serverless world
Page 20: Security in serverless world
Page 21: Security in serverless world

https://snyk.io/blog/owasp-top-10-breaches

Page 22: Security in serverless world

https://snyk.io/blog/owasp-top-10-breaches

Known Vulnerable Components cause 24% of the top 50 data breaches in 2016

Page 23: Security in serverless world

https://snyk.io/blog/77-percent-of-sites-use-vulnerable-js-libraries

Page 24: Security in serverless world
Page 25: Security in serverless world
Page 26: Security in serverless world
Page 27: Security in serverless world
Page 28: Security in serverless world

http://bit.ly/2topw5I

Page 29: Security in serverless world

sanitise inputs & outputs(standardise and encapsulate into shared lib)

Page 30: Security in serverless world
Page 31: Security in serverless world

http://bit.ly/2gSHtay

Broken Access Control

Insecure Direct Object Reference

Information Leakage

GraphQL Injection

Page 32: Security in serverless world

http://bit.ly/2uKhGXF

Page 33: Security in serverless world

http://bit.ly/2uKhGXF

Page 34: Security in serverless world

app dependency is a large attack surface

Page 35: Security in serverless world

further compounded by transient dependencies

Page 36: Security in serverless world

https://david-dm.org/request/request?view=tree

Page 37: Security in serverless world

https://snyk.io

Page 38: Security in serverless world

security updates are often bundled with unrelated feature and API changes

Page 39: Security in serverless world

your security is as strong as its weakest link

Page 40: Security in serverless world

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

Networkingruns on

needs

Source Code

has

maintains

Page 41: Security in serverless world

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

Page 42: Security in serverless world
Page 43: Security in serverless world
Page 44: 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

Networkingruns on

needs

Source Code

has

maintains

A1, A3, …

Page 45: Security in serverless world

people are often the WEAKEST link in the security chain

Page 46: Security in serverless world
Page 47: 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…

Networkingruns on

needs

Source Code

has

maintains

Page 48: 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

brute force, known account leaks, …

Networkingruns on

needs

Source Code

has

maintains

Page 49: 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

brute force, known account leaks, …

Networkingruns on

needs

Source Code

has

maintains

Page 50: Security in serverless world

http://bit.ly/2sFDwYX

…obtained publish access to 14% of npm packages…

Page 51: Security in serverless world

http://bit.ly/2sFDwYX

debug, request, react, co, express, moment, gulp, mongoose, mysql, bower, browserify, electron, jasmine, cheerio, modernizr, redux, …

Page 52: Security in serverless world

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.

Page 53: Security in serverless world

20% of all monthly NPM downloads…

Page 54: Security in serverless world

brute force

known account leaks from other sources

leaked NPM credentials (github, etc.)

Page 55: Security in serverless world

http://bit.ly/2sFDwYX

Page 56: Security in serverless world

http://bit.ly/2sFDwYX

662 users had password “123456” 172 — “123”

124 — “password”

Page 57: Security in serverless world
Page 58: Security in serverless world
Page 59: Security in serverless world

WTF!?!?

Page 60: Security in serverless world
Page 61: Security in serverless world
Page 62: Security in serverless world

oh god, that was too easy…

Page 63: Security in serverless world
Page 64: Security in serverless world
Page 65: Security in serverless world

compromised package is a transient dependency

sigh…

Page 66: Security in serverless world

still “works”…

Page 67: Security in serverless world
Page 68: Security in serverless world

NPM default - get latest “compatible” version, ie. 1.X.X

Page 69: Security in serverless world

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

Page 70: Security in serverless world
Page 71: Security in serverless world

use npm shrinkwrap or upgrade to NPM 5

Page 72: Security in serverless world

imagine…

Page 73: Security in serverless world

not specific to Node.js or NPM

Page 74: Security in serverless world
Page 75: Security in serverless world

Shared Responsibility Model

Page 76: Security in serverless world

who can invoke the function?

Page 77: Security in serverless world

what can the function access?

Page 78: Security in serverless world

Least Privilege Principle

Page 79: Security in serverless world

don’t leave insecure Lambda functions in VPC

Page 80: Security in serverless world

per function policy

Page 81: Security in serverless world
Page 82: Security in serverless world
Page 83: Security in serverless world

requires developer discipline(which means no one would do it)

Page 84: Security in serverless world

IAM policies not versioned with Lambda functions

Page 85: Security in serverless world

better in Serverless 1.X

Page 86: 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

Page 87: Security in serverless world

S3

AWS IoT

DynamoDB

RDS

EventStore

Elasticsearch Couchbase

Redshift

Neo4j

Google BigQuery

Page 88: Security in serverless world

secure sensitive data both at rest and in-transit

Page 89: Security in serverless world

leverage server-side encryption

Page 90: Security in serverless world

http://amzn.to/1N3Twb8

Page 91: Security in serverless world

http://amzn.to/1xF41eX

Page 92: Security in serverless world

http://amzn.to/2tgvFR2

Page 93: Security in serverless world

use API key or IAM roles to protect internal APIs

Page 94: Security in serverless world
Page 95: Security in serverless world
Page 96: Security in serverless world

Minimise function’s access

Page 97: Security in serverless world

Least Privilege Principle

Page 98: Security in serverless world

Disposability is a virtue

Page 99: Security in serverless world

AWS Lambda docs

Delete old Lambda functions that you are no longer using.

http://amzn.to/2jzLmkb

Page 100: Security in serverless world

easier said than done…

Page 101: Security in serverless world

identifying component ownership in a big IT

organization is challenging

Page 102: Security in serverless world

identifying ownership of individual functions is

much harder

Page 103: Security in serverless world

source: http://www.digitalattackmap.com

Page 104: Security in serverless world

more likely to scale through DoS attacks

Page 105: Security in serverless world

DoS + per exec billing = Denial of Wallet problem

Page 106: Security in serverless world

have to choose between a DoS and a DoW problem…

Page 107: Security in serverless world
Page 108: 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.

Page 109: Security in serverless world

async syncS3

SNS SES

CloudFormation CloudWatch Logs

CloudWatch Events Scheduled Events

CodeCommit AWS Config

http://amzn.to/2vs2lIg

Cognito Alexa Lex

API Gateway

streamsDynamoDB Stream

Kinesis Stream

Lambda handles retries (twice, then DLQ)

Page 110: Security in serverless world

http://bit.ly/2v7F2E4

Page 111: Security in serverless world

DoS attack 2+ Retries+

?

Page 112: Security in serverless world

DoS attack Regex DoS attack

long Lambda timeout 2+ Retries+

?

Page 113: Security in serverless world
Page 114: Security in serverless world

Day 1

Page 115: Security in serverless world

Day 2

Page 116: Security in serverless world
Page 117: Security in serverless world

no long-lived compromised servers

Page 118: Security in serverless world

containers are reused, avoid sensitive data in /tmp

Page 119: Security in serverless world
Page 120: Security in serverless world
Page 121: Security in serverless world

no accidentally exposed directories

Page 122: Security in serverless world
Page 123: Security in serverless world
Page 124: Security in serverless world
Page 125: Security in serverless world

http://bit.ly/2tlGTbc

Page 126: Security in serverless world

monitor activities in unused regions using CloudWatch Events

Page 127: Security in serverless world
Page 128: Security in serverless world

set up billing alarms in unused regions

Page 129: Security in serverless world

watertight compartments that can contain water in the case of hull breach or other leaks

Page 130: Security in serverless world

Michael Nygard

Page 131: Security in serverless world
Page 132: Security in serverless world

Least Privilege Principle

Page 133: Security in serverless world

per function policies

Page 134: Security in serverless world

account level isolation

Page 135: Security in serverless world

Recap

Page 136: Security in serverless world

App dependencies is a much BIGGER attack surface than you probably realise

Page 137: Security in serverless world
Page 138: Security in serverless world

sanitise inputs and outputs

Page 139: Security in serverless world

Least Privilege Principle

Page 140: Security in serverless world

here’s your per function policy

NEXT!

Page 141: Security in serverless world

S3

AWS IoT

DynamoDB

RDS

EventStore

Elasticsearch Couchbase

Redshift

Neo4j

Google BigQuery

encrypt data at rest

Page 142: Security in serverless world

S3

AWS IoT

DynamoDB

RDS

EventStore

Elasticsearch Couchbase

Redshift

Neo4j

Google BigQuery

and in-transit

Page 143: Security in serverless world

delete unused functions.

Page 144: Security in serverless world

DoS DoW*

* Denial of Wallet

Page 145: Security in serverless world
Page 146: Security in serverless world
Page 147: Security in serverless world
Page 148: 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

Page 149: Security in serverless world

don’t be an unwilling bit miner

Page 150: Security in serverless world

don’t be an unwilling bit miner

safeguard your credentials…

Page 151: Security in serverless world

prod dev

compartmentalise breaches

Page 152: Security in serverless world

people are often the WEAKEST link in the security chain

Page 153: Security in serverless world

@theburningmonktheburningmonk.comgithub.com/theburningmonk

Page 154: Security in serverless world

sign up here: http://bit.ly/2xCwJEe