1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288
|
# kate: syntax AppArmor Security Profile; replace-tabs off;
#
# Sample AppArmor Profile.
# License: Public Domain
#
# NOTE: This profile is not fully functional, since
# it is designed to test the syntax highlighting
# for the KDE's KSyntaxHighlighting framework.
#
include <tunables/global>
# Variable assignment
@{FOO_LIB}=/usr/lib{,32,64}/foo
@{USER_DIR}
= @{HOME}/Public @{HOME}/Desktop #No-Comment
@{USER_DIR} += @{HOME}/Hello \
deny owner #No-comment aa#aa
${BOOL} = true
# Alias
alias /usr/ -> /mnt/usr/,
# ABI feature
abi <abi/3.0>,
abi <"includes/abi/4.19">,
abi "simple_tests/includes/abi/4.19",
abi simple_tests/includes/abi/4.19,
# Profile for /usr/bin/foo
profile foo /usr/bin/foo flags=(attach_disconnected enforce) xattrs=(myvalue=foo user.bar=* user.foo="bar" ) {
#include <abstractions/ubuntu-helpers>
#include<abstractions/wayland>
#include"/etc/apparmor.d/abstractions/ubuntu-konsole"
include "/etc/apparmor.d/abstractions/openssl"
include if exists <path with spaces>
include <include_tests/includes_okay_helper.include> #include <includes/base>
/some/file mr, #include <includes/base> /bin/true Px,
# File rules
/{,**/} r,
owner /{home,media,mnt,srv,net}/** r,
owner @{USER_DIR}/** rw,
audit deny owner /**/* mx,
/**.[tT][xX][tT] r, # txt
owner file @{HOME}/.local/share/foo/{,**} rwkl,
owner @{HOME}/.config/*.[a-zA-Z0-9]* rwk,
"/usr/share/**" r,
"/var/lib/flatpak/exports/share/**" r,
"/var/lib/{spaces in
string,hello}/a[^ a]a/**" r,
allow file /etc/nsswitch.conf r,
allow /etc/fstab r,
deny /etc/xdg/{autostart,systemd}/** r,
deny /boot/** rwlkmx,
owner @{PROC}/@{pid}/{cmdline,mountinfo,mounts,stat,status,vmstat} r,
/sys/devices/**/uevent r,
@{FOO_LIB}/{@{multiarch},64}/** mr,
/usr/bin/foo ixr,
/usr/bin/dolphin pUx,
/usr/bin/* Pixr,
/usr/bin/khelpcenter Cx -> sanitized_helper,
/usr/bin/helloworld cxr ->
hello_world,
/bin/** px -> profile,
# Dbus rules
dbus (send) #No-Comment
bus=system
path=/org/freedesktop/NetworkManager
interface=org.freedesktop.DBus.Introspectable
peer=(name=org.freedesktop.NetworkManager label=unconfined),
dbus (send receive)
bus=system
path=/org/freedesktop/NetworkManager
interface=org.freedesktop.NetworkManager
member={Introspect,state}
peer=(name=(org.freedesktop.NetworkManager|org.freedesktop.DBus)),
dbus (send)
bus=session
path=/org/gnome/GConf/Database/*
member={AddMatch,AddNotify,AllEntries,LookupExtended,RemoveNotify},
dbus (bind)
bus=system
name=org.bluez,
# Signal rules
signal (send) set=(term) peer="/usr/lib/hello/world// foo helper",
signal (send, receive) set=(int exists rtmin+8) peer=/usr/lib/hello/world//foo-helper,
# Child profile
profile hello_world {
# File rules (three different ways)
file /usr/lib{,32,64}/helloworld/**.so mr,
/usr/lib{,32,64}/helloworld/** r,
rk /usr/lib{,32,64}/helloworld/hello,file,
# Link rules (two ways)
l /foo1 -> /bar,
link /foo2 -> bar,
link subset /link* -> /**,
# Network rules
network inet6 tcp,
network netlink dgram,
network bluetooth,
network unspec dgram,
# Capability rules
capability dac_override,
capability sys_admin,
capability sys_chroot,
# Mount rules
mount options=(rw bind remount nodev noexec) vfstype=ecryptfs /home/*/.helloworld/ -> /home/*/helloworld/,
mount options in (rw, bind) / -> /run/hellowordd/*.mnt,
mount options=read-only fstype=btrfs /dev/sd[a-z][1-9]* -> /media/*/*,
umount /home/*/helloworld/,
# Pivot Root rules
pivot_root oldroot=/mnt/root/old/ /mnt/root/,
pivot_root /mnt/root/,
# Ptrace rules
ptrace (trace) peer=unconfined,
ptrace (read, trace, tracedby) peer=/usr/lib/hello/helloword,
# Unix rules
unix (connect receive send) type=(stream) peer=(addr=@/tmp/ibus/dbus-*,label=unconfined),
unix (send,receive) type=(stream) protocol=0 peer=(addr=none),
unix peer=(label=@{profile_name},addr=@helloworld),
# Rlimit rule
set rlimit data <= 100M,
set rlimit nproc <= 10,
set rlimit memlock <= 2GB,
set rlimit rss <= infinity,
set rlimit nice <= -12,
set rlimit nice <= -12K,
# Change Profile rules
change_profile unsafe /** -> [^u/]**,
change_profile unsafe /** -> {u,un,unc,unco,uncon,unconf,unconfi,unconfin,unconfine},
change_profile /bin/bash ->
new_profile//hat,
}
# Hat
^foo-helper\/ {
network unix stream,
unix stream,
/usr/hi\"esc\x23esc\032es\477esc\*es\{esc\ rw r, # Escape expressions
# Text after a variable is highlighted as path
file /my/path r,
@{FOO_LIB}file r,
@{FOO_LIB}#my/path r, #Comment
@{FOO_LIB}ñ* r,
unix (/path\t{aa}*,*a @{var}*path,* @{var},*),
}
}
# Syntax Error
/usr/bin/error (complain, audit) {
file #include /hello r,
# Error: Variable open or with characters not allowed
@{var
@{sdf&s}
# Error: Open brackets
/{hello{ab,cd}world kr,
/{abc{abc kr,
/[abc kr,
/(abc kr,
# Error: Empty brackets
/hello[]hello{}hello()he kr,
# Comments not allowed
dbus (send) #No comment
path=/org/hello
#No comment
interface=org.hello #No comment
peer=(name=org.hello #No comment
label=unconfined), #Comment
# Don't allow assignment of variables within profiles
@{VARIABLE} = val1 val2 val3 # Comment
# Alias rules not allowed within profiles
alias /run/ -> /mnt/run/,
# Error: Open rule
/home/*/file rw
capability dac_override
deny file /etc/fstab w
audit network ieee802154,
dbus (receive
unix stream,
unix stream,
}
profile other_tests {
# set rlimit
set rlimit nice <= 3,
rlimit nice <= 3, # Without "set"
set #comment
rlimit
nice <= 3,
# "remount" keyword
mount remount
remount,
remount remount
remount,
dbus remount
remount,
unix remount
remount,
# "unix" keyword
network unix
unix,
ptrace unix
unix,
unix unix
unix,
# Transition rules
/usr/bin/foo cx -> hello*, # profile name
/usr/bin/foo Cx -> path/, # path
/usr/bin/foo cx -> ab[ad/]hello, # profile name
/usr/bin/foo Cx -> ab[cd/]a[ad/]hello/path, # path
/usr/bin/foo Cx -> ab[hello/path, # profile name
/usr/bin/foo cx -> "hello*", # profile name
/usr/bin/foo Cx -> "path/", # path
/usr/bin/foo cx -> "ab[ad/]hello", # profile name
/usr/bin/foo Cx -> "ab[cd/]a[ad/]hello/path", # path
/usr/bin/foo Cx -> "ab[hello/path", # profile name
/usr/bin/foo cx -> holas//hello/sa, # path
/usr/bin/foo cx -> df///dd//hat, # path + hat
/usr/bin/foo cx -> holas,#sd\323fsdf, # profile name
# Access modes
/hello/lib/foo rwklms, # s invalid
/hello/lib/foo rwmaix, # w & a incompatible
/hello/lib/foo kalmw,
/hello/lib/foo wa,
# OK
/hello/lib/foo rrwrwwrwrw,
/hello/lib/foo ixixix,
# Incompatible exec permissions
ixixux, uxuxUxux, ixixixPixix, ixixpx uxuxuxPuxux, UxUxcUxUx,
pixpixcixix, cxcxcxix, pixpixpux pixpixix xxix xxpux ixixx puxpuxx,
Cuxcux Pixpix, puxpUx puxPUx xxpix xxcx,
# Test valid permissions
r w a k l m l x ix ux Ux px Px cx Cx ,
pix Pix cix Cix pux Pux cux Cux pUx PUx cUx CUx,
rwklmx raklmx,
r rw rwk rwkl rwklm,
rwlmix rwlmUx rwlmPx rwlmcx rwlmPUx,
rwixixixkl rwUxUxUxkl rwuxuxuxk rwpxpxpxk rwPxPxkl rwcxcxlm rwCxCxk,
rwpixpixk rwPixPixkl wrpuxpuxk rwpUxpUxk rwcixcixcixml rwCixCixk rwCuxCuxk rwCUxCUxl,
# Profile name
profile holas { ... }
profile { ... }
profile /path { ... }
profile holas/abc { ... }
profile holas\/abc { ... }
profile
#holas { ... }
profile flags=(complain)#asd { ... }
profile flags flags=(complain) { ... }
profile flags(complain) { ... }
}
|