2015-11-18 04:38:57 -05:00
<!-- [metadata]>
+++
title = "Seccomp security profiles for Docker"
description = "Enabling seccomp in Docker"
keywords = ["seccomp, security, docker, documentation"]
2015-11-14 21:01:24 -05:00
[menu.main]
parent= "smn_secure_docker"
2016-01-20 15:46:40 -05:00
weight=90
2015-11-18 04:38:57 -05:00
+++
<![end-metadata]-->
2015-11-14 21:01:24 -05:00
# Seccomp security profiles for Docker
2015-11-18 04:38:57 -05:00
2015-11-14 21:01:24 -05:00
Secure computing mode (Seccomp) is a Linux kernel feature. You can use it to
restrict the actions available within the container. The `seccomp()` system
call operates on the seccomp state of the calling process. You can use this
feature to restrict your application's access.
2015-11-18 04:38:57 -05:00
2016-03-03 05:58:40 -05:00
This feature is available only if Docker has been built with seccomp and the
kernel is configured with `CONFIG_SECCOMP` enabled. To check if your kernel
supports seccomp:
2015-11-18 04:38:57 -05:00
2016-03-03 05:58:40 -05:00
```bash
$ cat /boot/config-`uname -r` | grep CONFIG_SECCOMP=
CONFIG_SECCOMP=y
```
> **Note**: seccomp profiles require seccomp 2.2.1 and are only
2016-04-26 17:09:00 -04:00
> available starting with Debian 9 "Stretch", Ubuntu 15.10 "Wily",
2016-05-12 06:38:02 -04:00
> Fedora 22, CentOS 7 and Oracle Linux 7. To use this feature on Ubuntu 14.04, Debian Wheezy, or
2016-02-17 17:45:18 -05:00
> Debian Jessie, you must download the [latest static Docker Linux binary](../installation/binaries.md).
> This feature is currently *not* available on other distributions.
2016-02-05 10:53:45 -05:00
2015-11-14 21:01:24 -05:00
## Passing a profile for a container
2015-11-18 04:38:57 -05:00
2015-11-14 21:01:24 -05:00
The default seccomp profile provides a sane default for running containers with
2016-02-29 11:03:31 -05:00
seccomp and disables around 44 system calls out of 300+. It is moderately protective while providing wide application
2016-08-02 00:24:15 -04:00
compatibility. The default Docker profile (found [here ](https://github.com/docker/docker/blob/master/profiles/seccomp/default.json )) has a JSON layout in the following form:
2015-11-18 04:38:57 -05:00
2016-03-03 05:58:40 -05:00
```json
2015-11-18 04:38:57 -05:00
{
2016-02-29 11:03:31 -05:00
"defaultAction": "SCMP_ACT_ERRNO",
2016-07-13 09:41:30 -04:00
"archMap": [
{
"architecture": "SCMP_ARCH_X86_64",
"subArchitectures": [
"SCMP_ARCH_X86",
"SCMP_ARCH_X32"
]
},
...
2016-02-29 11:03:31 -05:00
],
"syscalls": [
{
2016-07-13 09:41:30 -04:00
"names": [
"accept",
"accept4",
"access",
"alarm",
"alarm",
"bind",
"brk",
...
"waitid",
"waitpid",
"write",
"writev"
],
2016-02-29 11:03:31 -05:00
"action": "SCMP_ACT_ALLOW",
2016-07-13 09:41:30 -04:00
"args": [],
"comment": "",
"includes": {},
"excludes": {}
2016-02-29 11:03:31 -05:00
},
{
2016-07-13 09:41:30 -04:00
"names": [
"clone"
],
2016-02-29 11:03:31 -05:00
"action": "SCMP_ACT_ALLOW",
2016-07-13 09:41:30 -04:00
"args": [
{
"index": 1,
"value": 2080505856,
"valueTwo": 0,
"op": "SCMP_CMP_MASKED_EQ"
}
],
"comment": "s390 parameter ordering for clone is different",
"includes": {
"arches": [
"s390",
"s390x"
]
},
"excludes": {
"caps": [
"CAP_SYS_ADMIN"
]
}
2016-03-03 05:58:40 -05:00
},
2016-02-29 11:03:31 -05:00
...
2015-11-18 04:38:57 -05:00
}
```
2015-11-14 21:01:24 -05:00
When you run a container, it uses the default profile unless you override
it with the `security-opt` option. For example, the following explicitly
specifies the default policy:
2015-11-18 04:38:57 -05:00
```
2016-03-15 18:34:29 -04:00
$ docker run --rm -it --security-opt seccomp=/path/to/seccomp/profile.json hello-world
2015-11-18 04:38:57 -05:00
```
2015-12-21 22:32:12 -05:00
2016-02-29 11:03:31 -05:00
### Significant syscalls blocked by the default profile
2016-01-04 14:43:28 -05:00
Docker's default seccomp profile is a whitelist which specifies the calls that
are allowed. The table below lists the significant (but not all) syscalls that
are effectively blocked because they are not on the whitelist. The table includes
the reason each syscall is blocked rather than white-listed.
| Syscall | Description |
|---------------------|---------------------------------------------------------------------------------------------------------------------------------------|
| `acct` | Accounting syscall which could let containers disable their own resource limits or process accounting. Also gated by `CAP_SYS_PACCT` . |
2015-11-14 21:01:24 -05:00
| `add_key` | Prevent containers from using the kernel keyring, which is not namespaced. |
| `adjtimex` | Similar to `clock_settime` and `settimeofday` , time/date is not namespaced. |
| `bpf` | Deny loading potentially persistent bpf programs into kernel, already gated by `CAP_SYS_ADMIN` . |
| `clock_adjtime` | Time/date is not namespaced. |
| `clock_settime` | Time/date is not namespaced. |
| `clone` | Deny cloning new namespaces. Also gated by `CAP_SYS_ADMIN` for CLONE_* flags, except `CLONE_USERNS` . |
| `create_module` | Deny manipulation and functions on kernel modules. |
| `delete_module` | Deny manipulation and functions on kernel modules. Also gated by `CAP_SYS_MODULE` . |
| `finit_module` | Deny manipulation and functions on kernel modules. Also gated by `CAP_SYS_MODULE` . |
| `get_kernel_syms` | Deny retrieval of exported kernel and module symbols. |
| `get_mempolicy` | Syscall that modifies kernel memory and NUMA settings. Already gated by `CAP_SYS_NICE` . |
| `init_module` | Deny manipulation and functions on kernel modules. Also gated by `CAP_SYS_MODULE` . |
| `ioperm` | Prevent containers from modifying kernel I/O privilege levels. Already gated by `CAP_SYS_RAWIO` . |
| `iopl` | Prevent containers from modifying kernel I/O privilege levels. Already gated by `CAP_SYS_RAWIO` . |
| `kcmp` | Restrict process inspection capabilities, already blocked by dropping `CAP_PTRACE` . |
| `kexec_file_load` | Sister syscall of `kexec_load` that does the same thing, slightly different arguments. |
| `kexec_load` | Deny loading a new kernel for later execution. |
| `keyctl` | Prevent containers from using the kernel keyring, which is not namespaced. |
| `lookup_dcookie` | Tracing/profiling syscall, which could leak a lot of information on the host. |
| `mbind` | Syscall that modifies kernel memory and NUMA settings. Already gated by `CAP_SYS_NICE` . |
| `mount` | Deny mounting, already gated by `CAP_SYS_ADMIN` . |
| `move_pages` | Syscall that modifies kernel memory and NUMA settings. |
| `name_to_handle_at` | Sister syscall to `open_by_handle_at` . Already gated by `CAP_SYS_NICE` . |
| `nfsservctl` | Deny interaction with the kernel nfs daemon. |
| `open_by_handle_at` | Cause of an old container breakout. Also gated by `CAP_DAC_READ_SEARCH` . |
| `perf_event_open` | Tracing/profiling syscall, which could leak a lot of information on the host. |
| `personality` | Prevent container from enabling BSD emulation. Not inherently dangerous, but poorly tested, potential for a lot of kernel vulns. |
| `pivot_root` | Deny `pivot_root` , should be privileged operation. |
| `process_vm_readv` | Restrict process inspection capabilities, already blocked by dropping `CAP_PTRACE` . |
| `process_vm_writev` | Restrict process inspection capabilities, already blocked by dropping `CAP_PTRACE` . |
| `ptrace` | Tracing/profiling syscall, which could leak a lot of information on the host. Already blocked by dropping `CAP_PTRACE` . |
| `query_module` | Deny manipulation and functions on kernel modules. |
| `quotactl` | Quota syscall which could let containers disable their own resource limits or process accounting. Also gated by `CAP_SYS_ADMIN` . |
| `reboot` | Don't let containers reboot the host. Also gated by `CAP_SYS_BOOT` . |
| `request_key` | Prevent containers from using the kernel keyring, which is not namespaced. |
| `set_mempolicy` | Syscall that modifies kernel memory and NUMA settings. Already gated by `CAP_SYS_NICE` . |
| `setns` | Deny associating a thread with a namespace. Also gated by `CAP_SYS_ADMIN` . |
| `settimeofday` | Time/date is not namespaced. Also gated by `CAP_SYS_TIME` . |
| `stime` | Time/date is not namespaced. Also gated by `CAP_SYS_TIME` . |
| `swapon` | Deny start/stop swapping to file/device. Also gated by `CAP_SYS_ADMIN` . |
| `swapoff` | Deny start/stop swapping to file/device. Also gated by `CAP_SYS_ADMIN` . |
| `sysfs` | Obsolete syscall. |
| `_sysctl` | Obsolete, replaced by /proc/sys. |
| `umount` | Should be a privileged operation. Also gated by `CAP_SYS_ADMIN` . |
| `umount2` | Should be a privileged operation. |
| `unshare` | Deny cloning new namespaces for processes. Also gated by `CAP_SYS_ADMIN` , with the exception of `unshare --user` . |
| `uselib` | Older syscall related to shared libraries, unused for a long time. |
2016-03-16 17:17:32 -04:00
| `userfaultfd` | Userspace page fault handling, largely needed for process migration. |
2015-11-14 21:01:24 -05:00
| `ustat` | Obsolete syscall. |
| `vm86` | In kernel x86 real mode virtual machine. Also gated by `CAP_SYS_ADMIN` . |
| `vm86old` | In kernel x86 real mode virtual machine. Also gated by `CAP_SYS_ADMIN` . |
## Run without the default seccomp profile
You can pass `unconfined` to run a container without the default seccomp
profile.
```
2016-03-15 18:34:29 -04:00
$ docker run --rm -it --security-opt seccomp=unconfined debian:jessie \
2015-11-14 21:01:24 -05:00
unshare --map-root-user --user sh -c whoami
```