torbrowser-AppArmor-profile.patch 10.4 KB
Newer Older
1 2
diff --git a/etc/apparmor.d/torbrowser.Browser.firefox b/etc/apparmor.d/torbrowser.Browser.firefox
index d0aded9..3be3872 100644
3 4
--- a/etc/apparmor.d/torbrowser.Browser.firefox
+++ b/etc/apparmor.d/torbrowser.Browser.firefox
5
@@ -1,10 +1,11 @@
6
 #include <tunables/global>
7
 #include <tunables/torbrowser>
8
 
9 10 11 12
-@{torbrowser_firefox_executable} = /home/*/.local/share/torbrowser/tbb/{i686,x86_64}/tor-browser_*/Browser/firefox
+@{torbrowser_firefox_executable} = /usr/local/lib/tor-browser/firefox
 
 profile torbrowser_firefox @{torbrowser_firefox_executable} {
13 14 15 16 17
   #include <abstractions/gnome>
+  #include <abstractions/ibus>
 
   # Uncomment the following lines if you want to give the Tor Browser read-write
   # access to most of your personal files.
18
@@ -25,13 +26,16 @@
19 20
   deny /etc/passwd r,
   deny /etc/group r,
21 22 23 24
   deny /etc/mailcap r,
+  deny @{HOME}/.local/share/gvfs-metadata/home r,
+  deny /run/resolvconf/resolv.conf r,
 
25 26 27 28 29
-  deny /etc/machine-id r,
-  deny /var/lib/dbus/machine-id r,
+  /etc/machine-id r,
+  /var/lib/dbus/machine-id r,
 
30 31 32
   /dev/ r,
   /dev/shm/ r,
 
33
+  owner @{PROC}/@{pid}/environ r,
34
   owner @{PROC}/@{pid}/fd/ r,
35 36
   owner @{PROC}/@{pid}/mountinfo r,
   owner @{PROC}/@{pid}/stat r,
37
@@ -39,30 +43,32 @@
38
   owner @{PROC}/@{pid}/task/*/stat r,
39 40
   @{PROC}/sys/kernel/random/uuid r,
 
41 42 43 44 45 46 47 48 49 50
-  owner @{torbrowser_installation_dir}/ r,
-  owner @{torbrowser_installation_dir}/* r,
-  owner @{torbrowser_installation_dir}/.** rwk,
-  owner @{torbrowser_installation_dir}/update.test/ rwk,
-  owner @{torbrowser_home_dir}/.** rwk,
-  owner @{torbrowser_home_dir}/ rw,
-  owner @{torbrowser_home_dir}/** rwk,
-  owner @{torbrowser_home_dir}.bak/ rwk,
-  owner @{torbrowser_home_dir}.bak/** rwk,
-  owner @{torbrowser_home_dir}/*.so mr,
51 52
-  owner @{torbrowser_home_dir}/.cache/fontconfig/ rwk,
-  owner @{torbrowser_home_dir}/.cache/fontconfig/** rwkl,
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
-  owner @{torbrowser_home_dir}/components/*.so mr,
-  owner @{torbrowser_home_dir}/browser/components/*.so mr,
-  owner @{torbrowser_home_dir}/firefox rix,
-  owner @{torbrowser_home_dir}/plugin-container px -> torbrowser_plugin_container,
-  owner @{torbrowser_home_dir}/{,TorBrowser/UpdateInfo/}updates/[0-9]*/updater ix,
-  owner @{torbrowser_home_dir}/{,TorBrowser/UpdateInfo/}updates/0/MozUpdater/bgupdate/updater ix,
-  owner @{torbrowser_home_dir}/TorBrowser/Data/Browser/profiles.ini r,
-  owner @{torbrowser_home_dir}/TorBrowser/Data/Browser/profile.default/ r,
-  owner @{torbrowser_home_dir}/TorBrowser/Tor/tor px,
-  owner @{torbrowser_home_dir}/TorBrowser/Tor/ r,
-  owner @{torbrowser_home_dir}/TorBrowser/Tor/*.so mr,
-  owner @{torbrowser_home_dir}/TorBrowser/Tor/*.so.* mr,
+  @{torbrowser_home_dir}/ r,
+  @{torbrowser_home_dir}/** mr,
+  @{torbrowser_home_dir}/plugin-container px -> torbrowser_plugin_container,
68
+
69 70
+  owner "@{HOME}/Tor Browser/" rw,
+  owner "@{HOME}/Tor Browser/**" rwk,
71 72
+  owner "@{HOME}/Persistent/Tor Browser/" rw,
+  owner "@{HOME}/Persistent/Tor Browser/**" rwk,
73 74
+  owner "/live/persistence/TailsData_unlocked/Persistent/Tor Browser/" rw,
+  owner "/live/persistence/TailsData_unlocked/Persistent/Tor Browser/**" rwk,
75
+  owner @{HOME}/.mozilla/firefox/bookmarks/ rwk,
76
+  owner @{HOME}/.mozilla/firefox/bookmarks/** rwk,
77
+  owner /live/persistence/TailsData_unlocked/bookmarks/ rwk,
78
+  owner /live/persistence/TailsData_unlocked/bookmarks/** rwk,
79 80 81 82 83 84 85
+  owner @{HOME}/.tor-browser/profile.default/ r,
+  owner @{HOME}/.tor-browser/profile.default/** rwk,
+
+  /etc/xul-ext/ r,
+  /etc/xul-ext/** r,
+  /usr/local/share/tor-browser-extensions/ r,
+  /usr/local/share/tor-browser-extensions/** rk,
86 87
+  /usr/share/{xul-,web}ext/ r,
+  /usr/share/{xul-,web}ext/** r,
88 89 90 91 92 93
+
+  /usr/share/doc/tails/website/ r,
+  /usr/share/doc/tails/website/** r,
 
   /etc/mailcap r,
   /etc/mime.types r,
94 95 96 97 98 99 100 101 102
@@ -70,6 +76,7 @@
   /usr/share/ r,
   /usr/share/mime/ r,
   /usr/share/themes/ r,
+  /usr/share/glib-2.0/schemas/gschemas.compiled r,
   /usr/share/applications/** rk,
   /usr/share/gnome/applications/ r,
   /usr/share/gnome/applications/kde4/ r,
@@ -85,12 +92,6 @@
103 104
   /sys/devices/system/node/node[0-9]*/meminfo r,
   deny /sys/devices/virtual/block/*/uevent r,
105
 
106 107 108 109 110 111 112 113 114
-  # Should use abstractions/gstreamer instead once merged upstream
-  /etc/udev/udev.conf r,
-  /run/udev/data/+pci:* r,
-  /sys/devices/pci[0-9]*/**/uevent r,
-  owner /{dev,run}/shm/shmfd-* rw,
-
   # Required for multiprocess Firefox (aka Electrolysis, i.e. e10s)
   owner /{dev,run}/shm/org.chromium.* rw,
 
115
@@ -104,6 +105,32 @@
116 117 118
   deny @{HOME}/.cache/fontconfig/** rw,
   deny @{HOME}/.config/gtk-2.0/ rw,
   deny @{HOME}/.config/gtk-2.0/** rw,
119
+  deny @{HOME}/.mozilla/firefox/bookmarks/ r,
120 121 122
+  deny @{PROC}/@{pid}/net/route r,
+  deny /sys/devices/system/cpu/cpufreq/policy[0-9]*/cpuinfo_max_freq r,
+  deny /sys/devices/system/cpu/*/cache/index[0-9]*/size r,
123 124 125
+  deny /usr/local/lib/tor-browser/TorBrowser/UpdateInfo/ rw,
+  deny /usr/local/lib/tor-browser/update.test/ rw,
+
126
+  /usr/local/lib/tor-browser/firefox Pix,
127
+
128 129 130 131 132 133
+  # Grant access to assistive technologies
+  # (otherwise, Firefox crashes when Orca is enabled:
+  # https://labs.riseup.net/code/issues/9261)
+  owner @{HOME}/.cache/at-spi2-*/ rw,
+  owner @{HOME}/.cache/at-spi2-*/socket rw,
+
134 135 136 137
+  # Spell checking (the "enchant" abstraction includes these rules
+  # too, but it allows way more stuff than what we need)
+  /usr/share/hunspell/                             r,
+  /usr/share/hunspell/*                            r,
138 139 140 141
+
+  # Deny access to the list of recently used files. This overrides the
+  # access to it that's granted by the freedesktop.org abstraction.
+  deny @{HOME}/.local/share/recently-used.xbel* rw,
142 143 144 145 146 147
+
+  # Silence denial logs about permissions we don't need
+  deny /dev/dri/   rwklx,
   deny @{PROC}/@{pid}/net/route r,
   deny /sys/devices/system/cpu/cpufreq/policy[0-9]*/cpuinfo_max_freq r,
   deny /sys/devices/system/cpu/*/cache/index[0-9]*/size r,
148
@@ -119,5 +146,10 @@
149 150
   /etc/xfce4/defaults.list r,
   /usr/share/xfce4/applications/ r,
151 152
 
-  #include <local/torbrowser.Browser.firefox>
153 154 155 156 157 158 159
+  # Deny access to global tmp directories, that's granted by the user-tmp
+  # abstraction, which is sourced by the gnome abstraction, that we include.
+  deny owner /var/tmp/**     rwklx,
+  deny /var/tmp/             rwklx,
+  deny owner /tmp/**         rwklx,
+  deny /tmp/                 rwklx,
 }
160 161
diff --git a/etc/apparmor.d/torbrowser.Browser.plugin-container b/etc/apparmor.d/torbrowser.Browser.plugin-container
index fe95fdb..7ebf9d6 100644
162 163
--- a/etc/apparmor.d/torbrowser.Browser.plugin-container
+++ b/etc/apparmor.d/torbrowser.Browser.plugin-container
164 165 166 167
@@ -10,9 +10,9 @@ profile torbrowser_plugin_container {
   #  - the "deny" word in the machine-id lines
   #  - the rules that deny reading /etc/pulse/client.conf
   #    and executing /usr/bin/pulseaudio
168 169 170 171 172 173 174
-  # #include <abstractions/audio>
-  # /etc/asound.conf r,
-  # owner @{torbrowser_home_dir}/TorBrowser/Data/Browser/profile.default/tmp/mozilla-temp-* rw,
+  #include <abstractions/audio>
+  /etc/asound.conf r,
+  owner @{HOME}/.tor-browser/profile.default/tmp/mozilla-temp-* rw,
 
175 176 177
   signal (receive) set=("term") peer=torbrowser_firefox,
 
@@ -24,8 +24,8 @@ profile torbrowser_plugin_container {
178 179 180 181 182 183 184 185
   deny /etc/group r,
   deny /etc/mailcap r,
 
-  deny /etc/machine-id r,
-  deny /var/lib/dbus/machine-id r,
+  /etc/machine-id r,
+  /var/lib/dbus/machine-id r,
 
186 187 188
   /etc/mime.types r,
   /usr/share/applications/gnome-mimeapps.list r,
@@ -39,28 +39,27 @@ profile torbrowser_plugin_container {
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
   owner @{PROC}/@{pid}/task/*/stat r,
   @{PROC}/sys/kernel/random/uuid r,
 
-  owner @{torbrowser_home_dir}/*.dat r,
-  owner @{torbrowser_home_dir}/*.manifest r,
-  owner @{torbrowser_home_dir}/*.so mr,
-  owner @{torbrowser_home_dir}/.cache/fontconfig/   rw,
-  owner @{torbrowser_home_dir}/.cache/fontconfig/** rw,
-  owner @{torbrowser_home_dir}/browser/** r,
-  owner @{torbrowser_home_dir}/components/*.so mr,
-  owner @{torbrowser_home_dir}/browser/components/*.so mr,
-  owner @{torbrowser_home_dir}/defaults/pref/     r,
-  owner @{torbrowser_home_dir}/defaults/pref/*.js r,
-  owner @{torbrowser_home_dir}/fonts/   r,
-  owner @{torbrowser_home_dir}/fonts/** r,
-  owner @{torbrowser_home_dir}/omni.ja r,
-  owner @{torbrowser_home_dir}/plugin-container ixmr,
-  owner @{torbrowser_home_dir}/TorBrowser/Data/Browser/profile.default/extensions/*.xpi r,
-  owner @{torbrowser_home_dir}/TorBrowser/Data/Browser/profile.default/tmp/* rw,
-  owner @{torbrowser_home_dir}/TorBrowser/Data/fontconfig/fonts.conf r,
-  owner @{torbrowser_home_dir}/TorBrowser/Tor/ r,
-  owner @{torbrowser_home_dir}/TorBrowser/Tor/*.so mr,
-  owner @{torbrowser_home_dir}/TorBrowser/Tor/*.so.* mr,
-  owner @{torbrowser_home_dir}/Downloads/ rwk,
-  owner @{torbrowser_home_dir}/Downloads/** rwk,
+  @{torbrowser_home_dir}/ r,
+  @{torbrowser_home_dir}/** mr,
+  @{torbrowser_home_dir}/plugin-container ixmr,
+
+  owner @{HOME}/.tor-browser/profile.default/tmp/* rw,
+
+  owner "@{HOME}/Tor Browser/" rw,
+  owner "@{HOME}/Tor Browser/**" rwk,
+  owner "@{HOME}/Persistent/Tor Browser/" rw,
+  owner "@{HOME}/Persistent/Tor Browser/**" rwk,
+
225
+  owner @{HOME}/.tor-browser/profile.default/extensions/*.xpi r,
226 227 228 229 230 231 232 233 234 235 236 237
+  /etc/xul-ext/ r,
+  /etc/xul-ext/** r,
+  /usr/local/share/tor-browser-extensions/ r,
+  /usr/local/share/tor-browser-extensions/** rk,
+  /usr/share/xul-ext/ r,
+  /usr/share/xul-ext/** r,
+
+  /usr/share/doc/tails/website/ r,
+  /usr/share/doc/tails/website/** r,
 
   /sys/devices/system/cpu/ r,
   /sys/devices/system/cpu/present r,
238
@@ -86,10 +85,16 @@ profile torbrowser_plugin_container {
239
   deny @{PROC}/@{pid}/net/route r,
240 241
   deny /sys/devices/system/cpu/cpufreq/policy[0-9]*/cpuinfo_max_freq r,
   deny /sys/devices/system/cpu/*/cache/index[0-9]*/size r,
242
+  deny @{HOME}/.cache/fontconfig/ w,
243
 
244 245 246 247
   # Silence denial logs about PulseAudio
   deny /etc/pulse/client.conf r,
   deny /usr/bin/pulseaudio x,
 
248 249 250 251 252 253 254 255
-  #include <local/torbrowser.Browser.plugin-container>
+  # Deny access to global tmp directories, that's granted by the user-tmp
+  # abstraction, which is sourced by the gnome abstraction, that we include.
+  deny owner /var/tmp/**     rwklx,
+  deny /var/tmp/             rwklx,
+  deny owner /tmp/**         rwklx,
+  deny /tmp/                 rwklx,
 }
256 257
diff --git a/etc/apparmor.d/tunables/torbrowser b/etc/apparmor.d/tunables/torbrowser
index 9b31139..f77e082 100644
258 259 260 261 262 263
--- a/etc/apparmor.d/tunables/torbrowser
+++ b/etc/apparmor.d/tunables/torbrowser
@@ -1,2 +1 @@
-@{torbrowser_installation_dir}=@{HOME}/.local/share/torbrowser/tbb/{i686,x86_64}/tor-browser_*
-@{torbrowser_home_dir}=@{torbrowser_installation_dir}/Browser
+@{torbrowser_home_dir}=/usr/local/lib/tor-browser