2021-08-23 13:14:53 +00:00
|
|
|
//go:build linux
|
2016-01-19 21:54:42 +00:00
|
|
|
|
2018-02-05 21:05:59 +00:00
|
|
|
package apparmor // import "github.com/docker/docker/profiles/apparmor"
|
2016-01-19 21:54:42 +00:00
|
|
|
|
2020-08-11 08:18:58 +00:00
|
|
|
// NOTE: This profile is replicated in containerd and libpod. If you make a
|
|
|
|
// change to this profile, please make follow-up PRs to those projects so
|
|
|
|
// that these rules can be synchronised (because any issue with this
|
|
|
|
// profile will likely affect libpod and containerd).
|
|
|
|
// TODO: Move this to a common project so we can maintain it in one spot.
|
|
|
|
|
2016-01-19 21:54:42 +00:00
|
|
|
// baseTemplate defines the default apparmor profile for containers.
|
|
|
|
const baseTemplate = `
|
|
|
|
{{range $value := .Imports}}
|
|
|
|
{{$value}}
|
|
|
|
{{end}}
|
|
|
|
|
|
|
|
profile {{.Name}} flags=(attach_disconnected,mediate_deleted) {
|
|
|
|
{{range $value := .InnerImports}}
|
|
|
|
{{$value}}
|
|
|
|
{{end}}
|
|
|
|
|
|
|
|
network,
|
|
|
|
capability,
|
|
|
|
file,
|
|
|
|
umount,
|
2020-08-11 08:18:58 +00:00
|
|
|
# Host (privileged) processes may send signals to container processes.
|
|
|
|
signal (receive) peer=unconfined,
|
|
|
|
# dockerd may send signals to container processes (for "docker kill").
|
2018-04-08 10:21:30 +00:00
|
|
|
signal (receive) peer={{.DaemonProfile}},
|
2020-08-11 08:18:58 +00:00
|
|
|
# Container processes may send signals amongst themselves.
|
2018-04-08 10:21:30 +00:00
|
|
|
signal (send,receive) peer={{.Name}},
|
2016-01-19 21:54:42 +00:00
|
|
|
|
|
|
|
deny @{PROC}/* w, # deny write for all files directly in /proc (not in a subdir)
|
|
|
|
# deny write to files not in /proc/<number>/** or /proc/sys/**
|
2019-08-24 20:28:36 +00:00
|
|
|
deny @{PROC}/{[^1-9],[^1-9][^0-9],[^1-9s][^0-9y][^0-9s],[^1-9][^0-9][^0-9][^0-9/]*}/** w,
|
2016-01-19 21:54:42 +00:00
|
|
|
deny @{PROC}/sys/[^k]** w, # deny /proc/sys except /proc/sys/k* (effectively /proc/sys/kernel)
|
|
|
|
deny @{PROC}/sys/kernel/{?,??,[^s][^h][^m]**} w, # deny everything except shm* in /proc/sys/kernel/
|
|
|
|
deny @{PROC}/sysrq-trigger rwklx,
|
|
|
|
deny @{PROC}/kcore rwklx,
|
|
|
|
|
|
|
|
deny mount,
|
|
|
|
|
|
|
|
deny /sys/[^f]*/** wklx,
|
|
|
|
deny /sys/f[^s]*/** wklx,
|
|
|
|
deny /sys/fs/[^c]*/** wklx,
|
|
|
|
deny /sys/fs/c[^g]*/** wklx,
|
|
|
|
deny /sys/fs/cg[^r]*/** wklx,
|
2016-09-16 02:21:31 +00:00
|
|
|
deny /sys/firmware/** rwklx,
|
2023-09-18 22:41:03 +00:00
|
|
|
deny /sys/devices/virtual/powercap/** rwklx,
|
2016-01-19 21:54:42 +00:00
|
|
|
deny /sys/kernel/security/** rwklx,
|
|
|
|
|
|
|
|
# suppress ptrace denials when using 'docker ps' or using 'ps' inside a container
|
2019-04-22 14:08:28 +00:00
|
|
|
ptrace (trace,read,tracedby,readby) peer={{.Name}},
|
2016-01-19 21:54:42 +00:00
|
|
|
}
|
|
|
|
`
|