apparmor.d/profiles/google-chrome-chrome
2021-04-01 16:17:47 +01:00

205 lines
6.4 KiB
Text

# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2018-2021 Mikhail Morfikov
# SPDX-License-Identifier: GPL-2.0-only
abi <abi/3.0>,
include <tunables/global>
@{CHROME_INSTALLDIR} = /opt/google/chrome{,-beta,-unstable}
@{CHROME_HOMEDIR} = @{HOME}/.config/google-chrome{,-beta,-unstable}
@{CHROME_CACHEDIR} = @{HOME}/.cache/google-chrome{,-beta,-unstable}
@{exec_path} = @{CHROME_INSTALLDIR}/chrome{,-beta,-unstable}
profile google-chrome-chrome @{exec_path} {
include <abstractions/base>
include <abstractions/opencl-intel>
include <abstractions/gtk>
include <abstractions/freedesktop.org>
include <abstractions/fonts>
include <abstractions/fontconfig-cache-read>
include <abstractions/mesa>
include <abstractions/audio>
include <abstractions/user-download-strict>
include <abstractions/thumbnails-cache-read>
include <abstractions/nameservice-strict>
include <abstractions/ssl_certs>
include <abstractions/deny-root-dir-access>
# The following rules are needed only when the kernel.unprivileged_userns_clone option is set
# to "1".
capability sys_admin,
capability sys_chroot,
owner @{PROC}/@{pid}/setgroups w,
owner @{PROC}/@{pid}/gid_map w,
owner @{PROC}/@{pid}/uid_map w,
ptrace (trace) peer=@{profile_name},
signal (send) set=(term, kill) peer=keepassxc-proxy,
network inet dgram,
network inet6 dgram,
network inet stream,
network inet6 stream,
network netlink raw,
@{exec_path} mrix,
@{CHROME_INSTALLDIR}/{,**} r,
@{CHROME_INSTALLDIR}/chrome-sandbox rPx,
@{CHROME_INSTALLDIR}/google-chrome{,-beta,-unstable} rPx,
@{CHROME_INSTALLDIR}/nacl_helper rix,
@{CHROME_INSTALLDIR}/xdg-mime rix,
@{CHROME_INSTALLDIR}/xdg-settings rix,
# For "google-chrome --help"
/{usr/,}bin/man rPUx,
# For storing passwords externally
/{usr/,}bin/keepassxc-proxy rPUx,
/{usr/,}bin/lsb_release rPx -> child-lsb_release,
/{usr/,}bin/xdg-open rCx -> open,
# no new privs
deny /{usr/,}bin/xdg-desktop-menu rx,
deny /{usr/,}bin/xdg-icon-resource rx,
/{usr/,}bin/xdg-mime rPUx,
/{usr/,}bin/xdg-settings rPUx,
# To remove the following error:
# Error initializing NSS with a persistent database
owner @{HOME}/.pki/ rw,
owner @{HOME}/.pki/nssdb/ rw,
owner @{HOME}/.pki/nssdb/pkcs11.txt rw,
owner @{HOME}/.pki/nssdb/{cert9,key4}.db rwk,
owner @{HOME}/.pki/nssdb/{cert9,key4}.db-journal rw,
# Google Chrome home files
owner @{HOME}/ r,
owner @{CHROME_HOMEDIR}/ rw,
owner @{CHROME_HOMEDIR}/** rwk,
# Flashplayer
owner @{CHROME_HOMEDIR}/PepperFlash/**/libpepflashplayer.so mr,
owner @{HOME}/.local/share/.com.google.Chrome.* rw,
# Cache files
owner @{HOME}/.cache/ rw,
owner @{CHROME_CACHEDIR}/{,**/} rw,
owner @{CHROME_CACHEDIR}/*/**/{*-,}index rw,
owner @{CHROME_CACHEDIR}/*/**/[a-f0-9]*_? rw,
owner @{CHROME_CACHEDIR}/*/**/todelete_* rw,
# To remove browser history/cache
owner @{CHROME_CACHEDIR}/PnaclTranslationCache/index rw,
owner @{CHROME_CACHEDIR}/PnaclTranslationCache/data_[0-9]*[0-9] rw,
# For importing data (bookmarks, cookies, etc) from Firefox
owner @{HOME}/.mozilla/firefox/profiles.ini r,
owner @{HOME}/.mozilla/firefox/*/ r,
owner @{HOME}/.mozilla/firefox/*/compatibility.ini r,
owner @{HOME}/.mozilla/firefox/*/search{,-metadata}.json r,
owner @{HOME}/.mozilla/firefox/*/.parentlock rwk,
owner @{HOME}/.mozilla/firefox/*/{places,cookies,favicons,formhistory,}.sqlite{,-wal,-shm,-journal} rwk,
owner @{HOME}/.mozilla/firefox/*/{cert9,key4}.db rwk,
owner @{HOME}/.mozilla/firefox/*/logins.json r,
# For importing data from Chromium
owner "@{HOME}/.config/chromium/Local State" r,
owner @{HOME}/.config/chromium/Singleton{Lock,Socket,Cookie} w,
owner "@{HOME}/.config/chromium/*/Login Data{,-journal}" rwk,
owner @{HOME}/.config/chromium/*/ r,
owner @{HOME}/.config/chromium/*/{History,Cookies,Favicons,Bookmarks} rwk,
/etc/fstab r,
/usr/share/glib-2.0/schemas/gschemas.compiled r,
# Needed or Google Chrome crash with the following error:
# illegal hardware instruction
@{PROC}/ r,
#
deny @{PROC}/vmstat r,
@{PROC}/sys/kernel/yama/ptrace_scope r,
@{PROC}/@{pid}/fd/ r,
deny @{PROC}/@{pids}/stat r,
deny @{PROC}/@{pids}/statm r,
# To remove the following error:
# Failed to adjust OOM score of renderer with pid : Permission denied
deny owner @{PROC}/@{pid}/oom_{,score_}adj rw,
#
deny @{PROC}/@{pids}/cmdline r,
deny owner @{PROC}/@{pids}/environ r,
owner @{PROC}/@{pid}/task/ r,
deny @{PROC}/@{pids}/task/@{tid}/stat r,
deny @{PROC}/@{pids}/task/@{tid}/status r,
deny owner @{PROC}/@{pid}/limits r,
deny owner @{PROC}/@{pid}/mem r,
owner @{PROC}/@{pid}/mountinfo r,
owner @{PROC}/@{pid}/mounts r,
deny @{PROC}/diskstats r,
owner /dev/shm/.com.google.Chrome.* rw,
# To play DRM media (protected content)
@{CHROME_INSTALLDIR}/libwidevinecdm.so mr,
@{CHROME_INSTALLDIR}/libwidevinecdmadapter.so mr,
/var/lib/dbus/machine-id r,
/etc/machine-id r,
# Udev enumeration
@{sys}/bus/ r,
@{sys}/bus/**/devices/ r,
@{sys}/devices/**/uevent r,
@{sys}/class/ r,
@{sys}/class/**/ r,
@{run}/udev/data/* r,
@{sys}/devices/pci[0-9]*/**/usb[0-9]/{,**/}{descriptors,manufacturer,product,serial,bConfigurationValue} r,
@{sys}/devices/pci[0-9]*/**/usb[0-9]/{,**/}{busnum,devnum} r,
deny @{sys}/devices/virtual/tty/tty[0-9]/active r,
deny @{sys}/devices/system/cpu/cpufreq/policy[0-9]/cpuinfo_max_freq r,
# To remove the following error:
# pcilib: Cannot open /sys/bus/pci/devices/0000:03:00.0/irq: Permission denied
# The irq file is needed to render pages.
@{sys}/devices/pci[0-9]*/**/irq r,
/var/tmp/ r,
/tmp/ r,
owner /tmp/.com.google.Chrome.* rw,
owner /tmp/.com.google.Chrome.*/{,**} rw,
# For installing/updating extensions
owner /tmp/scoped_dir*/{,**} rw,
# Silencer
deny @{CHROME_INSTALLDIR}/** w,
profile open {
include <abstractions/base>
include <abstractions/xdg-open>
/{usr/,}bin/xdg-open mr,
/{usr/,}bin/{,ba,da}sh rix,
/{usr/,}bin/gawk rix,
/{usr/,}bin/readlink rix,
/{usr/,}bin/basename rix,
owner @{HOME}/ r,
owner @{run}/user/[0-9]*/ r,
# Allowed apps to open
# file_inherit
owner @{HOME}/.xsession-errors w,
}
include if exists <local/google-chrome-chrome>
}