| 1 |
# vim:syntax=apparmor |
| 2 |
|
| 3 |
# evince is not written with application confinement in mind and is designed to |
| 4 |
# operate within a trusted desktop session where anything running within the |
| 5 |
# user's session is trusted. That said, evince will often process untrusted |
| 6 |
# input (PDFs, images, etc). Ideally evince would be written in such a way that |
| 7 |
# image processing is separate from the main process and that processing |
| 8 |
# happens in a restrictive sandbox, but unfortunately that is not currently the |
| 9 |
# case. Because evince will process untrusted input, this profile aims to |
| 10 |
# provide some hardening, but considering evince's design and other factors such |
| 11 |
# as X, gsettings, accessibility, translations, DBus session and system |
| 12 |
# services, etc, complete confinement is not possible. |
| 13 |
|
| 14 |
include <tunables/global> |
| 15 |
|
| 16 |
/usr/bin/evince { |
| 17 |
include <abstractions/audio> |
| 18 |
include <abstractions/bash> |
| 19 |
include <abstractions/cups-client> |
| 20 |
include <abstractions/dbus-accessibility> |
| 21 |
include <abstractions/evince> |
| 22 |
include <abstractions/ibus> |
| 23 |
include <abstractions/nameservice> |
| 24 |
|
| 25 |
include <abstractions/ubuntu-browsers> |
| 26 |
include <abstractions/ubuntu-console-browsers> |
| 27 |
include <abstractions/ubuntu-email> |
| 28 |
include <abstractions/ubuntu-console-email> |
| 29 |
include <abstractions/ubuntu-media-players> |
| 30 |
|
| 31 |
# allow evince to spawn browsers distributed as snaps (LP: #1794064) |
| 32 |
include if exists <abstractions/snap_browsers> |
| 33 |
|
| 34 |
# For now, let evince talk to any session services over dbus. We can |
| 35 |
# blacklist any problematic ones (but note, evince uses libsecret :\) |
| 36 |
include <abstractions/dbus-session> |
| 37 |
|
| 38 |
include <abstractions/dbus-strict> |
| 39 |
dbus (receive) bus=system, |
| 40 |
# Allow getting information from various system services |
| 41 |
dbus (send) |
| 42 |
bus=system |
| 43 |
member="Get*" |
| 44 |
peer=(label=unconfined), |
| 45 |
# Allow talking to avahi with whatever polkit allows |
| 46 |
dbus (send) |
| 47 |
bus=system |
| 48 |
interface="org.freedesktop.Avahi{,.*}", |
| 49 |
# Allow talking to colord with whatever polkit allows |
| 50 |
dbus (send) |
| 51 |
bus=system |
| 52 |
interface="org.freedesktop.ColorManager{,.*}", |
| 53 |
|
| 54 |
# Terminals for using console applications. These abstractions should ideally |
| 55 |
# have 'ix' to restrict access to what only evince is allowed to do |
| 56 |
include <abstractions/ubuntu-gnome-terminal> |
| 57 |
|
| 58 |
# By default, we won't support launching a terminal program in Xterm or |
| 59 |
# KDE's konsole. It opens up too many unnecessary files for most users. |
| 60 |
# People who need this functionality can uncomment the following: |
| 61 |
##include <abstractions/ubuntu-xterm> |
| 62 |
##include <abstractions/ubuntu-konsole> |
| 63 |
|
| 64 |
/usr/bin/evince rmPx, |
| 65 |
/usr/bin/evince-previewer Px, |
| 66 |
/usr/bin/papers-previewer Px, |
| 67 |
/usr/bin/yelp Cx -> sanitized_helper, |
| 68 |
/usr/bin/bug-buddy px, |
| 69 |
# 'Show Containing Folder' (LP: #1022962) |
| 70 |
/usr/bin/nautilus Cx -> sanitized_helper, # Gnome |
| 71 |
/usr/bin/pcmanfm Cx -> sanitized_helper, # LXDE |
| 72 |
/usr/bin/krusader Cx -> sanitized_helper, # KDE |
| 73 |
/usr/bin/thunar Cx -> sanitized_helper, # XFCE |
| 74 |
|
| 75 |
# Print Dialog |
| 76 |
/usr/lib/@{multiarch}/libproxy/*/pxgsettings Cx -> sanitized_helper, |
| 77 |
|
| 78 |
# For Xubuntu to launch the browser |
| 79 |
include <abstractions/exo-open> |
| 80 |
|
| 81 |
# For text attachments |
| 82 |
/usr/bin/gedit ixr, |
| 83 |
|
| 84 |
# For Send to |
| 85 |
/usr/bin/nautilus-sendto Cx -> sanitized_helper, |
| 86 |
|
| 87 |
# GLib desktop launch helper (used under the hood by g_app_info_launch) |
| 88 |
/usr/lib/@{multiarch}/glib-[0-9]*/gio-launch-desktop rmix, |
| 89 |
/usr/bin/env ixr, |
| 90 |
|
| 91 |
# allow directory listings (ie 'r' on directories) so browsing via the file |
| 92 |
# dialog works |
| 93 |
/ r, |
| 94 |
/**/ r, |
| 95 |
|
| 96 |
# This is need for saving files in your home directory without an extension. |
| 97 |
# Changing this to '@{HOME}/** r' makes it require an extension and more |
| 98 |
# secure (but with 'rw', we still have abstractions/private-files-strict in |
| 99 |
# effect). |
| 100 |
owner @{HOME}/** rw, |
| 101 |
owner /media/** rw, |
| 102 |
owner @{HOME}/.local/share/gvfs-metadata/** l, |
| 103 |
owner /{,var/}run/user/*/gvfs-metadata/** l, |
| 104 |
|
| 105 |
owner @{HOME}/.gnome2/evince/* rwl, |
| 106 |
owner @{HOME}/.gnome2/accels/ rw, |
| 107 |
owner @{HOME}/.gnome2/accelsevince rw, |
| 108 |
owner @{HOME}/.gnome2/accels/evince rw, |
| 109 |
|
| 110 |
# Maybe add to an abstraction? |
| 111 |
/etc/dconf/** r, |
| 112 |
owner @{HOME}/.cache/dconf/user rw, |
| 113 |
owner @{HOME}/.config/dconf/user r, |
| 114 |
owner @{HOME}/.config/enchant/* rk, |
| 115 |
owner /{,var/}run/user/*/dconf/ w, |
| 116 |
owner /{,var/}run/user/*/dconf/user rw, |
| 117 |
owner /{,var/}run/user/*/dconf-service/keyfile/ w, |
| 118 |
owner /{,var/}run/user/*/dconf-service/keyfile/user rw, |
| 119 |
|
| 120 |
owner /{,var/}run/user/*/at-spi2-*/ rw, |
| 121 |
owner /{,var/}run/user/*/at-spi2-*/** rw, |
| 122 |
|
| 123 |
# Allow access to the non-abstract D-Bus socket used by at-spi > 2.42.0 |
| 124 |
# https://gitlab.gnome.org/GNOME/at-spi2-core/-/issues/43 |
| 125 |
owner /{,var/}run/user/*/at-spi/bus* rw, |
| 126 |
|
| 127 |
# from http://live.gnome.org/Evince/SupportedDocumentFormats. Allow |
| 128 |
# read and write for all supported file formats |
| 129 |
/**.[aA][iI] rw, |
| 130 |
/**.[bB][mM][pP] rw, |
| 131 |
/**.[dD][jJ][vV][uU] rw, |
| 132 |
/**.[dD][vV][iI] rw, |
| 133 |
/**.[gG][iI][fF] rw, |
| 134 |
/**.[jJ][pP][gG] rw, |
| 135 |
/**.[jJ][pP][eE][gG] rw, |
| 136 |
/**.[oO][dD][pP] rw, |
| 137 |
/**.[fFpP][dD][fF] rw, |
| 138 |
/**.[pP][nN][mM] rw, |
| 139 |
/**.[pP][nN][gG] rw, |
| 140 |
/**.[pP][sS] rw, |
| 141 |
/**.[eE][pP][sS] rw, |
| 142 |
/**.[tT][iI][fF] rw, |
| 143 |
/**.[tT][iI][fF][fF] rw, |
| 144 |
/**.[xX][pP][mM] rw, |
| 145 |
/**.[gG][zZ] rw, |
| 146 |
/**.[bB][zZ]2 rw, |
| 147 |
/**.[cC][bB][rRzZ7] rw, |
| 148 |
/**.[xX][zZ] rw, |
| 149 |
|
| 150 |
# evince creates a temporary stream file like '.goutputstream-XXXXXX' in the |
| 151 |
# directory a file is saved. This allows that behavior. |
| 152 |
owner /**/.goutputstream-* w, |
| 153 |
|
| 154 |
# allow evince to spawn browsers distributed as snaps (LP: #1794064) |
| 155 |
/{,snap/core/[0-9]*/,snap/snapd/[0-9]*/}usr/bin/snap mrCx -> snap_browsers, |
| 156 |
} |
| 157 |
|
| 158 |
/usr/bin/evince-previewer { |
| 159 |
include <abstractions/audio> |
| 160 |
include <abstractions/bash> |
| 161 |
include <abstractions/cups-client> |
| 162 |
include <abstractions/dbus-accessibility> |
| 163 |
include <abstractions/evince> |
| 164 |
include <abstractions/ibus> |
| 165 |
include <abstractions/nameservice> |
| 166 |
|
| 167 |
include <abstractions/ubuntu-browsers> |
| 168 |
include <abstractions/ubuntu-console-browsers> |
| 169 |
include <abstractions/ubuntu-email> |
| 170 |
include <abstractions/ubuntu-console-email> |
| 171 |
include <abstractions/ubuntu-media-players> |
| 172 |
|
| 173 |
# For now, let evince talk to any session services over dbus. We can |
| 174 |
# blacklist any problematic ones (but note, evince uses libsecret :\) |
| 175 |
include <abstractions/dbus-session> |
| 176 |
|
| 177 |
include <abstractions/dbus-strict> |
| 178 |
dbus (receive) bus=system, |
| 179 |
# Allow getting information from various system services |
| 180 |
dbus (send) |
| 181 |
bus=system |
| 182 |
member="Get*" |
| 183 |
peer=(label=unconfined), |
| 184 |
# Allow talking to avahi with whatever polkit allows |
| 185 |
dbus (send) |
| 186 |
bus=system |
| 187 |
interface="org.freedesktop.Avahi{,.*}", |
| 188 |
# Allow talking to colord with whatever polkit allows |
| 189 |
dbus (send) |
| 190 |
bus=system |
| 191 |
interface="org.freedesktop.ColorManager{,.*}", |
| 192 |
|
| 193 |
|
| 194 |
# Terminals for using console applications. These abstractions should ideally |
| 195 |
# have 'ix' to restrict access to what only evince is allowed to do |
| 196 |
include <abstractions/ubuntu-gnome-terminal> |
| 197 |
|
| 198 |
# By default, we won't support launching a terminal program in Xterm or |
| 199 |
# KDE's konsole. It opens up too many unnecessary files for most users. |
| 200 |
# People who need this functionality can uncomment the following: |
| 201 |
##include <abstractions/ubuntu-xterm> |
| 202 |
|
| 203 |
/usr/bin/evince-previewer mr, |
| 204 |
/usr/bin/yelp Cx -> sanitized_helper, |
| 205 |
/usr/bin/bug-buddy px, |
| 206 |
|
| 207 |
# Lenient, but remember we still have abstractions/private-files-strict in |
| 208 |
# effect). Write is needed for 'print to file' from the previewer. |
| 209 |
@{HOME}/ r, |
| 210 |
@{HOME}/** rw, |
| 211 |
|
| 212 |
# Maybe add to an abstraction? |
| 213 |
owner /{,var/}run/user/*/dconf/ w, |
| 214 |
owner /{,var/}run/user/*/dconf/user rw, |
| 215 |
} |
| 216 |
|
| 217 |
/usr/bin/evince-thumbnailer { |
| 218 |
include <abstractions/base> |
| 219 |
include <abstractions/private-files-strict> |
| 220 |
|
| 221 |
include <abstractions/fonts> |
| 222 |
deny @{HOME}/.{,cache/}fontconfig/** wl, |
| 223 |
deny @{HOME}/missfont.log wl, |
| 224 |
|
| 225 |
include <abstractions/dbus-session-strict> |
| 226 |
dbus (receive) bus=session, |
| 227 |
dbus (send) |
| 228 |
bus=session |
| 229 |
path="/org/gtk/vfs/mounttracker" |
| 230 |
interface="org.gtk.vfs.MountTracker" |
| 231 |
member="ListMountableInfo" |
| 232 |
peer=(label=unconfined), |
| 233 |
|
| 234 |
# updating gvfs-metadata for thumbnails is unneeded, so explicitly deny it |
| 235 |
deny dbus (send) |
| 236 |
bus=session |
| 237 |
path="/org/gtk/vfs/metadata" |
| 238 |
interface="org.gtk.vfs.Metadata" |
| 239 |
member="GetTreeFromDevice" |
| 240 |
peer=(label=unconfined), |
| 241 |
deny @{HOME}/.local/share/gvfs-metadata/* r, |
| 242 |
|
| 243 |
dbus (send) |
| 244 |
bus=session |
| 245 |
path="/org/gtk/vfs/Daemon" |
| 246 |
interface="org.gtk.vfs.Daemon" |
| 247 |
member="List*" |
| 248 |
peer=(label=unconfined), |
| 249 |
|
| 250 |
# The thumbnailer doesn't need access to everything in the nameservice |
| 251 |
# abstraction. Allow reading of /etc/passwd and /etc/group, but suppress |
| 252 |
# logging denial of nsswitch.conf. |
| 253 |
/etc/passwd r, |
| 254 |
/etc/group r, |
| 255 |
deny /etc/nsswitch.conf r, |
| 256 |
|
| 257 |
# TCP/UDP network access for NFS |
| 258 |
network inet stream, |
| 259 |
network inet6 stream, |
| 260 |
network inet dgram, |
| 261 |
network inet6 dgram, |
| 262 |
|
| 263 |
/etc/papersize r, |
| 264 |
|
| 265 |
/usr/bin/evince-thumbnailer mr, |
| 266 |
|
| 267 |
/etc/texmf/ r, |
| 268 |
/etc/texmf/** r, |
| 269 |
/etc/xpdf/* r, |
| 270 |
|
| 271 |
/usr/bin/gs-esp ixr, |
| 272 |
# Silence these denials since 'no new privs' drops transitions to |
| 273 |
# sanitized_helper, we don't want all those perms in the thumbnailer |
| 274 |
# and the thumbnailer generates thumbnails without these just fine. |
| 275 |
deny /usr/bin/mktexpk x, |
| 276 |
deny /usr/bin/mktextfm x, |
| 277 |
deny /usr/bin/dvipdfm x, |
| 278 |
deny /usr/bin/dvipdfmx x, |
| 279 |
deny /usr/bin/mkofm x, |
| 280 |
|
| 281 |
# supported archivers |
| 282 |
/{usr/,}bin/gzip ixr, |
| 283 |
/{usr/,}bin/bzip2 ixr, |
| 284 |
/usr/bin/unrar* ixr, |
| 285 |
/usr/bin/unzip ixr, |
| 286 |
/usr/bin/7zr ixr, |
| 287 |
/usr/lib/p7zip/7zr ixr, |
| 288 |
/usr/bin/7za ixr, |
| 289 |
/usr/lib/p7zip/7za ixr, |
| 290 |
/usr/bin/zipnote ixr, |
| 291 |
/{usr/,}bin/tar ixr, |
| 292 |
/usr/bin/xz ixr, |
| 293 |
|
| 294 |
# miscellaneous access for the above |
| 295 |
owner @{PROC}/@{pid}/fd/ r, |
| 296 |
owner @{PROC}/@{pid}/mountinfo r, |
| 297 |
/sys/devices/system/cpu/ r, |
| 298 |
|
| 299 |
# allow read access to anything in /usr/share, for plugins and input methods |
| 300 |
/usr/local/share/** r, |
| 301 |
/usr/share/** r, |
| 302 |
/usr/lib/ghostscript/** mr, |
| 303 |
/var/lib/ghostscript/** r, |
| 304 |
/var/lib/texmf/** r, |
| 305 |
|
| 306 |
# from http://live.gnome.org/Evince/SupportedDocumentFormats. Allow |
| 307 |
# read for all supported file formats |
| 308 |
/**.[bB][mM][pP] r, |
| 309 |
/**.[dD][jJ][vV][uU] r, |
| 310 |
/**.[dD][vV][iI] r, |
| 311 |
/**.[gG][iI][fF] r, |
| 312 |
/**.[jJ][pP][gG] r, |
| 313 |
/**.[jJ][pP][eE][gG] r, |
| 314 |
/**.[oO][dD][pP] r, |
| 315 |
/**.[fFpP][dD][fF] r, |
| 316 |
/**.[pP][nN][mM] r, |
| 317 |
/**.[pP][nN][gG] r, |
| 318 |
/**.[pP][sS] r, |
| 319 |
/**.[eE][pP][sS] r, |
| 320 |
/**.[eE][pP][sS][fFiI23] r, |
| 321 |
/**.[tT][iI][fF] r, |
| 322 |
/**.[tT][iI][fF][fF] r, |
| 323 |
/**.[xX][pP][mM] r, |
| 324 |
/**.[gG][zZ] r, |
| 325 |
/**.[bB][zZ]2 r, |
| 326 |
/**.[cC][bB][rRtTzZ7] r, |
| 327 |
/**.[xX][zZ] r, |
| 328 |
|
| 329 |
owner @{HOME}/.texlive*/** r, |
| 330 |
owner @{HOME}/.texmf*/** r, |
| 331 |
owner @{HOME}/.local/share/{,flatpak/exports/share/}mime/** r, |
| 332 |
owner @{HOME}/.local/share/{,flatpak/exports/share/}mime/** r, |
| 333 |
|
| 334 |
# With the network rules above, this allows data exfiltration for files |
| 335 |
# not covered by private-files-strict. |
| 336 |
@{HOME}/ r, |
| 337 |
owner @{HOME}/[^.]** r, |
| 338 |
owner /media/** r, |
| 339 |
|
| 340 |
owner /tmp/.gnome_desktop_thumbnail* w, |
| 341 |
owner /tmp/gnome-desktop-* rw, |
| 342 |
owner /tmp/evince-thumbnailer*/{,**} rw, |
| 343 |
|
| 344 |
# these happen post pivot_root |
| 345 |
/ r, |
| 346 |
deny /missfont.log w, |
| 347 |
|
| 348 |
# Site-specific additions and overrides. See local/README for details. |
| 349 |
include <local/usr.bin.evince> |
| 350 |
} |