SlideShare a Scribd company logo
The Golden Ticket: Docker
and High Security
Microservices
Aaron Grattafiori
Technical Director
whoami(1)
Longtime Hacker,
Pentester, and Linux geek
Wrote a few things about
Linux Containers…
The Golden Ticket: Docker and High Security Microservices by Aaron Grattafiori
a disclaimer…
Microservices are not for everyone
Microservices can be hard
Microservices often distribute complexity
Agenda
You’ve seen Microservices before
You’ve seen Microservices before
“Worker bees can leave.
Even drones can fly away.
The Queen is their slave.”
You’ve seen Microservices before
You’ve seen Microservices before
You’ve seen Microservices before
You’ve seen Microservices before
int main() {
printf(“foon”);
return 0;
}
void DoSomething() {
printf (“foon”);
}
int main() {
DoSomething();
return 0;
}
Your Legacy Application
What the sales team
sees…
What the developers see
What ops/sysadmins see
What hackers see…
What hackers think
Applied Security
Principles
A layered defense…
Shrink attack surfaces and present
harden those which remain
The Principle of Defense in Depth
The Golden Ticket: Docker and High Security Microservices by Aaron Grattafiori
Monolithic applications make this difficult
and Microservices make this easy
Key: not having a single point of security failure
The Principle of Defense in Depth
“Absolute power corrupts absolutely”
“Avoid running as root” is about
shrinking trust boundaries.
Monoliths make this difficult and
Microservices make this easier
The Principle of Least Privilege
#
“Sane defaults, Isolate by trust”
The Principle of Least Surprise
“Access provided on a need to know basis”
Military security, Mafia management,
database connections, defense in depth, …
The Principle of Least Access
This will be become a theme, a war against excess and
complexity…
Microservices have complexity “at scale”
Microservices still reduce overall complexity
“Least” is Common to all…
1)Establish trust boundaries
2)Identify, minimize and harden attack surfaces
3)Reduce scope and access
4)Layer protections / defenses
See “Stop Buying Security Prescriptions” by Justin Schuh of Google
.. Because “Least” is a Good Idea!
Compare and
Contrast
Upsides of Monolith AppSec
Building and Standing it up is a “known known”
Architecture is quite simple
Existing culture of dev/business/compliance/sales
Downsides of Monolith AppSec
Compromise of a single point often means compromise
of the entire application or network
Authentication requirements/creds are global in scope
Simple to build, but security is hard to tailor
Upsides of Microservices AppSec
UNIX model works well
Highly application/function specific containers permit
highly application specific security
Establishing a Trusted Computing Base (TCB)
Upsides of Microservices AppSec
Least privilege and app-specific security is much easier
Greatly reduced attack surfaces
Independent patching/updates/versions
Downsides of Microservices AppSec
A “Known unknown”
Requires good understanding of application
Legacy applications are not easily adapted
Downsides of Microservices AppSec
May require devops and other culture changes
Complexity breeds insecurity
“Requires” dumb pipes networking architecture
Exploring
Architectures
Exploring Real World Compromise
“Imagetragick” RCE
“Shellshock” RCE
General Command Injection
General LFI/LFR
Denial of Service
Exploring Real World Compromise
Exploring Real World Compromise
API Web Service
Front-end
Presentation
Back-end
Application
Database
LB
Exploring Real World Compromise
API Web Service
Front-end
Presentation
Back-end
Application
Database
Exploring Real World Compromise
API Web Service
Front-end
Presentation
Back-end
Application
Database
Exploring Real World Compromise
API Web Service
Front-end
Presentation
Back-end
Application
Database
Relationship Status: “Its Complicated”
Exploring Real World Solutions
API Web Service
Front-end Presentation
Back-end Application
Database
Enforcing Security Boundaries
API Web Service
Front-end Presentation
Back-end Application
Database
LB
Breaking Up Again
Back-end Application
Payments
AuthZ
Uploads
Cache
Legacy
Limit Compromises
Payments
AuthZ
Uploads
Cache
Legacy
Nope
Nope
Nope
Limited
Limit Compromises: OSI Edition
Layer 7 Authentication: Application
Layer 4/5 (7) Authentication: TLS
Layer 3 Authentication: IPSEC
Thinking about it another way
What’s the attack surface of:
an SSL VPN using username+pw auth
vs.
an SSL VPN using TLS client certs
vs.
an IPSEC-only endpoint using key-based auth ?
Thinking about it another way
Layer 7 Authentication/Encryption? aka XML
Encryption or HTTP Header auth
Or Layer 4/5 Authentication/Encryption? aka TLS/mTLS
Or Layer 3 Authentication/Encryption? aka IPSEC
In general…
Layer 7 authentication should be required
Less than layer 7 authentication is highly desirable
Don’t forget Authentication != Authorization
Don’t forget about transport security
Containers Map to Microservices
Container Model Microservices Model
Root Capabilities Capability based security
Different network namespaces Overlay networks or SDN
One application per container One core function per application
… …
A Few Attacks of Container Systems
Cross Container Attacks on Host
Cross Container Attacks on Network
Exploiting Vulnerable Application
Exploiting Vulnerable Library
Exploiting Out of Date Docker Engine
Exploiting Host Kernel
Targeting Container Configuration
Poisoning Service Discovery
Targeting Docker API Configuration
Attacking Container Management
Pruning The Attack Tree
Application attack? Container itself,
capabilities, immutable files, mount flags,
MAC, read-only rootfs, defensive coding, etc.
Kernel/syscall exploit ?
Seccomp and kernel hardening
Seccomp weakness?
Manditory Access Control
Pruning The Attack Tree
Compromised kernel/host OS?
Network hardening, isolation on trust,
logging, least privilege, least access
Compromised employee credentials?
Least access, least privilege, key-based
authentication
Microservices in
Docker or runc
Why Docker / runc ?
Helps with standardization, testing, security
Strong security defaults (seccomp, caps) and options (user namespace)
App containers help follow and develop the Microservice model
Why use runC for MS?
Lightweight and minimal!
Open Container Initiative
Docker’s libcontainer
Why not runC ?
Lightweight and minimal/manual
Weak documentation/examples/debugging
Warning: Apparmor not a default build tag and Apparmor
support / User namespace support not enabled by default
Security starts with the base OS
Minimal Distro (CoreOS/RancherOS/etc)?
Plain old Ubuntu Server?
Clear Linux?
… Unikernel?
Minimal: Distro
Security starts with the base OS
It’s important to understand how a distribution:
handles updates,
binary package compilation,
security defaults (MAC),
default kernel options,
sysctl settings, ….
Minimal: Kernel
Common sense configuration
make menuconfig: configuration, modules
grsecurity
Minimal Container?
… Why stop at shrinking just the host?
Don’t we want least access? Less updates?
Minimal: Container Images
docker-nginx mongo
FROM debian:jesse FROM debian:wheezy
redis node
FROM debian:jesse FROM buildpack-deps:jessie
Minimal: Container Images
So what exactly is FROM debian:jesse ?
FROM scratch
ADD rootfs.tar.xz /
CMD ["/bin/bash"]
= 137 MB
Minimal: Container Images
So what about FROM debian:wheezy ?
97 MB!
So what about Jenkins? ElasticSearch? Postgres?
FROM debian:jesse
Not Minimal Enough!
Even before an apt-get, there are still tons of libraries,
executables, perl, even language files our process doesn’t need!
That’s more patching, disk space, attack surface and post-
exploitation utilities we don’t need
General idea for Docker
$ cat Dockerfile
FROM scratch
ADD stuff
CMD [“/stuff”]
$ docker build
General idea for runC
$ mkdir rootfs
$ cp stuff rootfs/
$ runc spec
$ sudo runc run foo
Reality for runC (and Docker)
$ ldd /path/to/program
$ mkdir –p rootfs /usr /lib # … etc
$ cp /path/to/program rootfs/
$ cp /path/to/lib.so.0 rootfs/lib/
$ *cross fingers*
Minimal Container Images: Go + Docker
https://blog.codeship.com/building-minimal-
docker-containers-for-go-applications/http://blog.xebia.com/create-the-smallest-possible-docker-container/
Golang wiki server example
$ ls -l rootfs
rootfs/wiki
rootfs/usr/lib/libpthread.so.0
rootfs/usr/lib/libc.so.6
rootfs/lib64/ld-linux-x86-64.so.2
$ du –hs rootfs
7.3M
Minimal Container Images: Nginx + Docker
Roughly 32 libs + /usr/sbin/nginx + a few config
files and dirs…
= 15 MB!
“Make things as simple as
possible, but not simpler.”
— Albert Einstein
nanosleep(2)
Minimal (hardened) Host OS: ✔
Minimal (hardened) Root FS: ✔
Minimal (hardened) Kernel: ✔
The Golden Ticket: Docker and High Security Microservices by Aaron Grattafiori
Mandatory Access Control
MAC as a Linux Security Module (LSM)-
AppArmor, SELinux, etc. Grsecurity RBAC is also
nice
OSX uses TrustedBSD, Microsoft has MIC
Mandatory Access Control
Default Docker AppArmor policy is very good
Monolithic MAC policy must include a large number of
files, permission grants, complexity
Microservices again allow for specific security
Nested AppArmor
Profile /bin/bash {
/bin/cat Px,
profile /bin/cat {
/etc/hosts r,
}
}
Going back to Golang HTTPd PoC
Profile /wiki {
network inet stream,
/usr/lib/* mr,
/lib64/* mr,
/wiki mixr,
}
Custom AppArmor Profiles
Generating profiles with aa-genprof
Understanding/using application
is key, profiling is still required
Custom AppArmor Profiles
Common mistakes/problems:
- Providing too much access
- Dealing with wildcards
- Path-based ACLs
Custom AppArmor Profiles
Easier Mode for Docker/runC: Using Bane for profiles
by Jessie Frazelle
Hard Mode: FullSystemPolicy
Avoid deny lists
AppArmor Profile Gotchas
Profiles must be loaded by AppArmor first
Abstractions may be more verbose than you would like
Exercise your app is key, run unit/QA/regression tests
Profiling is difficult within a container itself
Seccomp BPF
Seccomp Profiles
MAC is vulnerable to kernel attacks… kernel is huge attack surface
Seccomp default filter enabled in Docker Engine >= 1.10 !!
Seccomp is widely used in security, recently now with BPF
Putting the BPF into Seccomp BPF
General BPF pseudocode:
1) Check architecture
2) Get syscall number
N) ALLOW or DENY syscall
N+1) KILL, TRAP, TRACE, ALLOW process
Why Custom Profiles?
Default seccomp filter permits 304 syscalls :/
Minimal applications need minimal syscall set
We want to practice least privilege!
Methods for Generating Seccomp Profiles
1) strace/ltrace
2) Kernel help (sysdig or systemtap)
3) Auditd/auditctl
4) Seccomp itself w/ SECCOMP_RET_TRACE and
PTRACE_O_TRACESECCOMP
Seccomp Profiles using strace
strace via ptrace(2)
Weird timing bugs can occur, count will miss some calls
Tracing outside of Docker should be fine
Some programs just don’t want to be traced
strace (and also ltrace –S)
$ strace –f /bin/ls
execve("/bin/ls", ["ls"], [/* 21 vars */]) = 0
brk(0) = 0x8c31000
mmap2(NULL, 8192, PROT_READ, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0xb78c7000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No
such file or directory)
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=65354, ...}) = 0
…
Seccomp Profiles using sysdig
Sysdig is cool! Really cool
Requires a kernel module :/
But it’s really cool!
sysdig
$ sysdig evt.type=open and proc.name=niginx
$ sysdig –p “%evt.type” proc.name=niginx
$ sysdig –p “%evt.type” | sort –u > 
nginix.syscalls.txt
Seccomp Profiles using auditd
Auditd is a nice system for… auditing
Requires a daemon and complex-ish config
Very cool power built-in but not ideal for this!
(Could collect calls over time )
Seccomp Profiles using Seccomp
Basic C example by Kees Cook and Will Drewry:
(https://outflux.net/teach-seccomp/)
– Profiling via SECCOMP_RET_TRAP is slow going
Using SECCOMP_RET_TRACE is better!
Seccomp Profiles using Seccomp
But why?
ALLOW, TRAP, TRACE, KILL, ERRNO are limited,
all of them block the call except for TRACE
(and default ALLOW is not a good model)
Seccomp Profiles using Seccomp
- Create a given syscall whitelist
- Set the default action to SECCOMP_RET_TRACE
- use ptrace(2) with PTRACE_O_TRACESECCOMP
- Log appropriate info
- Repeat until no soft-failures!
Ptrace PoC
$ seccomp-trace –f filter.txt /path/to/program
...
called sycall # 157 : prctl
called sycall # 157 : prctl
SECCOMP WOULD BLOCK 56
called sycall # 56 : clone
SECCOMP WOULD BLOCK 14
SECCOMP WOULD BLOCK 13
called sycall # 14 : rt_sigprocmask
called sycall # 13 : rt_sigaction
General Seccomp Pitfalls
Profiles are fragile!
Profiles are architecture dependent- limiting
container portability
Seccomp in Docker
Default (large) whitelist or:
--security-opt seccomp=<profile>
"seccomp": {
"defaultAction": "SCMP_ACT_KILL",
"architectures": [ "SCMP_ARCH_X86" ],
"syscalls": [
{ "name": "getcwd",
"action": "SCMP_ACT_ALLOW"
}
]
}
Seccomp in runC
Part of the default build!
"seccomp": {
"defaultAction": "SCMP_ACT_KILL",
"architectures": [ "SCMP_ARCH_X86" ],
"syscalls": [
{ "name": "getcwd",
"action": "SCMP_ACT_ALLOW"
}
]
}
Seccomp notes
Remember that seccomp filters are not sandboxes
Libseccomp is nice and has Go bindings
see also: oz sandbox train mode by Subgraph OS
Be careful implementing it from scratch, blacklists
/denylists are risky! (don’t allow ptrace!)
Seccomp Pro Tips for Docker/runC
https://github.com/konstruktoid/Docker/blob/master/
Scripts/genSeccomp.sh can save time or JSON pain !
You can always confirm Seccomp by looking in:
grep Seccomp /proc/<PID>/status
nanosleep(2)
Minimal (hardened) Host OS: ✔
Minimal (hardened) Root FS: ✔
Minimal (hardened) Kernel: ✔
Minimal AppArmor/SELinux: ✔
Minimal Seccomp whitelist: ✔
Security
Recommendations
High Security Docker Microservices
- Enable User namespace
- Use app specific AppArmor if possible
- Use app specific Seccomp whitelist if possible
- Harden host system
- Restrict host access
- Consider network security
High Security runC Microservices
- Configure user namespace
- Enable AppArmor + use app specific if possible
- Use app specific Seccomp whitelist if possible
- Harden host system
- Restrict host access
- Consider network security
The Problem of Managing Secrets
Avoid environment variables/flat files
– Why? … because execve()
Use temporary secret “injection”
– Temp bind mount, load into mem-only, unmount
Vault | Keywiz
Immutable Containers also Help
Extending the basic idea of non-executable memory
pages or OpenBSD’s W^X
- data-only containers, app-only containers
Frustrating vulnerability exploitation and limiting
system post-exploitation
Networking and AuthN/AuthZ
TLS. TLS. TLS.
It’s 2016 and all network traffic should be encrypted
(and authenticated) Just do it.
Authentication/Access at the lowest possible layer. Network
access controls go against “dumb pipes” but they’re important!
Networking and AuthN/AuthZ
But I want dumb pipes!?
Then use SDN / Overlay networks on top…
Beware of cross-container networking / multi-tenant
risks with a single bridge interface
Other Security Recommendations
Have a specification / Dockumentation
Generate application-specific and overall threat models
Don’t forget about application security itself (containers and
MS can’t help if your app itself is still vulnerable)
Other Security Recommendations
Orchestration / Service Discovery things… Use security
Generate application-specific and overall threat models
Don’t forget about application security itself (containers and
MS can’t help if your app itself is still vulnerable)
Other Security Recommendations
Microservice logging and accountability is important, collect and
keep logs centrally (and actually look at them once in while)
Security is much easier to do if you make it part of your lifecycle
in the beginning “build it in don’t patch it on”
Checkout my whitepaper for more general container security info
and more info on many of the topics covered here.
Thank you!
Aaron.Grattafiori /at/ nccgroup dot trust
@dyn___

More Related Content

PDF
What’s New in Docker - Victor Vieux, Docker
Docker, Inc.
 
PDF
Docker Security Deep Dive by Ying Li and David Lawrence
Docker, Inc.
 
PPTX
Docker - Demo on PHP Application deployment
Arun prasath
 
PDF
What's New in Docker 1.12 (June 20, 2016) by Mike Goelzer & Andrea Luzzardi
Mike Goelzer
 
PDF
DockerCon SF 2015: Docker Security
Docker, Inc.
 
PDF
DockerCon EU 2015: Docker and PCI-DSS - Lessons learned in a security sensiti...
Docker, Inc.
 
PDF
CI and CD at Scale: Scaling Jenkins with Docker and Apache Mesos
Carlos Sanchez
 
PPTX
A Survey of Container Security in 2016: A Security Update on Container Platforms
Salman Baset
 
What’s New in Docker - Victor Vieux, Docker
Docker, Inc.
 
Docker Security Deep Dive by Ying Li and David Lawrence
Docker, Inc.
 
Docker - Demo on PHP Application deployment
Arun prasath
 
What's New in Docker 1.12 (June 20, 2016) by Mike Goelzer & Andrea Luzzardi
Mike Goelzer
 
DockerCon SF 2015: Docker Security
Docker, Inc.
 
DockerCon EU 2015: Docker and PCI-DSS - Lessons learned in a security sensiti...
Docker, Inc.
 
CI and CD at Scale: Scaling Jenkins with Docker and Apache Mesos
Carlos Sanchez
 
A Survey of Container Security in 2016: A Security Update on Container Platforms
Salman Baset
 

What's hot (20)

PDF
DCSF19 CMD and Conquer: Containerizing the Monolith
Docker, Inc.
 
PDF
Building a Secure App with Docker - Ying Li and David Lawrence, Docker
Docker, Inc.
 
PDF
DockerCon SF 2015: Enabling Microservices @Orbitz
Docker, Inc.
 
PDF
On-Demand Image Resizing from Part of the monolith to Containerized Microserv...
Docker, Inc.
 
PPT
Amazon Web Services and Docker
Paolo latella
 
PPTX
Docker Security Overview
Sreenivas Makam
 
PPTX
Docker Security workshop slides
Docker, Inc.
 
PDF
Online Meetup: Why should container system / platform builders care about con...
Docker, Inc.
 
PDF
Troubleshooting Tips from a Docker Support Engineer
Jeff Anderson
 
PDF
DockerCon EU 2015: Shipping Manifests, Bill of Lading and Docker Metadata and...
Docker, Inc.
 
PDF
Docker London: Container Security
Phil Estes
 
PDF
Docker serverless v1.0
Thomas Chacko
 
PDF
DockerCon EU 2015: Trading Bitcoin with Docker
Docker, Inc.
 
PPTX
Comprehensive Monitoring for Docker
Christian Beedgen
 
PPTX
Docker Container As A Service - March 2016
Patrick Chanezon
 
PDF
Automation and Collaboration Across Multiple Swarms Using Docker Cloud - Marc...
Docker, Inc.
 
PPTX
DockerCon EU 2015: Stop Being Lazy and Test Your Software!
Docker, Inc.
 
PDF
DCSF19 How Docker Simplifies Kubernetes for the Masses
Docker, Inc.
 
PDF
Networking Overview for Docker Platform
Aditya Patawari
 
PDF
Global Operations with Docker for the Enterprise - Nico Kabar, Docker
Docker, Inc.
 
DCSF19 CMD and Conquer: Containerizing the Monolith
Docker, Inc.
 
Building a Secure App with Docker - Ying Li and David Lawrence, Docker
Docker, Inc.
 
DockerCon SF 2015: Enabling Microservices @Orbitz
Docker, Inc.
 
On-Demand Image Resizing from Part of the monolith to Containerized Microserv...
Docker, Inc.
 
Amazon Web Services and Docker
Paolo latella
 
Docker Security Overview
Sreenivas Makam
 
Docker Security workshop slides
Docker, Inc.
 
Online Meetup: Why should container system / platform builders care about con...
Docker, Inc.
 
Troubleshooting Tips from a Docker Support Engineer
Jeff Anderson
 
DockerCon EU 2015: Shipping Manifests, Bill of Lading and Docker Metadata and...
Docker, Inc.
 
Docker London: Container Security
Phil Estes
 
Docker serverless v1.0
Thomas Chacko
 
DockerCon EU 2015: Trading Bitcoin with Docker
Docker, Inc.
 
Comprehensive Monitoring for Docker
Christian Beedgen
 
Docker Container As A Service - March 2016
Patrick Chanezon
 
Automation and Collaboration Across Multiple Swarms Using Docker Cloud - Marc...
Docker, Inc.
 
DockerCon EU 2015: Stop Being Lazy and Test Your Software!
Docker, Inc.
 
DCSF19 How Docker Simplifies Kubernetes for the Masses
Docker, Inc.
 
Networking Overview for Docker Platform
Aditya Patawari
 
Global Operations with Docker for the Enterprise - Nico Kabar, Docker
Docker, Inc.
 
Ad

Viewers also liked (20)

PDF
Containerd: Building a Container Supervisor by Michael Crosby
Docker, Inc.
 
PPTX
Thinking Inside the Container: A Continuous Delivery Story by Maxfield Stewart
Docker, Inc.
 
PDF
Getting Deep on Orchestration: APIs, Actors, and Abstractions in a Distribute...
Docker, Inc.
 
PDF
runC: The little engine that could (run Docker containers) by Docker Captain ...
Docker, Inc.
 
PDF
Sharding Containers: Make Go Apps Computer-Friendly Again by Andrey Sibiryov
Docker, Inc.
 
PDF
Microservices + Events + Docker = A Perfect Trio by Docker Captain Chris Rich...
Docker, Inc.
 
PDF
Docker for Ops: Extending Docker with APIs, Drivers and Plugins by Arnaud Por...
Docker, Inc.
 
PDF
Cloning Running Servers with Docker and CRIU by Ross Boucher
Docker, Inc.
 
PDF
Docker for Mac and Windows: The Insider's Guide by Justin Cormack
Docker, Inc.
 
PDF
Unikernels and docker from revolution to evolution — unikernels and docker ...
Docker, Inc.
 
PPTX
Windows Server and Docker - The Internals Behind Bringing Docker and Containe...
Docker, Inc.
 
PPTX
DockerCon 16 General Session Day 1
Docker, Inc.
 
PPTX
DockerCon 16 General Session Day 2
Docker, Inc.
 
PPTX
Prometheus design and philosophy
Docker, Inc.
 
PPTX
Docker Roadshow 2016
Docker, Inc.
 
PDF
Docker for Developers - Part 2 by Borja Burgos and Fernando Mayo
Docker, Inc.
 
PDF
Docker and the Linux Kernel
Docker, Inc.
 
PDF
Docker for Developers - Part 1 by David Gageot
Docker, Inc.
 
PPTX
Docker for Ops: Docker Storage and Volumes Deep Dive and Considerations by Br...
Docker, Inc.
 
PPTX
Docker for Ops: Docker Networking Deep Dive, Considerations and Troubleshooti...
Docker, Inc.
 
Containerd: Building a Container Supervisor by Michael Crosby
Docker, Inc.
 
Thinking Inside the Container: A Continuous Delivery Story by Maxfield Stewart
Docker, Inc.
 
Getting Deep on Orchestration: APIs, Actors, and Abstractions in a Distribute...
Docker, Inc.
 
runC: The little engine that could (run Docker containers) by Docker Captain ...
Docker, Inc.
 
Sharding Containers: Make Go Apps Computer-Friendly Again by Andrey Sibiryov
Docker, Inc.
 
Microservices + Events + Docker = A Perfect Trio by Docker Captain Chris Rich...
Docker, Inc.
 
Docker for Ops: Extending Docker with APIs, Drivers and Plugins by Arnaud Por...
Docker, Inc.
 
Cloning Running Servers with Docker and CRIU by Ross Boucher
Docker, Inc.
 
Docker for Mac and Windows: The Insider's Guide by Justin Cormack
Docker, Inc.
 
Unikernels and docker from revolution to evolution — unikernels and docker ...
Docker, Inc.
 
Windows Server and Docker - The Internals Behind Bringing Docker and Containe...
Docker, Inc.
 
DockerCon 16 General Session Day 1
Docker, Inc.
 
DockerCon 16 General Session Day 2
Docker, Inc.
 
Prometheus design and philosophy
Docker, Inc.
 
Docker Roadshow 2016
Docker, Inc.
 
Docker for Developers - Part 2 by Borja Burgos and Fernando Mayo
Docker, Inc.
 
Docker and the Linux Kernel
Docker, Inc.
 
Docker for Developers - Part 1 by David Gageot
Docker, Inc.
 
Docker for Ops: Docker Storage and Volumes Deep Dive and Considerations by Br...
Docker, Inc.
 
Docker for Ops: Docker Networking Deep Dive, Considerations and Troubleshooti...
Docker, Inc.
 
Ad

Similar to The Golden Ticket: Docker and High Security Microservices by Aaron Grattafiori (20)

PDF
DockerCon 2017 - General Session Day 1 - Solomon Hykes
Docker, Inc.
 
PPTX
Weave User Group Talk - DockerCon 2017 Recap
Patrick Chanezon
 
PPTX
DockerCon EU 2015: The Missing Piece: when Docker networking unleashing soft ...
Docker, Inc.
 
PDF
Hack the whale
Marco Ferrigno
 
PPTX
DockerCon - The missing piece : when Docker networking unleashes software arc...
Laurent Grangeau
 
PPTX
The missing piece : when Docker networking and services finally unleashes so...
Adrien Blind
 
PPTX
Microservices and containers for the unitiated
Kevin Lee
 
PDF
Docker, Linux Containers (LXC), and security
Jérôme Petazzoni
 
PDF
Docker, Linux Containers, and Security: Does It Add Up?
Jérôme Petazzoni
 
PDF
Docker app armor_usecase
Kazuki Omo
 
PPTX
Docker Deep Dive Understanding Docker Engine Docker for DevOps
MehwishHayat3
 
PDF
Rooting Out Root: User namespaces in Docker
Phil Estes
 
PPTX
The Hacking Games - Operation System Vulnerabilities Meetup 29112022
lior mazor
 
PDF
Docker en kernel security
smart_bit
 
PDF
Docker security: Rolling out Trust in your container
Ronak Kogta
 
PPTX
Docker - Der Wal in der Kiste
Ulrich Krause
 
PDF
Linux Kernel Security: Adapting 1960s Technology to Meet 21st Century Threats
James Morris
 
PPTX
Infrastructure as code: running microservices on AWS using Docker, Terraform,...
Yevgeniy Brikman
 
PDF
Infrastructureascode slideshare-160331143725
miguel dominguez
 
PDF
Infrastructureascode slideshare-160331143725
MortazaJohari
 
DockerCon 2017 - General Session Day 1 - Solomon Hykes
Docker, Inc.
 
Weave User Group Talk - DockerCon 2017 Recap
Patrick Chanezon
 
DockerCon EU 2015: The Missing Piece: when Docker networking unleashing soft ...
Docker, Inc.
 
Hack the whale
Marco Ferrigno
 
DockerCon - The missing piece : when Docker networking unleashes software arc...
Laurent Grangeau
 
The missing piece : when Docker networking and services finally unleashes so...
Adrien Blind
 
Microservices and containers for the unitiated
Kevin Lee
 
Docker, Linux Containers (LXC), and security
Jérôme Petazzoni
 
Docker, Linux Containers, and Security: Does It Add Up?
Jérôme Petazzoni
 
Docker app armor_usecase
Kazuki Omo
 
Docker Deep Dive Understanding Docker Engine Docker for DevOps
MehwishHayat3
 
Rooting Out Root: User namespaces in Docker
Phil Estes
 
The Hacking Games - Operation System Vulnerabilities Meetup 29112022
lior mazor
 
Docker en kernel security
smart_bit
 
Docker security: Rolling out Trust in your container
Ronak Kogta
 
Docker - Der Wal in der Kiste
Ulrich Krause
 
Linux Kernel Security: Adapting 1960s Technology to Meet 21st Century Threats
James Morris
 
Infrastructure as code: running microservices on AWS using Docker, Terraform,...
Yevgeniy Brikman
 
Infrastructureascode slideshare-160331143725
miguel dominguez
 
Infrastructureascode slideshare-160331143725
MortazaJohari
 

More from Docker, Inc. (20)

PDF
Containerize Your Game Server for the Best Multiplayer Experience
Docker, Inc.
 
PDF
How to Improve Your Image Builds Using Advance Docker Build
Docker, Inc.
 
PDF
Build & Deploy Multi-Container Applications to AWS
Docker, Inc.
 
PDF
Securing Your Containerized Applications with NGINX
Docker, Inc.
 
PDF
How To Build and Run Node Apps with Docker and Compose
Docker, Inc.
 
PDF
Hands-on Helm
Docker, Inc.
 
PDF
Distributed Deep Learning with Docker at Salesforce
Docker, Inc.
 
PDF
The First 10M Pulls: Building The Official Curl Image for Docker Hub
Docker, Inc.
 
PDF
Monitoring in a Microservices World
Docker, Inc.
 
PDF
COVID-19 in Italy: How Docker is Helping the Biggest Italian IT Company Conti...
Docker, Inc.
 
PDF
Predicting Space Weather with Docker
Docker, Inc.
 
PDF
Become a Docker Power User With Microsoft Visual Studio Code
Docker, Inc.
 
PDF
How to Use Mirroring and Caching to Optimize your Container Registry
Docker, Inc.
 
PDF
Monolithic to Microservices + Docker = SDLC on Steroids!
Docker, Inc.
 
PDF
Kubernetes at Datadog Scale
Docker, Inc.
 
PDF
Labels, Labels, Labels
Docker, Inc.
 
PDF
Using Docker Hub at Scale to Support Micro Focus' Delivery and Deployment Model
Docker, Inc.
 
PDF
Build & Deploy Multi-Container Applications to AWS
Docker, Inc.
 
PDF
From Fortran on the Desktop to Kubernetes in the Cloud: A Windows Migration S...
Docker, Inc.
 
PDF
Developing with Docker for the Arm Architecture
Docker, Inc.
 
Containerize Your Game Server for the Best Multiplayer Experience
Docker, Inc.
 
How to Improve Your Image Builds Using Advance Docker Build
Docker, Inc.
 
Build & Deploy Multi-Container Applications to AWS
Docker, Inc.
 
Securing Your Containerized Applications with NGINX
Docker, Inc.
 
How To Build and Run Node Apps with Docker and Compose
Docker, Inc.
 
Hands-on Helm
Docker, Inc.
 
Distributed Deep Learning with Docker at Salesforce
Docker, Inc.
 
The First 10M Pulls: Building The Official Curl Image for Docker Hub
Docker, Inc.
 
Monitoring in a Microservices World
Docker, Inc.
 
COVID-19 in Italy: How Docker is Helping the Biggest Italian IT Company Conti...
Docker, Inc.
 
Predicting Space Weather with Docker
Docker, Inc.
 
Become a Docker Power User With Microsoft Visual Studio Code
Docker, Inc.
 
How to Use Mirroring and Caching to Optimize your Container Registry
Docker, Inc.
 
Monolithic to Microservices + Docker = SDLC on Steroids!
Docker, Inc.
 
Kubernetes at Datadog Scale
Docker, Inc.
 
Labels, Labels, Labels
Docker, Inc.
 
Using Docker Hub at Scale to Support Micro Focus' Delivery and Deployment Model
Docker, Inc.
 
Build & Deploy Multi-Container Applications to AWS
Docker, Inc.
 
From Fortran on the Desktop to Kubernetes in the Cloud: A Windows Migration S...
Docker, Inc.
 
Developing with Docker for the Arm Architecture
Docker, Inc.
 

Recently uploaded (20)

PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
PDF
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
PPTX
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
PDF
Software Development Methodologies in 2025
KodekX
 
PDF
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
PPTX
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
PDF
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
PDF
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
PDF
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
PDF
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
PPTX
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
PDF
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
PPTX
The Future of AI & Machine Learning.pptx
pritsen4700
 
PDF
The Future of Artificial Intelligence (AI)
Mukul
 
PDF
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
PDF
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
Software Development Methodologies in 2025
KodekX
 
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
The Future of AI & Machine Learning.pptx
pritsen4700
 
The Future of Artificial Intelligence (AI)
Mukul
 
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 

The Golden Ticket: Docker and High Security Microservices by Aaron Grattafiori

  • 1. The Golden Ticket: Docker and High Security Microservices Aaron Grattafiori Technical Director
  • 2. whoami(1) Longtime Hacker, Pentester, and Linux geek Wrote a few things about Linux Containers…
  • 4. a disclaimer… Microservices are not for everyone Microservices can be hard Microservices often distribute complexity
  • 7. You’ve seen Microservices before “Worker bees can leave. Even drones can fly away. The Queen is their slave.”
  • 11. You’ve seen Microservices before int main() { printf(“foon”); return 0; } void DoSomething() { printf (“foon”); } int main() { DoSomething(); return 0; }
  • 13. What the sales team sees…
  • 19. A layered defense… Shrink attack surfaces and present harden those which remain The Principle of Defense in Depth
  • 21. Monolithic applications make this difficult and Microservices make this easy Key: not having a single point of security failure The Principle of Defense in Depth
  • 22. “Absolute power corrupts absolutely” “Avoid running as root” is about shrinking trust boundaries. Monoliths make this difficult and Microservices make this easier The Principle of Least Privilege #
  • 23. “Sane defaults, Isolate by trust” The Principle of Least Surprise
  • 24. “Access provided on a need to know basis” Military security, Mafia management, database connections, defense in depth, … The Principle of Least Access
  • 25. This will be become a theme, a war against excess and complexity… Microservices have complexity “at scale” Microservices still reduce overall complexity “Least” is Common to all…
  • 26. 1)Establish trust boundaries 2)Identify, minimize and harden attack surfaces 3)Reduce scope and access 4)Layer protections / defenses See “Stop Buying Security Prescriptions” by Justin Schuh of Google .. Because “Least” is a Good Idea!
  • 28. Upsides of Monolith AppSec Building and Standing it up is a “known known” Architecture is quite simple Existing culture of dev/business/compliance/sales
  • 29. Downsides of Monolith AppSec Compromise of a single point often means compromise of the entire application or network Authentication requirements/creds are global in scope Simple to build, but security is hard to tailor
  • 30. Upsides of Microservices AppSec UNIX model works well Highly application/function specific containers permit highly application specific security Establishing a Trusted Computing Base (TCB)
  • 31. Upsides of Microservices AppSec Least privilege and app-specific security is much easier Greatly reduced attack surfaces Independent patching/updates/versions
  • 32. Downsides of Microservices AppSec A “Known unknown” Requires good understanding of application Legacy applications are not easily adapted
  • 33. Downsides of Microservices AppSec May require devops and other culture changes Complexity breeds insecurity “Requires” dumb pipes networking architecture
  • 35. Exploring Real World Compromise “Imagetragick” RCE “Shellshock” RCE General Command Injection General LFI/LFR Denial of Service
  • 36. Exploring Real World Compromise
  • 37. Exploring Real World Compromise API Web Service Front-end Presentation Back-end Application Database LB
  • 38. Exploring Real World Compromise API Web Service Front-end Presentation Back-end Application Database
  • 39. Exploring Real World Compromise API Web Service Front-end Presentation Back-end Application Database
  • 40. Exploring Real World Compromise API Web Service Front-end Presentation Back-end Application Database
  • 41. Relationship Status: “Its Complicated”
  • 42. Exploring Real World Solutions API Web Service Front-end Presentation Back-end Application Database
  • 43. Enforcing Security Boundaries API Web Service Front-end Presentation Back-end Application Database LB
  • 44. Breaking Up Again Back-end Application Payments AuthZ Uploads Cache Legacy
  • 47. Layer 7 Authentication: Application
  • 48. Layer 4/5 (7) Authentication: TLS
  • 50. Thinking about it another way What’s the attack surface of: an SSL VPN using username+pw auth vs. an SSL VPN using TLS client certs vs. an IPSEC-only endpoint using key-based auth ?
  • 51. Thinking about it another way Layer 7 Authentication/Encryption? aka XML Encryption or HTTP Header auth Or Layer 4/5 Authentication/Encryption? aka TLS/mTLS Or Layer 3 Authentication/Encryption? aka IPSEC
  • 52. In general… Layer 7 authentication should be required Less than layer 7 authentication is highly desirable Don’t forget Authentication != Authorization Don’t forget about transport security
  • 53. Containers Map to Microservices Container Model Microservices Model Root Capabilities Capability based security Different network namespaces Overlay networks or SDN One application per container One core function per application … …
  • 54. A Few Attacks of Container Systems Cross Container Attacks on Host Cross Container Attacks on Network Exploiting Vulnerable Application Exploiting Vulnerable Library Exploiting Out of Date Docker Engine Exploiting Host Kernel Targeting Container Configuration Poisoning Service Discovery Targeting Docker API Configuration Attacking Container Management
  • 55. Pruning The Attack Tree Application attack? Container itself, capabilities, immutable files, mount flags, MAC, read-only rootfs, defensive coding, etc. Kernel/syscall exploit ? Seccomp and kernel hardening Seccomp weakness? Manditory Access Control
  • 56. Pruning The Attack Tree Compromised kernel/host OS? Network hardening, isolation on trust, logging, least privilege, least access Compromised employee credentials? Least access, least privilege, key-based authentication
  • 58. Why Docker / runc ? Helps with standardization, testing, security Strong security defaults (seccomp, caps) and options (user namespace) App containers help follow and develop the Microservice model
  • 59. Why use runC for MS? Lightweight and minimal! Open Container Initiative Docker’s libcontainer
  • 60. Why not runC ? Lightweight and minimal/manual Weak documentation/examples/debugging Warning: Apparmor not a default build tag and Apparmor support / User namespace support not enabled by default
  • 61. Security starts with the base OS Minimal Distro (CoreOS/RancherOS/etc)? Plain old Ubuntu Server? Clear Linux? … Unikernel?
  • 63. Security starts with the base OS It’s important to understand how a distribution: handles updates, binary package compilation, security defaults (MAC), default kernel options, sysctl settings, ….
  • 64. Minimal: Kernel Common sense configuration make menuconfig: configuration, modules grsecurity
  • 65. Minimal Container? … Why stop at shrinking just the host? Don’t we want least access? Less updates?
  • 66. Minimal: Container Images docker-nginx mongo FROM debian:jesse FROM debian:wheezy redis node FROM debian:jesse FROM buildpack-deps:jessie
  • 67. Minimal: Container Images So what exactly is FROM debian:jesse ? FROM scratch ADD rootfs.tar.xz / CMD ["/bin/bash"] = 137 MB
  • 68. Minimal: Container Images So what about FROM debian:wheezy ? 97 MB! So what about Jenkins? ElasticSearch? Postgres? FROM debian:jesse
  • 69. Not Minimal Enough! Even before an apt-get, there are still tons of libraries, executables, perl, even language files our process doesn’t need! That’s more patching, disk space, attack surface and post- exploitation utilities we don’t need
  • 70. General idea for Docker $ cat Dockerfile FROM scratch ADD stuff CMD [“/stuff”] $ docker build
  • 71. General idea for runC $ mkdir rootfs $ cp stuff rootfs/ $ runc spec $ sudo runc run foo
  • 72. Reality for runC (and Docker) $ ldd /path/to/program $ mkdir –p rootfs /usr /lib # … etc $ cp /path/to/program rootfs/ $ cp /path/to/lib.so.0 rootfs/lib/ $ *cross fingers*
  • 73. Minimal Container Images: Go + Docker https://blog.codeship.com/building-minimal- docker-containers-for-go-applications/http://blog.xebia.com/create-the-smallest-possible-docker-container/
  • 74. Golang wiki server example $ ls -l rootfs rootfs/wiki rootfs/usr/lib/libpthread.so.0 rootfs/usr/lib/libc.so.6 rootfs/lib64/ld-linux-x86-64.so.2 $ du –hs rootfs 7.3M
  • 75. Minimal Container Images: Nginx + Docker Roughly 32 libs + /usr/sbin/nginx + a few config files and dirs… = 15 MB!
  • 76. “Make things as simple as possible, but not simpler.” — Albert Einstein
  • 77. nanosleep(2) Minimal (hardened) Host OS: ✔ Minimal (hardened) Root FS: ✔ Minimal (hardened) Kernel: ✔
  • 79. Mandatory Access Control MAC as a Linux Security Module (LSM)- AppArmor, SELinux, etc. Grsecurity RBAC is also nice OSX uses TrustedBSD, Microsoft has MIC
  • 80. Mandatory Access Control Default Docker AppArmor policy is very good Monolithic MAC policy must include a large number of files, permission grants, complexity Microservices again allow for specific security
  • 81. Nested AppArmor Profile /bin/bash { /bin/cat Px, profile /bin/cat { /etc/hosts r, } }
  • 82. Going back to Golang HTTPd PoC Profile /wiki { network inet stream, /usr/lib/* mr, /lib64/* mr, /wiki mixr, }
  • 83. Custom AppArmor Profiles Generating profiles with aa-genprof Understanding/using application is key, profiling is still required
  • 84. Custom AppArmor Profiles Common mistakes/problems: - Providing too much access - Dealing with wildcards - Path-based ACLs
  • 85. Custom AppArmor Profiles Easier Mode for Docker/runC: Using Bane for profiles by Jessie Frazelle Hard Mode: FullSystemPolicy Avoid deny lists
  • 86. AppArmor Profile Gotchas Profiles must be loaded by AppArmor first Abstractions may be more verbose than you would like Exercise your app is key, run unit/QA/regression tests Profiling is difficult within a container itself
  • 88. Seccomp Profiles MAC is vulnerable to kernel attacks… kernel is huge attack surface Seccomp default filter enabled in Docker Engine >= 1.10 !! Seccomp is widely used in security, recently now with BPF
  • 89. Putting the BPF into Seccomp BPF General BPF pseudocode: 1) Check architecture 2) Get syscall number N) ALLOW or DENY syscall N+1) KILL, TRAP, TRACE, ALLOW process
  • 90. Why Custom Profiles? Default seccomp filter permits 304 syscalls :/ Minimal applications need minimal syscall set We want to practice least privilege!
  • 91. Methods for Generating Seccomp Profiles 1) strace/ltrace 2) Kernel help (sysdig or systemtap) 3) Auditd/auditctl 4) Seccomp itself w/ SECCOMP_RET_TRACE and PTRACE_O_TRACESECCOMP
  • 92. Seccomp Profiles using strace strace via ptrace(2) Weird timing bugs can occur, count will miss some calls Tracing outside of Docker should be fine Some programs just don’t want to be traced
  • 93. strace (and also ltrace –S) $ strace –f /bin/ls execve("/bin/ls", ["ls"], [/* 21 vars */]) = 0 brk(0) = 0x8c31000 mmap2(NULL, 8192, PROT_READ, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb78c7000 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory) open("/etc/ld.so.cache", O_RDONLY) = 3 fstat64(3, {st_mode=S_IFREG|0644, st_size=65354, ...}) = 0 …
  • 94. Seccomp Profiles using sysdig Sysdig is cool! Really cool Requires a kernel module :/ But it’s really cool!
  • 95. sysdig $ sysdig evt.type=open and proc.name=niginx $ sysdig –p “%evt.type” proc.name=niginx $ sysdig –p “%evt.type” | sort –u > nginix.syscalls.txt
  • 96. Seccomp Profiles using auditd Auditd is a nice system for… auditing Requires a daemon and complex-ish config Very cool power built-in but not ideal for this! (Could collect calls over time )
  • 97. Seccomp Profiles using Seccomp Basic C example by Kees Cook and Will Drewry: (https://outflux.net/teach-seccomp/) – Profiling via SECCOMP_RET_TRAP is slow going Using SECCOMP_RET_TRACE is better!
  • 98. Seccomp Profiles using Seccomp But why? ALLOW, TRAP, TRACE, KILL, ERRNO are limited, all of them block the call except for TRACE (and default ALLOW is not a good model)
  • 99. Seccomp Profiles using Seccomp - Create a given syscall whitelist - Set the default action to SECCOMP_RET_TRACE - use ptrace(2) with PTRACE_O_TRACESECCOMP - Log appropriate info - Repeat until no soft-failures!
  • 100. Ptrace PoC $ seccomp-trace –f filter.txt /path/to/program ... called sycall # 157 : prctl called sycall # 157 : prctl SECCOMP WOULD BLOCK 56 called sycall # 56 : clone SECCOMP WOULD BLOCK 14 SECCOMP WOULD BLOCK 13 called sycall # 14 : rt_sigprocmask called sycall # 13 : rt_sigaction
  • 101. General Seccomp Pitfalls Profiles are fragile! Profiles are architecture dependent- limiting container portability
  • 102. Seccomp in Docker Default (large) whitelist or: --security-opt seccomp=<profile> "seccomp": { "defaultAction": "SCMP_ACT_KILL", "architectures": [ "SCMP_ARCH_X86" ], "syscalls": [ { "name": "getcwd", "action": "SCMP_ACT_ALLOW" } ] }
  • 103. Seccomp in runC Part of the default build! "seccomp": { "defaultAction": "SCMP_ACT_KILL", "architectures": [ "SCMP_ARCH_X86" ], "syscalls": [ { "name": "getcwd", "action": "SCMP_ACT_ALLOW" } ] }
  • 104. Seccomp notes Remember that seccomp filters are not sandboxes Libseccomp is nice and has Go bindings see also: oz sandbox train mode by Subgraph OS Be careful implementing it from scratch, blacklists /denylists are risky! (don’t allow ptrace!)
  • 105. Seccomp Pro Tips for Docker/runC https://github.com/konstruktoid/Docker/blob/master/ Scripts/genSeccomp.sh can save time or JSON pain ! You can always confirm Seccomp by looking in: grep Seccomp /proc/<PID>/status
  • 106. nanosleep(2) Minimal (hardened) Host OS: ✔ Minimal (hardened) Root FS: ✔ Minimal (hardened) Kernel: ✔ Minimal AppArmor/SELinux: ✔ Minimal Seccomp whitelist: ✔
  • 108. High Security Docker Microservices - Enable User namespace - Use app specific AppArmor if possible - Use app specific Seccomp whitelist if possible - Harden host system - Restrict host access - Consider network security
  • 109. High Security runC Microservices - Configure user namespace - Enable AppArmor + use app specific if possible - Use app specific Seccomp whitelist if possible - Harden host system - Restrict host access - Consider network security
  • 110. The Problem of Managing Secrets Avoid environment variables/flat files – Why? … because execve() Use temporary secret “injection” – Temp bind mount, load into mem-only, unmount Vault | Keywiz
  • 111. Immutable Containers also Help Extending the basic idea of non-executable memory pages or OpenBSD’s W^X - data-only containers, app-only containers Frustrating vulnerability exploitation and limiting system post-exploitation
  • 112. Networking and AuthN/AuthZ TLS. TLS. TLS. It’s 2016 and all network traffic should be encrypted (and authenticated) Just do it. Authentication/Access at the lowest possible layer. Network access controls go against “dumb pipes” but they’re important!
  • 113. Networking and AuthN/AuthZ But I want dumb pipes!? Then use SDN / Overlay networks on top… Beware of cross-container networking / multi-tenant risks with a single bridge interface
  • 114. Other Security Recommendations Have a specification / Dockumentation Generate application-specific and overall threat models Don’t forget about application security itself (containers and MS can’t help if your app itself is still vulnerable)
  • 115. Other Security Recommendations Orchestration / Service Discovery things… Use security Generate application-specific and overall threat models Don’t forget about application security itself (containers and MS can’t help if your app itself is still vulnerable)
  • 116. Other Security Recommendations Microservice logging and accountability is important, collect and keep logs centrally (and actually look at them once in while) Security is much easier to do if you make it part of your lifecycle in the beginning “build it in don’t patch it on” Checkout my whitepaper for more general container security info and more info on many of the topics covered here.
  • 117. Thank you! Aaron.Grattafiori /at/ nccgroup dot trust @dyn___

Editor's Notes

  • #2: THANKS FOR SKIPPING LUNCH
  • #3: Make bad things happen to good software -Has been called the “War and Peace” of Linux container security
  • #9: Distributed Responsibility/Redundancy
  • #10: iOS Seatbelt splits up applications Android User Sandbox and permissions limit each specific application
  • #11: Adobe Reader and Google Chrome, among others, use specific IPC Calls and mini-sandboxed workers to isolate and reduce attack surfaces Drawing a line in the sand because of complexity, code quality, etc…
  • #12: Even your programs split features into different classes or functions For reasons of simplicity, organization, easy re-use and error handling
  • #13: Looks kinda like this… maybe you’ve shoved in into a container, maybe you want to but haven’t yet…
  • #14: This is sales, sorry if any of you are in the audience, but it’s true. They love the monolith…
  • #15: Maybe this is more accurate … A careful balance.
  • #16: A huge pile of crap… and they need to take care of it somehow….
  • #17: Hackers see a large attack surface… Many possible holes
  • #18: They love the dinosaur!
  • #20: Also known as “With great power comes great responsibility”
  • #23: Also known as “With great power comes great responsibility” This recommendation applies to more than just user accounts…
  • #25: Monoliths make this difficult Microservices again make this easy
  • #29: Architecture is a well understood solution Compliance is easier with a traditional architecture….
  • #31: Do one thing and do it well… Chain together for benifits
  • #36: THE WORST CASE SCENARIOS
  • #39: LOTS OF CROSS COMMUNICATION YOU DON’T ALWAYS UNDERSTAND IT
  • #40: EVEN A SECOND LARGE SERVER
  • #41: THE BREAKUP
  • #42: COMMUNICATION BECOMES MORE CLEAR SECURITY CAN BE BETTER ENFORCED
  • #43: COMMUNICATION BECOMES MORE CLEAR SECURITY CAN BE BETTER ENFORCED
  • #45: Legacy code gets compromised Even given a Container Escape … Sandbox All The Things!
  • #46: SECURITY RARELY INCLUDED
  • #47: SECURITY RARELY INCLUDED AT LOWER LAYERS Application level authentication exposes a much larger attack surface!
  • #48: Mutual TLS lets us take this even further Speed is rarely if ever a real concern. AES-NI helped this.
  • #49: SECURITY RARELY INCLUDED
  • #55: “all the way down” Caution: no magic bullets…
  • #57: Configuration often involves tracing down a missing curley brace in your JSON config
  • #64: This is basically a “minbase” debbootstrap This is all BEFORE A GREEDY APT-GET
  • #65: This is all BEFORE A GREEDY APT-GET
  • #66: Think back to least access
  • #69: Obviously we’re assuming a dynamic executable here Some dynamic libs will need other libs!
  • #70: The go compiler will build static if we’re using pure Golang !
  • #71: Removing empty directories we have 4 files in our container If we build this with pure go, we’d have a statically linked binary and could even have just a single file in our container
  • #74: LETS GO BACK TO 1998….
  • #75: Microsoft of course did what Microsoft does best … Renamed a standard and wrote something themselves. They dropped the MIC so to speak.
  • #76: but focused on container escape not inner-container limits…
  • #81: SHE NAMED IT BANE ON PURPOSE
  • #86: Maybe on the order of 25-50…
  • #93: Seccomp return values are not friendly
  • #94: TRACE doesn’t explicitly indicate it allows the system call
  • #95: Here is the basic idea…
  • #100: If using blacklist, make sure to disallow X86 system calls!! https://gist.github.com/thejh/c5b670a816bbb9791a6d
  • #101: If using blacklist, make sure to disallow X86 system calls!! https://gist.github.com/thejh/c5b670a816bbb9791a6d
  • #106: Logs are append only Local data cannot be executed
  • #107: Client Certificates are quite nice!! Nothing is stopping you from doing TLS and Layer 7 Authentication
  • #108: Client Certificates are quite nice!! Nothing is stopping you from doing TLS and Layer 7 Authentication SDN- compromise can be global in scope….