containers and security serverless applications, · how a container is born dockerfile docker image...

43

Upload: others

Post on 21-May-2020

20 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update
Page 2: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

Serverless Applications, Containers and SecurityAnderson Dadario, CISSP, CSSLP

dadario.com.br | @andersonmvdFounder of Gauntlet.io

2

Page 3: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

Cool stuff we’ll talk about

- Containers- Serverless Applications

3

Page 4: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

Who am I?

Official (ISC)² CSSLP Instructor

Founder of Gauntlet.io

Loves Software {Engineering,Security}

4

Page 5: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

Simple deployment flow

How it works

5

Developer

Code Repository (GIT, SVN,

Mercurial, etc)Server Users

Page 6: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

Simple deployment flow

How it works

6

Developer

Users

Shared Private

ServerCode Repository

(GIT, SVN, Mercurial, etc)

Page 7: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

Shared server

7

Page 8: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

Shared server The Server

Your User

8

Page 9: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

Shared server The Server

Your User

Security

- The weakest link breaks the chain- Increased attack surface

- See dirty cow vulnerability

9

Page 10: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

Private server

10

Page 11: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

Private server

Your Server

Hypervisor (AWS / Google Cloud / Etc)

Your User

11

Page 12: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

Private server

Your Server

Hypervisor (AWS / Google Cloud / Etc)

Your User

Security

- The weakest link breaks the chain- Decreased attack surface

- But Hypervisor may have security flaws as well

12

Page 13: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

Setting up your private rerver

Manually connect through SSH & Go Nuts

13

Page 14: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

Setting up your private rerver

Manually connect through SSH & Go Nuts

Security

- It’s Ad hoc, non repeatable- Requires a different security

approach for every server, as they’re likely to be different

- Creates high technical debt

14

Page 15: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

Use CM Tools

Use Configuration Management (CM) Tools

... OR ...

15

Page 16: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

Use CM Tools

Use Configuration Management (CM) Tools

... OR ...

Security

- Chef & Puppet use agents & servers that need to be secured / tested

- Server recipes make the process repeatable

- Security needs to audit every recipe

16

Page 17: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

Ansible example---

- hosts: server

sudo: yes

sudo_user: root

tasks:

- name: install mysql-server

apt: name=mysql-server state=present

update_cache=yes

- name: Ensure mysql is running

service: name=mysql state=started

That’s the Infrastructure as Code (IaC) concept.

17

Page 18: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

Use cloud provider server images

... OR ...

18

Page 19: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

Use cloud provider server images

... OR ...

Security

- Only go to a cloud provider you trust. It’s like Google, they’ll hold your important assets and data

- Their images may be tampered, so make sure you trust them first

- You still need to configure (and secure) your application deploy process

- Enable 2FA

19

Page 20: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

Use a Platform as a Service (PaaS)

Platform as a Service (PaaS) - (Send them your code and let

them manage the servers)

... OR ...

20

Page 21: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

Use a Platform as a Service (PaaS)

Platform as a Service (PaaS) - (Send them your code and let

them manage the servers)

... OR ...

Security

- It’s all about trust and Vendor Risk Assessment. You’re as secure as your PaaS provider as long as you don’t mess up with your personal security (leak passwords, use weak passwords, etc)

- Review every server requirements, read everything they offer for security

- Enable 2FA

21

Page 22: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

22

Page 23: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

Or go with Containers

Containers

... OR ...

23

Page 24: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

It’s like Debian’s chroot on steroids!

● Isolation with LESS overhead● Faster deploys● Faster developer onboarding● Defense-in-depth mechanismVilla

ins

24

Page 25: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

How a container is born

Dockerfile Docker Image Docker Containers

builds a generates

25

Page 26: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

How a container is born

Dockerfile Docker Image Docker Containers

builds a generates

Dockerfile

FROM ubuntu:14.04RUN apt-get update && apt-get install -y redis-serverEXPOSE 6379ENTRYPOINT ["/usr/bin/redis-server"]

Build Image

$ docker build -t AndersonDadario/redis .

Run Container

$ docker run --name redis -d AndersonDadario/redis

26

Page 27: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

What is in a container

Docker Containers

A container is a server with its own:● IP Address● Network● File system● Etc

27

Page 28: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

Two major ways to use containers

» Microservices• Thin Containers• One process per Container

» Monolithic• Fat Containers• Multiple processes per Container• Looks like a Virtual Machine (VM)

28

Page 29: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

Typical flow with Containers

ImageDatabase of

Images

29

Page 30: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

What can you do about security?

- Keep Docker Up-to-date- Harden Docker Daemon- Don’t run containers as root

- And don’t let users easily become root- Remove SUID flags / SUDO

- Don’t put sensitive files in your container- Audit Dockerfiles

30

Page 31: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

What can you do about security?

- Reduce Container Capabilities- Avoid images without Dockerfile

- As you can’t check what’s inside so easily, e.g., look for backdoors

- Only install an image if you trust- If possible verify

- Limit Container Usage (Memory/Etc) Anti-DoS31

Page 32: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

What can you do about security?

- Run security scanners on images- Docker Security Scanning (Paid)- CoreOS Clair (Open Source)

- Consider using a Container Security Platform- Evaluated by Gartner:

- Aqua Security, CloudPassage, Docker, Magnetic.io, Twistlock, Weaveworks

32

Page 33: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

Enough about containers

Time is finite after all..Show me the Serverless Stuff

33

Page 34: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

Serverless Applications

34

Page 35: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

The Challenge

- Case Study: Dadario’s Learning Platform- Build a Serverless Application with:

- Authentication- Authorization- Payment Processing

35

Page 36: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

Authentication

dadario.com.brUsers

Authentication Provider

(1) GET login page

(2) Login page with Auth0 JS

(3) User authenticate

on Auth0

(4) After login, redirect user back to site with his/her account info.

36

Page 37: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

Authorization

dadario.com.brUsers

Authentication Provider

(1) GET login page

(2) Login page with Auth0 JS

(3) User authenticate

on Auth0

(4) After login, redirect user back to site with his/her account info.

The account information includes the path to each video playlist url (hard to guess), thus there is no “authorization on the client side”.

37

Page 38: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

Payment Processing

dadario.com.brUsers

Payment Provider

(1) Pay course

(2) Redirect to PayPal

(3) User pay using

PayPal

(4) After success, PayPal notifies an AWS API Gateway endpoint, which runs an AWS Lambda function.

User Database

(5) Lambda verifies if request came from PayPal and the payment was ok, then update user account with video playlists.

38

Page 39: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

But there are Limitations

- Few languages available- Can’t include all libraries- Need automation to organize multiple

functions

For some needs it’s a great solution.

39

Page 40: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

And how does Security fits in?

- Vendor Risk Assessment- Security Configuration- Code Review- Fuzzing- Note: Pentest requires Vendor approval

40

Page 41: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

Takeaways

- Development is changing, thus Security must catch up- Your applications are safer in Containers- Serverless Applications are real and growing

41

Page 43: Containers and Security Serverless Applications, · How a container is born Dockerfile Docker Image Docker Containers builds a generates Dockerfile FROM ubuntu:14.04 RUN apt-get update

Thank you

Anderson Dadariodadario.com.br | @andersonmvd

Founder of Gauntlet.io

43

Slides are available for free on https://dadario.com.br/slides