Docker, Linux Containers, and Security: Does It Add Up?

Jérôme Petazzoni
Docker,
Linux Containers,
Security:
Does it add up?
Jérôme Petazzoni
@jpetazzo
Docker Inc.
@docker
Question:
Is it safe to run
applications in
Linux Containers?
...
Yes
/* shocker: docker PoC VMM-container breakout (C) 2014 Sebastian Krahmer
*
* Demonstrates that any given docker image someone is asking
* you to run in your docker setup can access ANY file on your host,
* e.g. dumping hosts /etc/shadow or other sensitive info, compromising
* security of the host and any other docker VM's on it.
*
* docker using container based VMM: Sebarate pid and net namespace,
* stripped caps and RO bind mounts into container's /. However
* as its only a bind-mount the fs struct from the task is shared
* with the host which allows to open files by file handles
* (open_by_handle_at()). As we thankfully have dac_override and
* dac_read_search we can do this. The handle is usually a 64bit
* string with 32bit inodenumber inside (tested with ext4).
* Inode of / is always 2, so we have a starting point to walk
* the FS path and brute force the remaining 32bit until we find the
* desired file (It's probably easier, depending on the fhandle export
* function used for the FS in question: it could be a parent inode# or
* the inode generation which can be obtained via an ioctl).
* [In practise the remaining 32bit are all 0 :]
*
* tested with docker 0.11 busybox demo image on a 3.11 kernel:
*
* docker run -i busybox sh
*
* seems to run any program inside VMM with UID 0 (some caps stripped);
Wait
No!
Docker has changed its security status to
It's complicated
Who am I? Why am I here?
 Jérôme Petazzoni (@jpetazzo)
- Grumpy French Linux DevOps
 Operated dotCloud PAAS
for 3+ years
- hosts arbitrary code for arbitrary users
- all services, all apps, run in containers
- no major security issue yet (fingers crossed)
 Containerize all the things!
- VPN-in-Docker, KVM-in-Docker,
Xorg-in-Docker, Docker-in-Docker...
What are those “containers” ?
(1/3)
 Technically: ~chroot on steroids
- a container is a set of processes
(running on top of common kernel)
- isolated* from the rest of the machine
(cannot see/affect/harm host or other containers)
- using namespaces to have private view of the system
(network interfaces, PID tree, mountpoints...)
- and cgroups to have metered/limited/reserved resources
(to mitigate “bad neighbor” effect)
*Limitations may apply.
What are those “containers” ?
(2/3)
 From a distance: looks like a VM
- I can SSH into my container
- I can have root access in it
- I can install packages in it
- I have my own eth0 interface
- I can tweak routing table, iptables rules
- I can mount filesystems
- etc.
What are those “containers” ?
(3/3)
 Lightweight, fast, disposable...
virtual environments
- boot in milliseconds
- just a few MB of intrinsic disk/memory usage
- bare metal performance is possible
 The new way to build, ship, deploy,
run your apps!
Why is this a hot topic?
 Containers:
have been around for decades
 LXC (Linux Containers):
have been around for years
So, what?
Blame
Docker
Why is this a hot topic?
 Containers:
have been around for decades
 LXC (Linux Containers):
have been around for years
 Tools like Docker have commoditized LXC
(i.e. made it very easy to use)
 Everybody wants to deploy containers now
 But, oops, LXC wasn't made for security
 We want containers, and we want them now;
how can we do that safely?
Some
inspirational
quotes
“LXC is not yet secure.
If I want real security
I will use KVM.”
—Dan Berrangé
(famous LXC hacker)
This was in 2011.
The Linux Kernel has changed a tiny little bit since then.
“From security point
of view lxc is terrible and
may not be consider as
security solution.”
—someone on Reddit
(original spelling and grammar)
Common opinion among security experts and paranoid people.
To be fair, they have to play safe & can't take risks.
“Basically containers are
not functional as security
containers at present, in
that if you have root on
a container you have
root on the whole box.”
—Gentoo Wiki
That's just plain false, or misleading, and we'll see why.
“Containers do not
contain.”
—Dan Walsh
(Mr SELinux)
This was earlier this year,
and this guy knows what he's talking about.
Are we in trouble?
“For the fashion of Minas Tirith was
such that it was built on seven
levels, each delved into a hill,
and about each was set a wall,
and in each wall was a gate.”
—J.R.R. Tolkien
(also quoted in VAX/VMS Internals and Data Structures, ca. 1980)
Keyword:
levels
Let's review one of those quotes:
“If you have root on a container
you have root on the whole box.”
First things first:
just don't give root in the container
If you really have to give root,
give looks-like-root
If that's not enough, give root
but build another wall
Root in
the host
Root in the
container
Uruks
(intruders)
There are multiple threat models
 Regular applications
- web servers, databases, caches, message queues, ...
 System services (high level)
- logging, remote access, periodic command execution, ...
 System services (low level)
- manage physical devices, networking, filesystems, ...
 Kernel
- security policies, drivers, ...
 The special case of immutable infrastructure
Regular
applications
Regular applications
 Apache, MySQL, PostgreSQL, MongoDB,
Redis, Cassandra, Hadoop, RabbitMQ...
 Virtually all your programs in any language
(services/web services, workers, everything!)
 They never ever need root privileges
(except to install packages)
 Don't run them as root! Ever!
Regular applications
 Risk: they run arbitrary code
- vector: by definition, they are arbitrary code
- vector: security breach causes execution of malicious code
 Fix: nothing
- by definition, we are willing to execute arbitrary code here
 Consequence:
assume those apps can try
anything to break out
Regular applications
 Risk: escalate from non-root to root
- vector: vulnerabilities in SUID binaries
 Fix: defang SUID binaries
- remove them
- remove suid bit
- mount filesystem with nosuid
 Docker:
- you can remove SUID binaries easily
- doesn't support nosuid mount (but trivial to add)
Docker, Linux Containers, and Security: Does It Add Up?
Regular applications
 Risk: execute arbitrary kernel code
- vector: bogus syscall (e.g. vmsplice* in 2008)
 Fix: limit available syscalls
- seccomp-bpf = whitelist/blacklist syscalls
- Docker: seccomp available in LXC driver; not in libcontainer
 Fix: run stronger kernels
- GRSEC is a good idea (stable patches for 3.14 since July 4th)
- update often (i.e. have efficient way to roll out new kernels)
- Docker: more experiments needed
*More details about that: http://lwn.net/Articles/268783/
Regular applications
 Risk: leak to another container
- vector: bug in namespace code; filesystem leak
(like the one showed in the beginning of this talk!)
 Fix: user namespaces
- map UID in container to a different UID outside
- two containers run a process with UID 1000,
but it's 14298 and 15398 outside
- Docker: PR currently being reviewed
 Fix: security modules (e.g. SELinux)
- assign different security contexts to containers
- those mechanisms were designed to isolate!
- Docker: SELinux integration; AppArmor in the works
System services
(high level)
System services (high level)
 SSH, cron, syslog...
 You use/need them all the time
 Bad news: they typically run as root
 Good news: they don't really need root
 Bad news: it's hard to run them as non-root
 Good news: they are not arbitrary code
System services (high level)
 Risk: running arbitrary code as root
- vector: malformed data or similar
(note: risk is pretty low for syslog/cron; much higher for SSH)
 Fix: isolate sensitive services
- run SSH on bastion host, or in a VM
- note: this is not container-specific
(if someone hacks into your SSH server,
you'll have a bad time anyway)
System services (high level)
 Risk: messing with /dev
- vector: malicious code
 Fix: “devices” control group
- whitelist/blacklist devices
- fine-grained: can allow only read, write, none, or both
- fine-grained: can specify major+minor number of device
 Docker: ✓
- sensible defaults
- support for fine-grained access to devices in the works
System services (high level)
 Risk: use of root calls (mount, chmod, iptables...)
- vector: malicious code
 Fix: capabilities
- break down “root” into many permissions
- e.g. CAP_NET_ADMIN (network configuration)
- e.g. CAP_NET_RAW (generate and sniff traffic)
- e.g. CAP_SYS_ADMIN (big can of worms )☹
- see capabilities(7)
 Docker: ✓
- sensible default capabilities
- but: CAP_SYS_ADMIN! (see next slide)
Interlude: CAP_SYS_ADMIN
Operations controlled by CAP_SYS_ADMIN...
 quotactl, mount, umount, swapon, swapoff
 sethostname, setdomainname
 IPC_SET, IPC_RMID on arbitrary System V IPC
 perform operations on trusted and security
Extended Attributes
 set realtime priority
(ioprio_set + IOPRIO_CLASS_RT)
 create new namespaces
(clone and unshare + CLONE_NEWNS)
System services (high level)
 Risk: messing with /proc, /sys
- vector: malicious code
 Fix: prevent unauthorized access control
- Mandatory Access Control (AppArmor, SELinux)
- remount read-only, then drop CAP_SYS_ADMIN to prevent
remount
 Fix: wider implementation of namespaces
- some parts of procfs/sysfs are “namespace-aware”
- some aren't, but can be fixed (by writing kernel code)
 Docker: ✓
- locks down /proc and /sys
System services (high level)
 Risk: leaking with UID 0
- vector: malicious code
 Fix: user namespaces
- already mentioned earlier
- UID 0 in the container is mapped to some random UID outside
- you break out: you're not root
- you manage to issue weird syscalls: they're done as
unprivileged UID
 Docker: work in progress
 Caveat: user namespaces are still new.
We have to see how they behave with that!
System services
(low level)
System services (low level)
 Device management (keyboard, mouse,
screen), network and firewall config,
filesystem mounts...
 You use/need some of them all the time
 But you don't need any of them in containers
- physical device management is done by the host
- network configuration and filesystems are setup by the host
 Exceptions:
- custom mounts (FUSE)
- network appliances
System services (low level)
 Risk: running arbitrary code as root
- vector: malformed data or similar
 Fix: isolate sensitive functions
- “one-shot” commands can be fenced in privileged context
(think “sudo” but without even requiring “sudo”)
- everything else (especially processes that are long-running,
or handle arbitrary input) runs in non-privileged context
- works well for FUSE, some VPN services
 Docker: provides fine-grained sharing
- e.g. docker run --net container:… for network namespace
- nsenter for other out-of-band operations
System services (low level)
 Risk: run arbitrary code with full privileges
- vector: needs a process running with full privileges (rare!)
- vector: malformed data, unchecked input… classic exploit
 Fix: treat it as “kernel”
- we'll see that immediately in the next section
Kernel
Kernel
 Drivers
- can talk to the hardware, so can do pretty much anything
- except: virtualize the bus and use e.g. driver domains (Xen)
 Network stacks
- this probably has to live into the kernel for good performance
- except: DPDK, OpenOnload...
(networking stacks in userspace)
 Security policies
- by definition, they control everything else
- except: there might be nested security contexts some day
Kernel
 Risk: run arbitrary code with absolute
privileges
 Fix: ?
Reality check:
if you run something which by
definition needs full control over
hardware or kernel, containers
are not going to make it secure.
Please stop trying to shoot
yourself in the foot safely.
Reality check:
if you run something which by
definition needs full control over
hardware or kernel, containers
are not going to make it secure.
Please stop trying to shoot
yourself in the foot safely.
Kernel
 Risk:
run arbitrary code with absolute privileges
 Fix:
give it its own kernel and (virtual) hardware
- i.e. run it in a virtual machine
- that VM can run in a container
- that VM can hold a container
- run a privileged container, in Docker, in a VM,
while the VM runs in a container, in a Docker
https://github.com/jpetazzo/docker2docker
- inb4 xzibit meme
Docker, Linux Containers, and Security: Does It Add Up?
Immutable
immutable
infrastructure
Immutable immutable
infrastructure
 New rule:
the whole container is read-only
 Compromise:
if we must write, write to a noexec area
 Scalability has never been easier
(if totally read-only)
 It's even harder for malicious users
to do evil things
Recap (in no specific order!)
 don't run things as root
 drop capabilities
 enable user namespaces
 get rid of shady SUID binaries
 enable SELinux (or AppArmor)
 use seccomp-bpf
 get a GRSEC kernel
 update kernels often
 mount everything read-only
 ultimately, fence things in VMs
Recap (with Docker status)
 don't run things as root ☑ (you do it!)
 drop capabilities ☑ (but CAP_SYS_ADMIN!)
 enable user namespaces ☑ (work in progress)
 get rid of shady SUID binaries ☑ (but not enforced yet)
 enable SELinux (or AppArmor) ☑ (SELinux)
 use seccomp-bpf ☑ (on LXC driver)
 get a GRSEC kernel ☑ (to be confirmed)
 update kernels often ☑ (not Docker's job)
 mount everything read-only ☐ (not yet)
 ultimately, fence things in VMs ☑ (easy to do)
Recap (improvements needed)
 don't run things as root ☒ (you do it!)
 drop capabilities ☒ (but CAP_SYS_ADMIN!)
 enable user namespaces ☒ (work in progress)
 get rid of shady SUID binaries ☒ (but not enforced yet)
 enable SELinux (or AppArmor) ☒ (SELinux)
 use seccomp-bpf ☒ (on LXC driver)
 get a GRSEC kernel ☒ (to be confirmed)
 update kernels often ☒ (not Docker's job)
 mount everything read-only ☒ (not yet)
 ultimately, fence things in VMs ☒ (easy to do)
Docker, Linux Containers, and Security: Does It Add Up?
Thank you!
Questions?
1 von 58

Recomendados

Containers, Docker, and Security: State Of The Union (LinuxCon and ContainerC... von
Containers, Docker, and Security: State Of The Union (LinuxCon and ContainerC...Containers, Docker, and Security: State Of The Union (LinuxCon and ContainerC...
Containers, Docker, and Security: State Of The Union (LinuxCon and ContainerC...Jérôme Petazzoni
7.4K views38 Folien
Introduction to Docker, December 2014 "Tour de France" Bordeaux Special Edition von
Introduction to Docker, December 2014 "Tour de France" Bordeaux Special EditionIntroduction to Docker, December 2014 "Tour de France" Bordeaux Special Edition
Introduction to Docker, December 2014 "Tour de France" Bordeaux Special EditionJérôme Petazzoni
6.5K views117 Folien
Docker, Linux Containers (LXC), and security von
Docker, Linux Containers (LXC), and securityDocker, Linux Containers (LXC), and security
Docker, Linux Containers (LXC), and securityJérôme Petazzoni
51.7K views59 Folien
LXC, Docker, security: is it safe to run applications in Linux Containers? von
LXC, Docker, security: is it safe to run applications in Linux Containers?LXC, Docker, security: is it safe to run applications in Linux Containers?
LXC, Docker, security: is it safe to run applications in Linux Containers?Jérôme Petazzoni
22.7K views53 Folien
Introduction to Docker, December 2014 "Tour de France" Edition von
Introduction to Docker, December 2014 "Tour de France" EditionIntroduction to Docker, December 2014 "Tour de France" Edition
Introduction to Docker, December 2014 "Tour de France" EditionJérôme Petazzoni
3.8K views60 Folien
Docker: automation for the rest of us von
Docker: automation for the rest of usDocker: automation for the rest of us
Docker: automation for the rest of usJérôme Petazzoni
9.9K views61 Folien

Más contenido relacionado

Was ist angesagt?

Lxc – next gen virtualization for cloud intro (cloudexpo) von
Lxc – next gen virtualization for cloud   intro (cloudexpo)Lxc – next gen virtualization for cloud   intro (cloudexpo)
Lxc – next gen virtualization for cloud intro (cloudexpo)Boden Russell
19.8K views34 Folien
Cgroups, namespaces, and beyond: what are containers made from? (DockerCon Eu... von
Cgroups, namespaces, and beyond: what are containers made from? (DockerCon Eu...Cgroups, namespaces, and beyond: what are containers made from? (DockerCon Eu...
Cgroups, namespaces, and beyond: what are containers made from? (DockerCon Eu...Jérôme Petazzoni
20.4K views56 Folien
Linux Container Brief for IEEE WG P2302 von
Linux Container Brief for IEEE WG P2302Linux Container Brief for IEEE WG P2302
Linux Container Brief for IEEE WG P2302Boden Russell
3.6K views29 Folien
Evoluation of Linux Container Virtualization von
Evoluation of Linux Container VirtualizationEvoluation of Linux Container Virtualization
Evoluation of Linux Container VirtualizationImesh Gunaratne
4.2K views46 Folien
Containers: from development to production at DevNation 2015 von
Containers: from development to production at DevNation 2015Containers: from development to production at DevNation 2015
Containers: from development to production at DevNation 2015Jérôme Petazzoni
6.4K views47 Folien
The Docker ecosystem and the future of application deployment von
The Docker ecosystem and the future of application deploymentThe Docker ecosystem and the future of application deployment
The Docker ecosystem and the future of application deploymentJérôme Petazzoni
2.9K views110 Folien

Was ist angesagt?(20)

Lxc – next gen virtualization for cloud intro (cloudexpo) von Boden Russell
Lxc – next gen virtualization for cloud   intro (cloudexpo)Lxc – next gen virtualization for cloud   intro (cloudexpo)
Lxc – next gen virtualization for cloud intro (cloudexpo)
Boden Russell19.8K views
Cgroups, namespaces, and beyond: what are containers made from? (DockerCon Eu... von Jérôme Petazzoni
Cgroups, namespaces, and beyond: what are containers made from? (DockerCon Eu...Cgroups, namespaces, and beyond: what are containers made from? (DockerCon Eu...
Cgroups, namespaces, and beyond: what are containers made from? (DockerCon Eu...
Jérôme Petazzoni20.4K views
Linux Container Brief for IEEE WG P2302 von Boden Russell
Linux Container Brief for IEEE WG P2302Linux Container Brief for IEEE WG P2302
Linux Container Brief for IEEE WG P2302
Boden Russell3.6K views
Evoluation of Linux Container Virtualization von Imesh Gunaratne
Evoluation of Linux Container VirtualizationEvoluation of Linux Container Virtualization
Evoluation of Linux Container Virtualization
Imesh Gunaratne4.2K views
Containers: from development to production at DevNation 2015 von Jérôme Petazzoni
Containers: from development to production at DevNation 2015Containers: from development to production at DevNation 2015
Containers: from development to production at DevNation 2015
Jérôme Petazzoni6.4K views
The Docker ecosystem and the future of application deployment von Jérôme Petazzoni
The Docker ecosystem and the future of application deploymentThe Docker ecosystem and the future of application deployment
The Docker ecosystem and the future of application deployment
Jérôme Petazzoni2.9K views
LXC, Docker, and the future of software delivery | LinuxCon 2013 von dotCloud
LXC, Docker, and the future of software delivery | LinuxCon 2013LXC, Docker, and the future of software delivery | LinuxCon 2013
LXC, Docker, and the future of software delivery | LinuxCon 2013
dotCloud12.8K views
Docker storage drivers by Jérôme Petazzoni von Docker, Inc.
Docker storage drivers by Jérôme PetazzoniDocker storage drivers by Jérôme Petazzoni
Docker storage drivers by Jérôme Petazzoni
Docker, Inc.7.7K views
Tokyo OpenStack Summit 2015: Unraveling Docker Security von Phil Estes
Tokyo OpenStack Summit 2015: Unraveling Docker SecurityTokyo OpenStack Summit 2015: Unraveling Docker Security
Tokyo OpenStack Summit 2015: Unraveling Docker Security
Phil Estes1.6K views
Seven problems of Linux Containers von Kirill Kolyshkin
Seven problems of Linux ContainersSeven problems of Linux Containers
Seven problems of Linux Containers
Kirill Kolyshkin28.1K views
Linux containers – next gen virtualization for cloud (atl summit) ar4 3 - copy von Boden Russell
Linux containers – next gen virtualization for cloud (atl summit) ar4 3 - copyLinux containers – next gen virtualization for cloud (atl summit) ar4 3 - copy
Linux containers – next gen virtualization for cloud (atl summit) ar4 3 - copy
Boden Russell4K views
Containers, docker, and security: state of the union (Bay Area Infracoders Me... von Jérôme Petazzoni
Containers, docker, and security: state of the union (Bay Area Infracoders Me...Containers, docker, and security: state of the union (Bay Area Infracoders Me...
Containers, docker, and security: state of the union (Bay Area Infracoders Me...
Container Torture: Run any binary, in any container von Docker, Inc.
Container Torture: Run any binary, in any containerContainer Torture: Run any binary, in any container
Container Torture: Run any binary, in any container
Docker, Inc.5.1K views
Docker and kernel security von smart_bit
Docker and kernel securityDocker and kernel security
Docker and kernel security
smart_bit1.2K views
Microservices. Microservices everywhere! (At OSCON 2015) von Jérôme Petazzoni
Microservices. Microservices everywhere! (At OSCON 2015)Microservices. Microservices everywhere! (At OSCON 2015)
Microservices. Microservices everywhere! (At OSCON 2015)
Jérôme Petazzoni8.1K views
KVM and docker LXC Benchmarking with OpenStack von Boden Russell
KVM and docker LXC Benchmarking with OpenStackKVM and docker LXC Benchmarking with OpenStack
KVM and docker LXC Benchmarking with OpenStack
Boden Russell131.8K views
Containerization is more than the new Virtualization: enabling separation of ... von Jérôme Petazzoni
Containerization is more than the new Virtualization: enabling separation of ...Containerization is more than the new Virtualization: enabling separation of ...
Containerization is more than the new Virtualization: enabling separation of ...
Docker: the road ahead von shykes
Docker: the road aheadDocker: the road ahead
Docker: the road ahead
shykes46.4K views

Destacado

The How and Why of Container Vulnerability Management von
The How and Why of Container Vulnerability ManagementThe How and Why of Container Vulnerability Management
The How and Why of Container Vulnerability ManagementBlack Duck by Synopsys
1.1K views30 Folien
Basic principles of Git von
Basic principles of GitBasic principles of Git
Basic principles of Gitphuongvohuy
4.1K views26 Folien
Contain your risk: Deploy secure containers with trust and confidence von
Contain your risk: Deploy secure containers with trust and confidenceContain your risk: Deploy secure containers with trust and confidence
Contain your risk: Deploy secure containers with trust and confidenceBlack Duck by Synopsys
1K views36 Folien
Rootkit von
RootkitRootkit
RootkitAlex Avila
919 views6 Folien
Applying Memory Forensics to Rootkit Detection von
Applying Memory Forensics to Rootkit DetectionApplying Memory Forensics to Rootkit Detection
Applying Memory Forensics to Rootkit DetectionIgor Korkin
6.6K views78 Folien
Amazon Web Services and Docker von
Amazon Web Services and DockerAmazon Web Services and Docker
Amazon Web Services and DockerPaolo latella
3.7K views17 Folien

Destacado(20)

Basic principles of Git von phuongvohuy
Basic principles of GitBasic principles of Git
Basic principles of Git
phuongvohuy4.1K views
Contain your risk: Deploy secure containers with trust and confidence von Black Duck by Synopsys
Contain your risk: Deploy secure containers with trust and confidenceContain your risk: Deploy secure containers with trust and confidence
Contain your risk: Deploy secure containers with trust and confidence
Applying Memory Forensics to Rootkit Detection von Igor Korkin
Applying Memory Forensics to Rootkit DetectionApplying Memory Forensics to Rootkit Detection
Applying Memory Forensics to Rootkit Detection
Igor Korkin6.6K views
Amazon Web Services and Docker von Paolo latella
Amazon Web Services and DockerAmazon Web Services and Docker
Amazon Web Services and Docker
Paolo latella3.7K views
[Impact Lab] IT инструменты для проекта von Dmitry Spodarets
[Impact Lab] IT инструменты для проекта[Impact Lab] IT инструменты для проекта
[Impact Lab] IT инструменты для проекта
Dmitry Spodarets3.4K views
Performance comparison between Linux Containers and Virtual Machines von Soheila Dehghanzadeh
Performance comparison between Linux Containers and Virtual MachinesPerformance comparison between Linux Containers and Virtual Machines
Performance comparison between Linux Containers and Virtual Machines
Nagios Conference 2014 - Spenser Reinhardt - Detecting Security Breaches With... von Nagios
Nagios Conference 2014 - Spenser Reinhardt - Detecting Security Breaches With...Nagios Conference 2014 - Spenser Reinhardt - Detecting Security Breaches With...
Nagios Conference 2014 - Spenser Reinhardt - Detecting Security Breaches With...
Nagios1.9K views
[Defcon] Hardware backdooring is practical von Moabi.com
[Defcon] Hardware backdooring is practical[Defcon] Hardware backdooring is practical
[Defcon] Hardware backdooring is practical
Moabi.com130.2K views
10 reasons to be excited about go von Dvir Volk
10 reasons to be excited about go10 reasons to be excited about go
10 reasons to be excited about go
Dvir Volk11.2K views
Detecting hardware virtualization rootkits von Edgar Barbosa
Detecting hardware virtualization rootkitsDetecting hardware virtualization rootkits
Detecting hardware virtualization rootkits
Edgar Barbosa2.4K views
Docker Security Paradigm von Anis LARGUEM
Docker Security ParadigmDocker Security Paradigm
Docker Security Paradigm
Anis LARGUEM528 views
Attacks on tacacs - Алексей Тюрин von DefconRussia
Attacks on tacacs - Алексей ТюринAttacks on tacacs - Алексей Тюрин
Attacks on tacacs - Алексей Тюрин
DefconRussia1.4K views
Defeating x64: Modern Trends of Kernel-Mode Rootkits von Alex Matrosov
Defeating x64: Modern Trends of Kernel-Mode RootkitsDefeating x64: Modern Trends of Kernel-Mode Rootkits
Defeating x64: Modern Trends of Kernel-Mode Rootkits
Alex Matrosov4.3K views
Zn task - defcon russia 20 von DefconRussia
Zn task  - defcon russia 20Zn task  - defcon russia 20
Zn task - defcon russia 20
DefconRussia829 views

Similar a Docker, Linux Containers, and Security: Does It Add Up?

Lightweight Virtualization in Linux von
Lightweight Virtualization in LinuxLightweight Virtualization in Linux
Lightweight Virtualization in LinuxSadegh Dorri N.
567 views60 Folien
Docker London: Container Security von
Docker London: Container SecurityDocker London: Container Security
Docker London: Container SecurityPhil Estes
16.9K views21 Folien
How Secure Is Your Container? ContainerCon Berlin 2016 von
How Secure Is Your Container? ContainerCon Berlin 2016How Secure Is Your Container? ContainerCon Berlin 2016
How Secure Is Your Container? ContainerCon Berlin 2016Phil Estes
5.6K views21 Folien
Docker Security von
Docker SecurityDocker Security
Docker SecurityBladE0341
659 views22 Folien
Unix Security von
Unix SecurityUnix Security
Unix Securityreplay21
6.3K views47 Folien
Containers and workload security an overview von
Containers and workload security an overview Containers and workload security an overview
Containers and workload security an overview Krishna-Kumar
10.4K views29 Folien

Similar a Docker, Linux Containers, and Security: Does It Add Up?(20)

Lightweight Virtualization in Linux von Sadegh Dorri N.
Lightweight Virtualization in LinuxLightweight Virtualization in Linux
Lightweight Virtualization in Linux
Sadegh Dorri N.567 views
Docker London: Container Security von Phil Estes
Docker London: Container SecurityDocker London: Container Security
Docker London: Container Security
Phil Estes16.9K views
How Secure Is Your Container? ContainerCon Berlin 2016 von Phil Estes
How Secure Is Your Container? ContainerCon Berlin 2016How Secure Is Your Container? ContainerCon Berlin 2016
How Secure Is Your Container? ContainerCon Berlin 2016
Phil Estes5.6K views
Docker Security von BladE0341
Docker SecurityDocker Security
Docker Security
BladE0341659 views
Unix Security von replay21
Unix SecurityUnix Security
Unix Security
replay216.3K views
Containers and workload security an overview von Krishna-Kumar
Containers and workload security an overview Containers and workload security an overview
Containers and workload security an overview
Krishna-Kumar 10.4K views
Docker security: Rolling out Trust in your container von Ronak Kogta
Docker security: Rolling out Trust in your containerDocker security: Rolling out Trust in your container
Docker security: Rolling out Trust in your container
Ronak Kogta725 views
Rootless Containers von Akihiro Suda
Rootless ContainersRootless Containers
Rootless Containers
Akihiro Suda23.1K views
Introduction to docker security von Walid Ashraf
Introduction to docker securityIntroduction to docker security
Introduction to docker security
Walid Ashraf135 views
Secure container: Kata container and gVisor von Ching-Hsuan Yen
Secure container: Kata container and gVisorSecure container: Kata container and gVisor
Secure container: Kata container and gVisor
Ching-Hsuan Yen395 views
Unraveling Docker Security: Lessons From a Production Cloud von Salman Baset
Unraveling Docker Security: Lessons From a Production CloudUnraveling Docker Security: Lessons From a Production Cloud
Unraveling Docker Security: Lessons From a Production Cloud
Salman Baset457 views
Agile Brown Bag - Vagrant & Docker: Introduction von Agile Partner S.A.
Agile Brown Bag - Vagrant & Docker: IntroductionAgile Brown Bag - Vagrant & Docker: Introduction
Agile Brown Bag - Vagrant & Docker: Introduction
Agile Partner S.A.1.2K views
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic... von Codemotion
Why everyone is excited about Docker (and you should too...) -  Carlo Bonamic...Why everyone is excited about Docker (and you should too...) -  Carlo Bonamic...
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
Codemotion765 views
Container Security: How We Got Here and Where We're Going von Phil Estes
Container Security: How We Got Here and Where We're GoingContainer Security: How We Got Here and Where We're Going
Container Security: How We Got Here and Where We're Going
Phil Estes398 views
Docker en kernel security von smart_bit
Docker en kernel securityDocker en kernel security
Docker en kernel security
smart_bit1.2K views
Hands on introduction to docker security for docker newbies von Yigal Elefant
Hands on introduction to docker security for docker newbiesHands on introduction to docker security for docker newbies
Hands on introduction to docker security for docker newbies
Yigal Elefant137 views

Más de Jérôme Petazzoni

Use the Source or Join the Dark Side: differences between Docker Community an... von
Use the Source or Join the Dark Side: differences between Docker Community an...Use the Source or Join the Dark Side: differences between Docker Community an...
Use the Source or Join the Dark Side: differences between Docker Community an...Jérôme Petazzoni
3.1K views38 Folien
Docker : quels enjeux pour le stockage et réseau ? Paris Open Source Summit ... von
Docker : quels enjeux pour le stockage et réseau ? Paris Open Source Summit ...Docker : quels enjeux pour le stockage et réseau ? Paris Open Source Summit ...
Docker : quels enjeux pour le stockage et réseau ? Paris Open Source Summit ...Jérôme Petazzoni
5.2K views46 Folien
Making DevOps Secure with Docker on Solaris (Oracle Open World, with Jesse Bu... von
Making DevOps Secure with Docker on Solaris (Oracle Open World, with Jesse Bu...Making DevOps Secure with Docker on Solaris (Oracle Open World, with Jesse Bu...
Making DevOps Secure with Docker on Solaris (Oracle Open World, with Jesse Bu...Jérôme Petazzoni
10.9K views49 Folien
From development environments to production deployments with Docker, Compose,... von
From development environments to production deployments with Docker, Compose,...From development environments to production deployments with Docker, Compose,...
From development environments to production deployments with Docker, Compose,...Jérôme Petazzoni
33K views122 Folien
How to contribute to large open source projects like Docker (LinuxCon 2015) von
How to contribute to large open source projects like Docker (LinuxCon 2015)How to contribute to large open source projects like Docker (LinuxCon 2015)
How to contribute to large open source projects like Docker (LinuxCon 2015)Jérôme Petazzoni
8.9K views57 Folien
Immutable infrastructure with Docker and containers (GlueCon 2015) von
Immutable infrastructure with Docker and containers (GlueCon 2015)Immutable infrastructure with Docker and containers (GlueCon 2015)
Immutable infrastructure with Docker and containers (GlueCon 2015)Jérôme Petazzoni
20.2K views59 Folien

Más de Jérôme Petazzoni(16)

Use the Source or Join the Dark Side: differences between Docker Community an... von Jérôme Petazzoni
Use the Source or Join the Dark Side: differences between Docker Community an...Use the Source or Join the Dark Side: differences between Docker Community an...
Use the Source or Join the Dark Side: differences between Docker Community an...
Jérôme Petazzoni3.1K views
Docker : quels enjeux pour le stockage et réseau ? Paris Open Source Summit ... von Jérôme Petazzoni
Docker : quels enjeux pour le stockage et réseau ? Paris Open Source Summit ...Docker : quels enjeux pour le stockage et réseau ? Paris Open Source Summit ...
Docker : quels enjeux pour le stockage et réseau ? Paris Open Source Summit ...
Jérôme Petazzoni5.2K views
Making DevOps Secure with Docker on Solaris (Oracle Open World, with Jesse Bu... von Jérôme Petazzoni
Making DevOps Secure with Docker on Solaris (Oracle Open World, with Jesse Bu...Making DevOps Secure with Docker on Solaris (Oracle Open World, with Jesse Bu...
Making DevOps Secure with Docker on Solaris (Oracle Open World, with Jesse Bu...
Jérôme Petazzoni10.9K views
From development environments to production deployments with Docker, Compose,... von Jérôme Petazzoni
From development environments to production deployments with Docker, Compose,...From development environments to production deployments with Docker, Compose,...
From development environments to production deployments with Docker, Compose,...
Jérôme Petazzoni33K views
How to contribute to large open source projects like Docker (LinuxCon 2015) von Jérôme Petazzoni
How to contribute to large open source projects like Docker (LinuxCon 2015)How to contribute to large open source projects like Docker (LinuxCon 2015)
How to contribute to large open source projects like Docker (LinuxCon 2015)
Jérôme Petazzoni8.9K views
Immutable infrastructure with Docker and containers (GlueCon 2015) von Jérôme Petazzoni
Immutable infrastructure with Docker and containers (GlueCon 2015)Immutable infrastructure with Docker and containers (GlueCon 2015)
Immutable infrastructure with Docker and containers (GlueCon 2015)
Jérôme Petazzoni20.2K views
Containers, Docker, and Microservices: the Terrific Trio von Jérôme Petazzoni
Containers, Docker, and Microservices: the Terrific TrioContainers, Docker, and Microservices: the Terrific Trio
Containers, Docker, and Microservices: the Terrific Trio
Jérôme Petazzoni17.7K views
Pipework: Software-Defined Network for Containers and Docker von Jérôme Petazzoni
Pipework: Software-Defined Network for Containers and DockerPipework: Software-Defined Network for Containers and Docker
Pipework: Software-Defined Network for Containers and Docker
Jérôme Petazzoni9.1K views
Docker Tips And Tricks at the Docker Beijing Meetup von Jérôme Petazzoni
Docker Tips And Tricks at the Docker Beijing MeetupDocker Tips And Tricks at the Docker Beijing Meetup
Docker Tips And Tricks at the Docker Beijing Meetup
Jérôme Petazzoni34.4K views
Introduction to Docker at Glidewell Laboratories in Orange County von Jérôme Petazzoni
Introduction to Docker at Glidewell Laboratories in Orange CountyIntroduction to Docker at Glidewell Laboratories in Orange County
Introduction to Docker at Glidewell Laboratories in Orange County
Jérôme Petazzoni2.1K views
Introduction to Docker at the Azure Meet-up in New York von Jérôme Petazzoni
Introduction to Docker at the Azure Meet-up in New YorkIntroduction to Docker at the Azure Meet-up in New York
Introduction to Docker at the Azure Meet-up in New York
Jérôme Petazzoni3.9K views
Introduction to Docker and deployment and Azure von Jérôme Petazzoni
Introduction to Docker and deployment and AzureIntroduction to Docker and deployment and Azure
Introduction to Docker and deployment and Azure
Jérôme Petazzoni2.1K views
Docker 1 0 1 0 1: a Docker introduction, actualized for the stable release of... von Jérôme Petazzoni
Docker 1 0 1 0 1: a Docker introduction, actualized for the stable release of...Docker 1 0 1 0 1: a Docker introduction, actualized for the stable release of...
Docker 1 0 1 0 1: a Docker introduction, actualized for the stable release of...
Jérôme Petazzoni5.3K views

Último

Scaling Knowledge Graph Architectures with AI von
Scaling Knowledge Graph Architectures with AIScaling Knowledge Graph Architectures with AI
Scaling Knowledge Graph Architectures with AIEnterprise Knowledge
30 views15 Folien
SAP Automation Using Bar Code and FIORI.pdf von
SAP Automation Using Bar Code and FIORI.pdfSAP Automation Using Bar Code and FIORI.pdf
SAP Automation Using Bar Code and FIORI.pdfVirendra Rai, PMP
23 views38 Folien
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院 von
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院IttrainingIttraining
52 views8 Folien
Five Things You SHOULD Know About Postman von
Five Things You SHOULD Know About PostmanFive Things You SHOULD Know About Postman
Five Things You SHOULD Know About PostmanPostman
33 views43 Folien
Piloting & Scaling Successfully With Microsoft Viva von
Piloting & Scaling Successfully With Microsoft VivaPiloting & Scaling Successfully With Microsoft Viva
Piloting & Scaling Successfully With Microsoft VivaRichard Harbridge
12 views160 Folien
Evolving the Network Automation Journey from Python to Platforms von
Evolving the Network Automation Journey from Python to PlatformsEvolving the Network Automation Journey from Python to Platforms
Evolving the Network Automation Journey from Python to PlatformsNetwork Automation Forum
13 views21 Folien

Último(20)

【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院 von IttrainingIttraining
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院
Five Things You SHOULD Know About Postman von Postman
Five Things You SHOULD Know About PostmanFive Things You SHOULD Know About Postman
Five Things You SHOULD Know About Postman
Postman33 views
Piloting & Scaling Successfully With Microsoft Viva von Richard Harbridge
Piloting & Scaling Successfully With Microsoft VivaPiloting & Scaling Successfully With Microsoft Viva
Piloting & Scaling Successfully With Microsoft Viva
Case Study Copenhagen Energy and Business Central.pdf von Aitana
Case Study Copenhagen Energy and Business Central.pdfCase Study Copenhagen Energy and Business Central.pdf
Case Study Copenhagen Energy and Business Central.pdf
Aitana16 views
Serverless computing with Google Cloud (2023-24) von wesley chun
Serverless computing with Google Cloud (2023-24)Serverless computing with Google Cloud (2023-24)
Serverless computing with Google Cloud (2023-24)
wesley chun11 views
Igniting Next Level Productivity with AI-Infused Data Integration Workflows von Safe Software
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Safe Software263 views
Future of AR - Facebook Presentation von ssuserb54b561
Future of AR - Facebook PresentationFuture of AR - Facebook Presentation
Future of AR - Facebook Presentation
ssuserb54b56114 views
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f... von TrustArc
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc10 views
6g - REPORT.pdf von Liveplex
6g - REPORT.pdf6g - REPORT.pdf
6g - REPORT.pdf
Liveplex10 views
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive von Network Automation Forum
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveAutomating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive
HTTP headers that make your website go faster - devs.gent November 2023 von Thijs Feryn
HTTP headers that make your website go faster - devs.gent November 2023HTTP headers that make your website go faster - devs.gent November 2023
HTTP headers that make your website go faster - devs.gent November 2023
Thijs Feryn22 views
Data Integrity for Banking and Financial Services von Precisely
Data Integrity for Banking and Financial ServicesData Integrity for Banking and Financial Services
Data Integrity for Banking and Financial Services
Precisely21 views
Business Analyst Series 2023 - Week 3 Session 5 von DianaGray10
Business Analyst Series 2023 -  Week 3 Session 5Business Analyst Series 2023 -  Week 3 Session 5
Business Analyst Series 2023 - Week 3 Session 5
DianaGray10248 views

Docker, Linux Containers, and Security: Does It Add Up?

  • 1. Docker, Linux Containers, Security: Does it add up? Jérôme Petazzoni @jpetazzo Docker Inc. @docker
  • 2. Question: Is it safe to run applications in Linux Containers?
  • 3. ...
  • 4. Yes
  • 5. /* shocker: docker PoC VMM-container breakout (C) 2014 Sebastian Krahmer * * Demonstrates that any given docker image someone is asking * you to run in your docker setup can access ANY file on your host, * e.g. dumping hosts /etc/shadow or other sensitive info, compromising * security of the host and any other docker VM's on it. * * docker using container based VMM: Sebarate pid and net namespace, * stripped caps and RO bind mounts into container's /. However * as its only a bind-mount the fs struct from the task is shared * with the host which allows to open files by file handles * (open_by_handle_at()). As we thankfully have dac_override and * dac_read_search we can do this. The handle is usually a 64bit * string with 32bit inodenumber inside (tested with ext4). * Inode of / is always 2, so we have a starting point to walk * the FS path and brute force the remaining 32bit until we find the * desired file (It's probably easier, depending on the fhandle export * function used for the FS in question: it could be a parent inode# or * the inode generation which can be obtained via an ioctl). * [In practise the remaining 32bit are all 0 :] * * tested with docker 0.11 busybox demo image on a 3.11 kernel: * * docker run -i busybox sh * * seems to run any program inside VMM with UID 0 (some caps stripped);
  • 7. No!
  • 8. Docker has changed its security status to It's complicated
  • 9. Who am I? Why am I here?  Jérôme Petazzoni (@jpetazzo) - Grumpy French Linux DevOps  Operated dotCloud PAAS for 3+ years - hosts arbitrary code for arbitrary users - all services, all apps, run in containers - no major security issue yet (fingers crossed)  Containerize all the things! - VPN-in-Docker, KVM-in-Docker, Xorg-in-Docker, Docker-in-Docker...
  • 10. What are those “containers” ? (1/3)  Technically: ~chroot on steroids - a container is a set of processes (running on top of common kernel) - isolated* from the rest of the machine (cannot see/affect/harm host or other containers) - using namespaces to have private view of the system (network interfaces, PID tree, mountpoints...) - and cgroups to have metered/limited/reserved resources (to mitigate “bad neighbor” effect) *Limitations may apply.
  • 11. What are those “containers” ? (2/3)  From a distance: looks like a VM - I can SSH into my container - I can have root access in it - I can install packages in it - I have my own eth0 interface - I can tweak routing table, iptables rules - I can mount filesystems - etc.
  • 12. What are those “containers” ? (3/3)  Lightweight, fast, disposable... virtual environments - boot in milliseconds - just a few MB of intrinsic disk/memory usage - bare metal performance is possible  The new way to build, ship, deploy, run your apps!
  • 13. Why is this a hot topic?  Containers: have been around for decades  LXC (Linux Containers): have been around for years So, what?
  • 15. Why is this a hot topic?  Containers: have been around for decades  LXC (Linux Containers): have been around for years  Tools like Docker have commoditized LXC (i.e. made it very easy to use)  Everybody wants to deploy containers now  But, oops, LXC wasn't made for security  We want containers, and we want them now; how can we do that safely?
  • 17. “LXC is not yet secure. If I want real security I will use KVM.” —Dan Berrangé (famous LXC hacker) This was in 2011. The Linux Kernel has changed a tiny little bit since then.
  • 18. “From security point of view lxc is terrible and may not be consider as security solution.” —someone on Reddit (original spelling and grammar) Common opinion among security experts and paranoid people. To be fair, they have to play safe & can't take risks.
  • 19. “Basically containers are not functional as security containers at present, in that if you have root on a container you have root on the whole box.” —Gentoo Wiki That's just plain false, or misleading, and we'll see why.
  • 20. “Containers do not contain.” —Dan Walsh (Mr SELinux) This was earlier this year, and this guy knows what he's talking about. Are we in trouble?
  • 21. “For the fashion of Minas Tirith was such that it was built on seven levels, each delved into a hill, and about each was set a wall, and in each wall was a gate.” —J.R.R. Tolkien (also quoted in VAX/VMS Internals and Data Structures, ca. 1980)
  • 23. Let's review one of those quotes: “If you have root on a container you have root on the whole box.” First things first: just don't give root in the container If you really have to give root, give looks-like-root If that's not enough, give root but build another wall
  • 24. Root in the host Root in the container Uruks (intruders)
  • 25. There are multiple threat models  Regular applications - web servers, databases, caches, message queues, ...  System services (high level) - logging, remote access, periodic command execution, ...  System services (low level) - manage physical devices, networking, filesystems, ...  Kernel - security policies, drivers, ...  The special case of immutable infrastructure
  • 27. Regular applications  Apache, MySQL, PostgreSQL, MongoDB, Redis, Cassandra, Hadoop, RabbitMQ...  Virtually all your programs in any language (services/web services, workers, everything!)  They never ever need root privileges (except to install packages)  Don't run them as root! Ever!
  • 28. Regular applications  Risk: they run arbitrary code - vector: by definition, they are arbitrary code - vector: security breach causes execution of malicious code  Fix: nothing - by definition, we are willing to execute arbitrary code here  Consequence: assume those apps can try anything to break out
  • 29. Regular applications  Risk: escalate from non-root to root - vector: vulnerabilities in SUID binaries  Fix: defang SUID binaries - remove them - remove suid bit - mount filesystem with nosuid  Docker: - you can remove SUID binaries easily - doesn't support nosuid mount (but trivial to add)
  • 31. Regular applications  Risk: execute arbitrary kernel code - vector: bogus syscall (e.g. vmsplice* in 2008)  Fix: limit available syscalls - seccomp-bpf = whitelist/blacklist syscalls - Docker: seccomp available in LXC driver; not in libcontainer  Fix: run stronger kernels - GRSEC is a good idea (stable patches for 3.14 since July 4th) - update often (i.e. have efficient way to roll out new kernels) - Docker: more experiments needed *More details about that: http://lwn.net/Articles/268783/
  • 32. Regular applications  Risk: leak to another container - vector: bug in namespace code; filesystem leak (like the one showed in the beginning of this talk!)  Fix: user namespaces - map UID in container to a different UID outside - two containers run a process with UID 1000, but it's 14298 and 15398 outside - Docker: PR currently being reviewed  Fix: security modules (e.g. SELinux) - assign different security contexts to containers - those mechanisms were designed to isolate! - Docker: SELinux integration; AppArmor in the works
  • 34. System services (high level)  SSH, cron, syslog...  You use/need them all the time  Bad news: they typically run as root  Good news: they don't really need root  Bad news: it's hard to run them as non-root  Good news: they are not arbitrary code
  • 35. System services (high level)  Risk: running arbitrary code as root - vector: malformed data or similar (note: risk is pretty low for syslog/cron; much higher for SSH)  Fix: isolate sensitive services - run SSH on bastion host, or in a VM - note: this is not container-specific (if someone hacks into your SSH server, you'll have a bad time anyway)
  • 36. System services (high level)  Risk: messing with /dev - vector: malicious code  Fix: “devices” control group - whitelist/blacklist devices - fine-grained: can allow only read, write, none, or both - fine-grained: can specify major+minor number of device  Docker: ✓ - sensible defaults - support for fine-grained access to devices in the works
  • 37. System services (high level)  Risk: use of root calls (mount, chmod, iptables...) - vector: malicious code  Fix: capabilities - break down “root” into many permissions - e.g. CAP_NET_ADMIN (network configuration) - e.g. CAP_NET_RAW (generate and sniff traffic) - e.g. CAP_SYS_ADMIN (big can of worms )☹ - see capabilities(7)  Docker: ✓ - sensible default capabilities - but: CAP_SYS_ADMIN! (see next slide)
  • 38. Interlude: CAP_SYS_ADMIN Operations controlled by CAP_SYS_ADMIN...  quotactl, mount, umount, swapon, swapoff  sethostname, setdomainname  IPC_SET, IPC_RMID on arbitrary System V IPC  perform operations on trusted and security Extended Attributes  set realtime priority (ioprio_set + IOPRIO_CLASS_RT)  create new namespaces (clone and unshare + CLONE_NEWNS)
  • 39. System services (high level)  Risk: messing with /proc, /sys - vector: malicious code  Fix: prevent unauthorized access control - Mandatory Access Control (AppArmor, SELinux) - remount read-only, then drop CAP_SYS_ADMIN to prevent remount  Fix: wider implementation of namespaces - some parts of procfs/sysfs are “namespace-aware” - some aren't, but can be fixed (by writing kernel code)  Docker: ✓ - locks down /proc and /sys
  • 40. System services (high level)  Risk: leaking with UID 0 - vector: malicious code  Fix: user namespaces - already mentioned earlier - UID 0 in the container is mapped to some random UID outside - you break out: you're not root - you manage to issue weird syscalls: they're done as unprivileged UID  Docker: work in progress  Caveat: user namespaces are still new. We have to see how they behave with that!
  • 42. System services (low level)  Device management (keyboard, mouse, screen), network and firewall config, filesystem mounts...  You use/need some of them all the time  But you don't need any of them in containers - physical device management is done by the host - network configuration and filesystems are setup by the host  Exceptions: - custom mounts (FUSE) - network appliances
  • 43. System services (low level)  Risk: running arbitrary code as root - vector: malformed data or similar  Fix: isolate sensitive functions - “one-shot” commands can be fenced in privileged context (think “sudo” but without even requiring “sudo”) - everything else (especially processes that are long-running, or handle arbitrary input) runs in non-privileged context - works well for FUSE, some VPN services  Docker: provides fine-grained sharing - e.g. docker run --net container:… for network namespace - nsenter for other out-of-band operations
  • 44. System services (low level)  Risk: run arbitrary code with full privileges - vector: needs a process running with full privileges (rare!) - vector: malformed data, unchecked input… classic exploit  Fix: treat it as “kernel” - we'll see that immediately in the next section
  • 46. Kernel  Drivers - can talk to the hardware, so can do pretty much anything - except: virtualize the bus and use e.g. driver domains (Xen)  Network stacks - this probably has to live into the kernel for good performance - except: DPDK, OpenOnload... (networking stacks in userspace)  Security policies - by definition, they control everything else - except: there might be nested security contexts some day
  • 47. Kernel  Risk: run arbitrary code with absolute privileges  Fix: ?
  • 48. Reality check: if you run something which by definition needs full control over hardware or kernel, containers are not going to make it secure. Please stop trying to shoot yourself in the foot safely.
  • 49. Reality check: if you run something which by definition needs full control over hardware or kernel, containers are not going to make it secure. Please stop trying to shoot yourself in the foot safely.
  • 50. Kernel  Risk: run arbitrary code with absolute privileges  Fix: give it its own kernel and (virtual) hardware - i.e. run it in a virtual machine - that VM can run in a container - that VM can hold a container - run a privileged container, in Docker, in a VM, while the VM runs in a container, in a Docker https://github.com/jpetazzo/docker2docker - inb4 xzibit meme
  • 53. Immutable immutable infrastructure  New rule: the whole container is read-only  Compromise: if we must write, write to a noexec area  Scalability has never been easier (if totally read-only)  It's even harder for malicious users to do evil things
  • 54. Recap (in no specific order!)  don't run things as root  drop capabilities  enable user namespaces  get rid of shady SUID binaries  enable SELinux (or AppArmor)  use seccomp-bpf  get a GRSEC kernel  update kernels often  mount everything read-only  ultimately, fence things in VMs
  • 55. Recap (with Docker status)  don't run things as root ☑ (you do it!)  drop capabilities ☑ (but CAP_SYS_ADMIN!)  enable user namespaces ☑ (work in progress)  get rid of shady SUID binaries ☑ (but not enforced yet)  enable SELinux (or AppArmor) ☑ (SELinux)  use seccomp-bpf ☑ (on LXC driver)  get a GRSEC kernel ☑ (to be confirmed)  update kernels often ☑ (not Docker's job)  mount everything read-only ☐ (not yet)  ultimately, fence things in VMs ☑ (easy to do)
  • 56. Recap (improvements needed)  don't run things as root ☒ (you do it!)  drop capabilities ☒ (but CAP_SYS_ADMIN!)  enable user namespaces ☒ (work in progress)  get rid of shady SUID binaries ☒ (but not enforced yet)  enable SELinux (or AppArmor) ☒ (SELinux)  use seccomp-bpf ☒ (on LXC driver)  get a GRSEC kernel ☒ (to be confirmed)  update kernels often ☒ (not Docker's job)  mount everything read-only ☒ (not yet)  ultimately, fence things in VMs ☒ (easy to do)