2015-10-13 20:37:54 -04:00
|
|
|
package main
|
|
|
|
|
|
|
|
const dockerProfileTemplate = `@{DOCKER_GRAPH_PATH}=/var/lib/docker
|
2015-05-12 09:44:47 -04:00
|
|
|
|
2015-07-23 23:23:05 -04:00
|
|
|
profile /usr/bin/docker (attach_disconnected, complain) {
|
2015-05-12 09:44:47 -04:00
|
|
|
# Prevent following links to these files during container setup.
|
|
|
|
deny /etc/** mkl,
|
|
|
|
deny /dev/** kl,
|
|
|
|
deny /sys/** mkl,
|
|
|
|
deny /proc/** mkl,
|
|
|
|
|
|
|
|
mount -> @{DOCKER_GRAPH_PATH}/**,
|
|
|
|
mount -> /,
|
|
|
|
mount -> /proc/**,
|
|
|
|
mount -> /sys/**,
|
|
|
|
mount -> /run/docker/netns/**,
|
2015-10-10 20:06:16 -04:00
|
|
|
mount -> /.pivot_root[0-9]*/,
|
|
|
|
|
|
|
|
/ r,
|
2015-05-12 09:44:47 -04:00
|
|
|
|
|
|
|
umount,
|
|
|
|
pivot_root,
|
2016-02-14 02:04:16 -05:00
|
|
|
{{if ge .Version 209000}}
|
2015-05-12 09:44:47 -04:00
|
|
|
signal (receive) peer=@{profile_name},
|
|
|
|
signal (receive) peer=unconfined,
|
|
|
|
signal (send),
|
2016-02-14 02:04:16 -05:00
|
|
|
{{end}}
|
2015-05-12 09:44:47 -04:00
|
|
|
network,
|
|
|
|
capability,
|
2015-07-23 12:01:24 -04:00
|
|
|
owner /** rw,
|
2015-10-05 21:30:09 -04:00
|
|
|
@{DOCKER_GRAPH_PATH}/** rwl,
|
|
|
|
@{DOCKER_GRAPH_PATH}/network/files/boltdb.db k,
|
2015-10-10 20:06:16 -04:00
|
|
|
@{DOCKER_GRAPH_PATH}/network/files/local-kv.db k,
|
2019-09-26 11:34:43 -04:00
|
|
|
# For user namespaces:
|
|
|
|
@{DOCKER_GRAPH_PATH}/[0-9]*.[0-9]*/network/files/boltdb.db k,
|
|
|
|
@{DOCKER_GRAPH_PATH}/[0-9]*.[0-9]*/network/files/local-kv.db k,
|
2015-07-23 12:01:24 -04:00
|
|
|
|
|
|
|
# For non-root client use:
|
|
|
|
/dev/urandom r,
|
2015-10-12 10:41:18 -04:00
|
|
|
/dev/null rw,
|
|
|
|
/dev/pts/[0-9]* rw,
|
2015-07-23 12:01:24 -04:00
|
|
|
/run/docker.sock rw,
|
|
|
|
/proc/** r,
|
2015-10-12 10:41:18 -04:00
|
|
|
/proc/[0-9]*/attr/exec w,
|
2015-07-23 12:01:24 -04:00
|
|
|
/sys/kernel/mm/hugepages/ r,
|
|
|
|
/etc/localtime r,
|
2015-10-05 21:30:09 -04:00
|
|
|
/etc/ld.so.cache r,
|
2015-10-12 10:41:18 -04:00
|
|
|
/etc/passwd r,
|
2015-05-12 09:44:47 -04:00
|
|
|
|
2016-02-14 02:04:16 -05:00
|
|
|
{{if ge .Version 209000}}
|
2015-05-12 09:44:47 -04:00
|
|
|
ptrace peer=@{profile_name},
|
2015-07-23 12:01:24 -04:00
|
|
|
ptrace (read) peer=docker-default,
|
|
|
|
deny ptrace (trace) peer=docker-default,
|
|
|
|
deny ptrace peer=/usr/bin/docker///bin/ps,
|
2016-02-14 02:04:16 -05:00
|
|
|
{{end}}
|
2015-05-12 09:44:47 -04:00
|
|
|
|
2015-10-05 21:30:09 -04:00
|
|
|
/usr/lib/** rm,
|
|
|
|
/lib/** rm,
|
|
|
|
|
2015-05-12 09:44:47 -04:00
|
|
|
/usr/bin/docker pix,
|
2015-07-23 12:01:24 -04:00
|
|
|
/sbin/xtables-multi rCx,
|
2015-05-12 09:44:47 -04:00
|
|
|
/sbin/iptables rCx,
|
|
|
|
/sbin/modprobe rCx,
|
|
|
|
/sbin/auplink rCx,
|
2015-07-30 06:24:41 -04:00
|
|
|
/sbin/mke2fs rCx,
|
|
|
|
/sbin/tune2fs rCx,
|
|
|
|
/sbin/blkid rCx,
|
2015-07-23 12:01:24 -04:00
|
|
|
/bin/kmod rCx,
|
2015-05-12 09:44:47 -04:00
|
|
|
/usr/bin/xz rCx,
|
2015-07-23 12:01:24 -04:00
|
|
|
/bin/ps rCx,
|
2015-12-23 12:11:16 -05:00
|
|
|
/bin/tar rCx,
|
2015-07-23 12:01:24 -04:00
|
|
|
/bin/cat rCx,
|
|
|
|
/sbin/zfs rCx,
|
2015-10-05 21:30:09 -04:00
|
|
|
/sbin/apparmor_parser rCx,
|
2015-05-12 09:44:47 -04:00
|
|
|
|
2016-02-14 02:04:16 -05:00
|
|
|
{{if ge .Version 209000}}
|
2015-05-12 09:44:47 -04:00
|
|
|
# Transitions
|
|
|
|
change_profile -> docker-*,
|
|
|
|
change_profile -> unconfined,
|
2016-02-14 02:04:16 -05:00
|
|
|
{{end}}
|
2015-05-12 09:44:47 -04:00
|
|
|
|
2015-07-23 23:23:05 -04:00
|
|
|
profile /bin/cat (complain) {
|
2015-07-23 12:01:24 -04:00
|
|
|
/etc/ld.so.cache r,
|
2015-10-05 21:30:09 -04:00
|
|
|
/lib/** rm,
|
2015-07-23 12:01:24 -04:00
|
|
|
/dev/null rw,
|
|
|
|
/proc r,
|
|
|
|
/bin/cat mr,
|
|
|
|
|
|
|
|
# For reading in 'docker stats':
|
|
|
|
/proc/[0-9]*/net/dev r,
|
|
|
|
}
|
2015-07-23 23:23:05 -04:00
|
|
|
profile /bin/ps (complain) {
|
2015-07-23 12:01:24 -04:00
|
|
|
/etc/ld.so.cache r,
|
|
|
|
/etc/localtime r,
|
|
|
|
/etc/passwd r,
|
|
|
|
/etc/nsswitch.conf r,
|
2015-10-05 21:30:09 -04:00
|
|
|
/lib/** rm,
|
2015-07-23 12:01:24 -04:00
|
|
|
/proc/[0-9]*/** r,
|
|
|
|
/dev/null rw,
|
|
|
|
/bin/ps mr,
|
|
|
|
|
2016-02-14 02:04:16 -05:00
|
|
|
{{if ge .Version 209000}}
|
2015-07-23 12:01:24 -04:00
|
|
|
# We don't need ptrace so we'll deny and ignore the error.
|
|
|
|
deny ptrace (read, trace),
|
2016-02-14 02:04:16 -05:00
|
|
|
{{end}}
|
2015-07-23 12:01:24 -04:00
|
|
|
|
|
|
|
# Quiet dac_override denials
|
|
|
|
deny capability dac_override,
|
|
|
|
deny capability dac_read_search,
|
|
|
|
deny capability sys_ptrace,
|
|
|
|
|
|
|
|
/dev/tty r,
|
|
|
|
/proc/stat r,
|
|
|
|
/proc/cpuinfo r,
|
|
|
|
/proc/meminfo r,
|
|
|
|
/proc/uptime r,
|
|
|
|
/sys/devices/system/cpu/online r,
|
|
|
|
/proc/sys/kernel/pid_max r,
|
|
|
|
/proc/ r,
|
|
|
|
/proc/tty/drivers r,
|
|
|
|
}
|
2015-07-23 23:23:05 -04:00
|
|
|
profile /sbin/iptables (complain) {
|
2016-02-14 02:04:16 -05:00
|
|
|
{{if ge .Version 209000}}
|
2015-07-23 12:01:24 -04:00
|
|
|
signal (receive) peer=/usr/bin/docker,
|
2016-02-14 02:04:16 -05:00
|
|
|
{{end}}
|
2015-07-23 12:01:24 -04:00
|
|
|
capability net_admin,
|
2015-05-12 09:44:47 -04:00
|
|
|
}
|
2015-07-23 23:23:05 -04:00
|
|
|
profile /sbin/auplink flags=(attach_disconnected, complain) {
|
2016-02-14 02:04:16 -05:00
|
|
|
{{if ge .Version 209000}}
|
2015-07-23 12:01:24 -04:00
|
|
|
signal (receive) peer=/usr/bin/docker,
|
2016-02-14 02:04:16 -05:00
|
|
|
{{end}}
|
2015-07-23 12:01:24 -04:00
|
|
|
capability sys_admin,
|
|
|
|
capability dac_override,
|
2015-05-12 09:44:47 -04:00
|
|
|
|
2015-07-23 12:01:24 -04:00
|
|
|
@{DOCKER_GRAPH_PATH}/aufs/** rw,
|
|
|
|
@{DOCKER_GRAPH_PATH}/tmp/** rw,
|
|
|
|
# For user namespaces:
|
|
|
|
@{DOCKER_GRAPH_PATH}/[0-9]*.[0-9]*/** rw,
|
2015-05-12 09:44:47 -04:00
|
|
|
|
2015-07-23 12:01:24 -04:00
|
|
|
/sys/fs/aufs/** r,
|
2015-10-05 21:30:09 -04:00
|
|
|
/lib/** rm,
|
2015-07-23 12:01:24 -04:00
|
|
|
/apparmor/.null r,
|
|
|
|
/dev/null rw,
|
|
|
|
/etc/ld.so.cache r,
|
|
|
|
/sbin/auplink rm,
|
|
|
|
/proc/fs/aufs/** rw,
|
|
|
|
/proc/[0-9]*/mounts rw,
|
2015-05-12 09:44:47 -04:00
|
|
|
}
|
2015-07-23 23:23:05 -04:00
|
|
|
profile /sbin/modprobe /bin/kmod (complain) {
|
2016-02-14 02:04:16 -05:00
|
|
|
{{if ge .Version 209000}}
|
2015-07-23 12:01:24 -04:00
|
|
|
signal (receive) peer=/usr/bin/docker,
|
2016-02-14 02:04:16 -05:00
|
|
|
{{end}}
|
2015-07-23 12:01:24 -04:00
|
|
|
capability sys_module,
|
|
|
|
/etc/ld.so.cache r,
|
2015-10-05 21:30:09 -04:00
|
|
|
/lib/** rm,
|
2015-07-23 12:01:24 -04:00
|
|
|
/dev/null rw,
|
|
|
|
/apparmor/.null rw,
|
|
|
|
/sbin/modprobe rm,
|
|
|
|
/bin/kmod rm,
|
|
|
|
/proc/cmdline r,
|
|
|
|
/sys/module/** r,
|
|
|
|
/etc/modprobe.d{/,/**} r,
|
2015-05-12 09:44:47 -04:00
|
|
|
}
|
|
|
|
# xz works via pipes, so we do not need access to the filesystem.
|
2015-07-23 23:23:05 -04:00
|
|
|
profile /usr/bin/xz (complain) {
|
2016-02-14 02:04:16 -05:00
|
|
|
{{if ge .Version 209000}}
|
2015-07-23 12:01:24 -04:00
|
|
|
signal (receive) peer=/usr/bin/docker,
|
2016-02-14 02:04:16 -05:00
|
|
|
{{end}}
|
2015-07-23 12:01:24 -04:00
|
|
|
/etc/ld.so.cache r,
|
2015-10-05 21:30:09 -04:00
|
|
|
/lib/** rm,
|
2015-07-23 12:01:24 -04:00
|
|
|
/usr/bin/xz rm,
|
|
|
|
deny /proc/** rw,
|
|
|
|
deny /sys/** rw,
|
|
|
|
}
|
2015-07-23 23:23:05 -04:00
|
|
|
profile /sbin/xtables-multi (attach_disconnected, complain) {
|
2015-07-23 12:01:24 -04:00
|
|
|
/etc/ld.so.cache r,
|
2015-10-05 21:30:09 -04:00
|
|
|
/lib/** rm,
|
2015-07-23 12:01:24 -04:00
|
|
|
/sbin/xtables-multi rm,
|
|
|
|
/apparmor/.null w,
|
|
|
|
/dev/null rw,
|
2015-10-05 21:30:09 -04:00
|
|
|
|
|
|
|
/proc r,
|
|
|
|
|
2015-07-23 12:01:24 -04:00
|
|
|
capability net_raw,
|
|
|
|
capability net_admin,
|
|
|
|
network raw,
|
|
|
|
}
|
2015-07-23 23:23:05 -04:00
|
|
|
profile /sbin/zfs (attach_disconnected, complain) {
|
2015-07-23 12:01:24 -04:00
|
|
|
file,
|
|
|
|
capability,
|
2015-05-12 09:44:47 -04:00
|
|
|
}
|
2015-07-30 06:24:41 -04:00
|
|
|
profile /sbin/mke2fs (complain) {
|
|
|
|
/sbin/mke2fs rm,
|
|
|
|
|
2015-10-05 21:30:09 -04:00
|
|
|
/lib/** rm,
|
2015-07-30 06:24:41 -04:00
|
|
|
|
|
|
|
/apparmor/.null w,
|
|
|
|
|
|
|
|
/etc/ld.so.cache r,
|
|
|
|
/etc/mke2fs.conf r,
|
|
|
|
/etc/mtab r,
|
|
|
|
|
|
|
|
/dev/dm-* rw,
|
|
|
|
/dev/urandom r,
|
|
|
|
/dev/null rw,
|
|
|
|
|
|
|
|
/proc/swaps r,
|
|
|
|
/proc/[0-9]*/mounts r,
|
|
|
|
}
|
|
|
|
profile /sbin/tune2fs (complain) {
|
|
|
|
/sbin/tune2fs rm,
|
|
|
|
|
2015-10-05 21:30:09 -04:00
|
|
|
/lib/** rm,
|
2015-07-30 06:24:41 -04:00
|
|
|
|
|
|
|
/apparmor/.null w,
|
|
|
|
|
|
|
|
/etc/blkid.conf r,
|
|
|
|
/etc/mtab r,
|
|
|
|
/etc/ld.so.cache r,
|
|
|
|
|
|
|
|
/dev/null rw,
|
|
|
|
/dev/.blkid.tab r,
|
|
|
|
/dev/dm-* rw,
|
|
|
|
|
|
|
|
/proc/swaps r,
|
|
|
|
/proc/[0-9]*/mounts r,
|
|
|
|
}
|
|
|
|
profile /sbin/blkid (complain) {
|
|
|
|
/sbin/blkid rm,
|
|
|
|
|
2015-10-05 21:30:09 -04:00
|
|
|
/lib/** rm,
|
2015-07-30 06:24:41 -04:00
|
|
|
/apparmor/.null w,
|
|
|
|
|
|
|
|
/etc/ld.so.cache r,
|
|
|
|
/etc/blkid.conf r,
|
|
|
|
|
|
|
|
/dev/null rw,
|
|
|
|
/dev/.blkid.tab rl,
|
|
|
|
/dev/.blkid.tab* rwl,
|
|
|
|
/dev/dm-* r,
|
|
|
|
|
|
|
|
/sys/devices/virtual/block/** r,
|
|
|
|
|
|
|
|
capability mknod,
|
|
|
|
|
|
|
|
mount -> @{DOCKER_GRAPH_PATH}/**,
|
|
|
|
}
|
2015-10-05 21:30:09 -04:00
|
|
|
profile /sbin/apparmor_parser (complain) {
|
|
|
|
/sbin/apparmor_parser rm,
|
|
|
|
|
|
|
|
/lib/** rm,
|
|
|
|
|
|
|
|
/etc/ld.so.cache r,
|
|
|
|
/etc/apparmor/** r,
|
|
|
|
/etc/apparmor.d/** r,
|
|
|
|
/etc/apparmor.d/cache/** w,
|
|
|
|
|
|
|
|
/dev/null rw,
|
|
|
|
|
|
|
|
/sys/kernel/security/apparmor/** r,
|
|
|
|
/sys/kernel/security/apparmor/.replace w,
|
|
|
|
|
|
|
|
/proc/[0-9]*/mounts r,
|
|
|
|
/proc/sys/kernel/osrelease r,
|
|
|
|
/proc r,
|
|
|
|
|
|
|
|
capability mac_admin,
|
|
|
|
}
|
2015-10-13 20:37:54 -04:00
|
|
|
}`
|