github.com/Prakhar-Agarwal-byte/moby@v0.0.0-20231027092010-a14e3e8ab87e/profiles/apparmor/template.go (about) 1 //go:build linux 2 3 package apparmor // import "github.com/Prakhar-Agarwal-byte/moby/profiles/apparmor" 4 5 // NOTE: This profile is replicated in containerd and libpod. If you make a 6 // change to this profile, please make follow-up PRs to those projects so 7 // that these rules can be synchronised (because any issue with this 8 // profile will likely affect libpod and containerd). 9 // TODO: Move this to a common project so we can maintain it in one spot. 10 11 // baseTemplate defines the default apparmor profile for containers. 12 const baseTemplate = ` 13 {{range $value := .Imports}} 14 {{$value}} 15 {{end}} 16 17 profile {{.Name}} flags=(attach_disconnected,mediate_deleted) { 18 {{range $value := .InnerImports}} 19 {{$value}} 20 {{end}} 21 22 network, 23 capability, 24 file, 25 umount, 26 # Host (privileged) processes may send signals to container processes. 27 signal (receive) peer=unconfined, 28 # dockerd may send signals to container processes (for "docker kill"). 29 signal (receive) peer={{.DaemonProfile}}, 30 # Container processes may send signals amongst themselves. 31 signal (send,receive) peer={{.Name}}, 32 33 deny @{PROC}/* w, # deny write for all files directly in /proc (not in a subdir) 34 # deny write to files not in /proc/<number>/** or /proc/sys/** 35 deny @{PROC}/{[^1-9],[^1-9][^0-9],[^1-9s][^0-9y][^0-9s],[^1-9][^0-9][^0-9][^0-9/]*}/** w, 36 deny @{PROC}/sys/[^k]** w, # deny /proc/sys except /proc/sys/k* (effectively /proc/sys/kernel) 37 deny @{PROC}/sys/kernel/{?,??,[^s][^h][^m]**} w, # deny everything except shm* in /proc/sys/kernel/ 38 deny @{PROC}/sysrq-trigger rwklx, 39 deny @{PROC}/kcore rwklx, 40 41 deny mount, 42 43 deny /sys/[^f]*/** wklx, 44 deny /sys/f[^s]*/** wklx, 45 deny /sys/fs/[^c]*/** wklx, 46 deny /sys/fs/c[^g]*/** wklx, 47 deny /sys/fs/cg[^r]*/** wklx, 48 deny /sys/firmware/** rwklx, 49 deny /sys/devices/virtual/powercap/** rwklx, 50 deny /sys/kernel/security/** rwklx, 51 52 # suppress ptrace denials when using 'docker ps' or using 'ps' inside a container 53 ptrace (trace,read,tracedby,readby) peer={{.Name}}, 54 } 55 `