Browse code

Fixed #6545 - Updated Security article

Docker-DCO-1.1-Signed-off-by: James Turnbull <james@lovedthanlost.net> (github: jamtur01)

James Turnbull authored on 2014/06/20 02:07:39
Showing 1 changed files
... ...
@@ -17,15 +17,10 @@ There are three major areas to consider when reviewing Docker security:
17 17
 
18 18
 ## Kernel Namespaces
19 19
 
20
-Docker containers are essentially LXC containers, and they come with the
21
-same security features. When you start a container with
22
-`docker run`, behind the scenes Docker uses
23
-`lxc-start` to execute the Docker container. This
24
-creates a set of namespaces and control groups for the container. Those
25
-namespaces and control groups are not created by Docker itself, but by
26
-`lxc-start`. This means that as the LXC userland
27
-tools evolve (and provide additional namespaces and isolation features),
28
-Docker will automatically make use of them.
20
+Docker containers are very similar to LXC containers, and they come with
21
+the similar security features. When you start a container with `docker
22
+run`, behind the scenes Docker creates a set of namespaces and control
23
+groups for the container.
29 24
 
30 25
 **Namespaces provide the first and most straightforward form of
31 26
 isolation**: processes running within a container cannot see, and even
... ...
@@ -55,10 +50,9 @@ ago), namespace code has been exercised and scrutinized on a large
55 55
 number of production systems. And there is more: the design and
56 56
 inspiration for the namespaces code are even older. Namespaces are
57 57
 actually an effort to reimplement the features of [OpenVZ](
58
-http://en.wikipedia.org/wiki/OpenVZ) in such a way that they
59
-could be merged within the mainstream kernel. And OpenVZ was initially
60
-released in 2005, so both the design and the implementation are pretty
61
-mature.
58
+http://en.wikipedia.org/wiki/OpenVZ) in such a way that they could be
59
+merged within the mainstream kernel. And OpenVZ was initially released
60
+in 2005, so both the design and the implementation are pretty mature.
62 61
 
63 62
 ## Control Groups
64 63
 
... ...
@@ -82,7 +76,7 @@ started in 2006, and initially merged in kernel 2.6.24.
82 82
 ## Docker Daemon Attack Surface
83 83
 
84 84
 Running containers (and applications) with Docker implies running the
85
-Docker daemon. This daemon currently requires root privileges, and you
85
+Docker daemon. This daemon currently requires `root` privileges, and you
86 86
 should therefore be aware of some important details.
87 87
 
88 88
 First of all, **only trusted users should be allowed to control your
... ...
@@ -114,8 +108,9 @@ socket.
114 114
 You can also expose the REST API over HTTP if you explicitly decide so.
115 115
 However, if you do that, being aware of the above mentioned security
116 116
 implication, you should ensure that it will be reachable only from a
117
-trusted network or VPN; or protected with e.g. `stunnel`
118
-and client SSL certificates.
117
+trusted network or VPN; or protected with e.g. `stunnel` and client SSL
118
+certificates. You can also secure them with [HTTPS and
119
+certificates](/articles/https/).
119 120
 
120 121
 Recent improvements in Linux namespaces will soon allow to run
121 122
 full-featured containers without root privileges, thanks to the new user
... ...
@@ -199,15 +194,18 @@ container, it will be much harder to do serious damage, or to escalate
199 199
 to the host.
200 200
 
201 201
 This won't affect regular web apps; but malicious users will find that
202
-the arsenal at their disposal has shrunk considerably! You can see [the
203
-list of dropped capabilities in the Docker
204
-code](https://github.com/dotcloud/docker/blob/v0.5.0/lxc_template.go#L97),
205
-and a full list of available capabilities in [Linux
202
+the arsenal at their disposal has shrunk considerably! By default Docker
203
+drops all capabilities except [those
204
+needed](https://github.com/dotcloud/docker/blob/master/daemon/execdriver/native/template/default_template.go),
205
+a whitelist instead of a blacklist approach. You can see a full list of
206
+available capabilities in [Linux
206 207
 manpages](http://man7.org/linux/man-pages/man7/capabilities.7.html).
207 208
 
208 209
 Of course, you can always enable extra capabilities if you really need
209 210
 them (for instance, if you want to use a FUSE-based filesystem), but by
210
-default, Docker containers will be locked down to ensure maximum safety.
211
+default, Docker containers use only a
212
+[whitelist](https://github.com/dotcloud/docker/blob/master/daemon/execdriver/native/template/default_template.go)
213
+of kernel capabilities by default.
211 214
 
212 215
 ## Other Kernel Security Features
213 216
 
... ...
@@ -222,17 +220,16 @@ harden a Docker host. Here are a few examples.
222 222
 
223 223
  - You can run a kernel with GRSEC and PAX. This will add many safety
224 224
    checks, both at compile-time and run-time; it will also defeat many
225
-   exploits, thanks to techniques like address randomization. It
226
-   doesn't require Docker-specific configuration, since those security
227
-   features apply system-wide, independently of containers.
228
- - If your distribution comes with security model templates for LXC
229
-   containers, you can use them out of the box. For instance, Ubuntu
230
-   comes with AppArmor templates for LXC, and those templates provide
231
-   an extra safety net (even though it overlaps greatly with
232
-   capabilities).
225
+   exploits, thanks to techniques like address randomization. It doesn't
226
+   require Docker-specific configuration, since those security features
227
+   apply system-wide, independently of containers.
228
+ - If your distribution comes with security model templates for
229
+   Docker containers, you can use them out of the box. For instance, we
230
+   ship a template that works with AppArmor and Red Hat comes with SELinux
231
+   policies for Docker. These templates provide an extra safety net (even
232
+   though it overlaps greatly with capabilities).
233 233
  - You can define your own policies using your favorite access control
234
-   mechanism. Since Docker containers are standard LXC containers,
235
-   there is nothing “magic” or specific to Docker.
234
+   mechanism.
236 235
 
237 236
 Just like there are many third-party tools to augment Docker containers
238 237
 with e.g. special network topologies or shared filesystems, you can
... ...
@@ -243,7 +240,7 @@ affecting Docker's core.
243 243
 
244 244
 Docker containers are, by default, quite secure; especially if you take
245 245
 care of running your processes inside the containers as non-privileged
246
-users (i.e. non root).
246
+users (i.e. non-`root`).
247 247
 
248 248
 You can add an extra layer of safety by enabling Apparmor, SELinux,
249 249
 GRSEC, or your favorite hardening solution.