Slide 1

Slide 1 text

APP SEC IN THE TIME OF DOCKER CONTAINERS Akash Mahajan - Director Appsecco DevOpsDays India 2016 #DevOpsDaysIN

Slide 2

Slide 2 text

THAT WEB APPLICATION SECURITY GUY

Slide 3

Slide 3 text

“ There is space for only 5 types of security approaches in this world -Said no one ever

Slide 4

Slide 4 text

THIS IS HOW I FELT WHEN I STARTED TAKING DOCKER SERIOUSLY Image courtesy Arguazuarma http://arquazuarma.blogspot.in/2011/01/from-outside-looking-in.html

Slide 5

Slide 5 text

DIDN’T FEEL LIKE THAT WEB APPLICATION SECURITY GUY From  h'p://rigel.co/2013/11/26/impostor-­‐syndrome/

Slide 6

Slide 6 text

DEALING WITH IT

Slide 7

Slide 7 text

HOW WE DO APPSEC CURRENTLY?

Slide 8

Slide 8 text

AUTOMATED WEB APPLICATION SCANNERS NAIL HAMMER ANALOGY

Slide 9

Slide 9 text

BUG BOUNTY BEGINNERS - WIN SOME - LOSE SOME

Slide 10

Slide 10 text

BUG BOUNTY/PENTESTERS & EXPERTS MAKE IT LOOK SIMPLE

Slide 11

Slide 11 text

SECURITY TESTERS PLOD AWAY USING CHECKLISTS & TOOLS

Slide 12

Slide 12 text

WHAT IS A DOCKER CONTAINER?

Slide 13

Slide 13 text

A DOCKER CONTAINER? ➤ A container allows a developer to package up and application and all of its dependent parts in a box ➤ This box is basically an isolated environment and the application has everything it needs to run inside of this environment

Slide 14

Slide 14 text

CONTAINERS ARE COMING A value of 100 is the peak popularity for a term DOCKER IN GOOGLE TRENDS SINCE JUL 2013-PRESENT

Slide 15

Slide 15 text

IF THE DRY GRAPH WASN’T ENOUGH TO CONVINCE YOU

Slide 16

Slide 16 text

“ Why has this change to docker become imminent? -Me, when I started noticing how quickly the developer world was moving to docker

Slide 17

Slide 17 text

REPEAT AFTER ME DEVELOPER PRODUCTIVITY OPERATIONAL PRODUCTIVITY DEVELOPER PRODUCTIVITY

Slide 18

Slide 18 text

“ Regardless of how much security folks think their opinion matters, most of the developers don’t give a fish about what we think - Akash Mahajan, learning the truth the hard way

Slide 19

Slide 19 text

THIS IS WHAT DEVELOPERS WANT - AN IT FREE WORLD http://www.infoq.com/cn/articles/docker-core-technology-preview

Slide 20

Slide 20 text

BUT ISN’T THIS JUST LIKE CHROOT?

Slide 21

Slide 21 text

INSTALLING MUTILLIDAE (PHP+APACHE+MYSQL APP)

Slide 22

Slide 22 text

OR USE SOMETHING AS SIMPLE AS KITEMATIC (MAC ONLY)

Slide 23

Slide 23 text

“ If a developer has to choose between being productive or being secure, more or less she/he will chose being productive - Something I should have said!

Slide 24

Slide 24 text

PRODUCTIVITY TRUMPS SECURITY TRUE FACT - SAMPLE SIZE 1 curl  http://path/to/bash/script.sh  |  sudo  bash

Slide 25

Slide 25 text

CONTAINERS, APPSEC & OWASP

Slide 26

Slide 26 text

FOR CONTAINERS THESE ARE THE RELEVANT APPSEC RISKS OWASP Top 10 Issue What is that? A1 Injection Stuff that harms the server A2 Broken AuthN Stuff that lets attackers access parts of the application, which allows them to upload stuff that harms the server A4 Insecure Direct Object Reference A5 Security Misconfiguration Stuff that makes the infra supporting the app insecure A9 Using components with Known Vulnerabilities Stuff that possibly enables any or all of the above, due to using 3rd party stuff

Slide 27

Slide 27 text

OWASP TOP 10 - A1 INJECTION Attacker Data Files Creds Shell

Slide 28

Slide 28 text

OWASP TOP 10 - A2 BROKEN AUTHN & SESSION MANAGEMENT What is the name of my pet? Tinkerbell

Slide 29

Slide 29 text

OWASP TOP 10 - A4 INSECURE DIRECT OBJECT REFERENCE 890141042432191 890141042432192 890141042432193 890141042432194

Slide 30

Slide 30 text

OWASP TOP 10 - A5 SECURITY MISCONFIGURATION

Slide 31

Slide 31 text

WHAT CAN WE DO NOW TO GET ON THE BANDWAGON? Task What should be done Testing Applications We usually need the setup running somewhere (testing) Secure Development Pre-configured dockerfiles with selective containers which allow for secure configuration by default Secure Operations Running docker in secured, isolated instances

Slide 32

Slide 32 text

TESTING APPLICATIONS AGAINST OWASP TOP 10 Now all of this can be in Docker! Now all of this can be in Docker! APP == API

Slide 33

Slide 33 text

SECURE DEVELOPMENT BY BEING SECURE BY DEFAULT ENABLE CONTENT TRUST AND NOTARY

Slide 34

Slide 34 text

SECURE OPERATIONS - FOLLOW BEST PRACTICES ➤Kernel Namespaces ➤Control Groups ➤Capabilities ➤Syscall Filtering with Seccomp ➤Mandatory Access Control ➤SELinux ➤AppArmor

Slide 35

Slide 35 text

PRACTICE DEFENCE IN DEPTH USING CIS CHECKLIST ➤ Follow the CIS Docker Benchmark to get a checklist of things to do on ➤ Host Configuration (15 list items) ➤ Docker Daemon Configuration (13 list items) ➤ Files, Permissions and configuration files for Docker Daemon (20 list items) ➤ Container Images (5 list items) ➤ Container Runtime (25 list items) ➤ Follow Docker Security Operations Best Practices https://benchmarks.cisecurity.org/tools2/docker/CIS_Docker_1.11.0_Benchmark_v1.0.0.pdf

Slide 36

Slide 36 text

DOCKER HOST AND CONTAINER SECURITY GETTING STARTED Start by reading Understanding docker security and best practices https:// blog.docker.com/2015/05/understanding-docker-security-and-best-practices/ Use the Docker Bench Security script to automatically check best practices as outlined by the CIS Docker Benchmark version 1.11 https://github.com/docker/ docker-bench-security Play this awesome game to break out of docker containers in your browser https:// contained.af/ Read the full CIS Docker 1.11.0 Benchmark report https:// benchmarks.cisecurity.org/tools2/docker/CIS_Docker_1.11.0_Benchmark_v1.0.0.pdf Understanding and Hardening Linux Containers by NCC Group https:// www.nccgroup.trust/us/our-research/understanding-and-hardening-linux-containers/

Slide 37

Slide 37 text

TO START WITH, THIS IS WHAT YOU SHOULD DO Test the application as you normally would If you find application security issues report these Do white box assessment with the docker security checklists Keep track of any privilege escalation bugs in docker daemon or the underlying hypervisor/VM tech you are using Understand what is the software supply chain for the application & pick secure alternatives for orchestration itself

Slide 38

Slide 38 text

DOCKER FAILS Couple of #devoops moments

Slide 39

Slide 39 text

TWITTER’S VINE SOURCE CODE DUMP BY @AVICODER ➤ @avicoder a bug bounty hunter, he spoke about this bug at a null/ OWASP/G4H Bangalore meet in June 2016 ➤ He found an interesting sub domain for Vine ( A twitter video app) ➤ He had stumbled upon a private docker registry being used ➤ He realised that the version being used didn’t use any authentication and by querying the API he determined the docker files being hosted ➤ He did a docker pull of an image that contained the source code for the Vine App and got $$$$$ bounty ➤ https://avicoder.me/2016/07/22/Twitter-Vine-Source-code-dump/

Slide 40

Slide 40 text

DOCKER IMAGE INSECURITY ➤ This has been fixed now! Especially from docker version 1.10 ➤ Earlier if an image had been compressed with xz (in C so not safety for memory) ➤ Docker Daemon would exec the xz binary as root user ➤ If there was a single vulnerability in xz, a docker pull could result in complete compromise ➤ Read more about the vulnerability https://titanous.com/posts/docker- insecurity ➤ Read more about how this was fixed https://titanous.com/posts/docker- insecurity

Slide 41

Slide 41 text

NOT EXACTLY A DOCKER ISSUE BUT THIS SHOULD RESONATE

Slide 42

Slide 42 text

DIRTY DIRTY COW HAS A POC FOR DOCKER ESCAPE http://www.theregister.co.uk/2016/11/01/docker_user_havent_patched_dirty_cow_yet_bad_news/

Slide 43

Slide 43 text

QUESTIONS @makash | https://linkd.in/webappsecguy | akash@appsecco.com