File: apparmor-profile

package info (click to toggle)
papers 49.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 21,140 kB
  • sloc: ansic: 37,721; sh: 197; xml: 127; makefile: 112
file content (349 lines) | stat: -rw-r--r-- 11,468 bytes parent folder | download | duplicates (2)
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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
# vim:syntax=apparmor

# papers is not written with application confinement in mind and is designed to
# operate within a trusted desktop session where anything running within the
# user's session is trusted. That said, papers will often process untrusted
# input (PDFs, images, etc). Ideally papers would be written in such a way that
# image processing is separate from the main process and that processing
# happens in a restrictive sandbox, but unfortunately that is not currently the
# case. Because papers will process untrusted input, this profile aims to
# provide some hardening, but considering papers's design and other factors such
# as X, gsettings, accessibility, translations, DBus session and system
# services, etc, complete confinement is not possible.

include <tunables/global>

/usr/bin/papers {
  include <abstractions/audio>
  include <abstractions/bash>
  include <abstractions/cups-client>
  include <abstractions/dbus-accessibility>
  include <abstractions/papers>
  include <abstractions/ibus>
  include <abstractions/nameservice>

  include <abstractions/ubuntu-browsers>
  include <abstractions/ubuntu-console-browsers>
  include <abstractions/ubuntu-email>
  include <abstractions/ubuntu-console-email>
  include <abstractions/ubuntu-media-players>

  # allow papers to spawn browsers distributed as snaps (LP: #1794064)
  include if exists <abstractions/snap_browsers>

  # For now, let papers talk to any session services over dbus. We can
  # blacklist any problematic ones (but note, papers uses libsecret :\)
  include <abstractions/dbus-session>

  include <abstractions/dbus-strict>
  dbus (receive) bus=system,
  # Allow getting information from various system services
  dbus (send)
      bus=system
      member="Get*"
      peer=(label=unconfined),
  # Allow talking to avahi with whatever polkit allows
  dbus (send)
      bus=system
      interface="org.freedesktop.Avahi{,.*}",
  # Allow talking to colord with whatever polkit allows
  dbus (send)
      bus=system
      interface="org.freedesktop.ColorManager{,.*}",

  # Terminals for using console applications. These abstractions should ideally
  # have 'ix' to restrict access to what only papers is allowed to do
  include <abstractions/ubuntu-gnome-terminal>

  # By default, we won't support launching a terminal program in Xterm or
  # KDE's konsole. It opens up too many unnecessary files for most users.
  # People who need this functionality can uncomment the following:
  ##include <abstractions/ubuntu-xterm>
  ##include <abstractions/ubuntu-konsole>

  /usr/bin/papers rmPx,
  /usr/bin/papers-previewer Px,
  /usr/bin/yelp Cx -> sanitized_helper,
  /usr/bin/bug-buddy px,
  # 'Show Containing Folder' (LP: #1022962)
  /usr/bin/nautilus Cx -> sanitized_helper, # Gnome
  /usr/bin/pcmanfm Cx -> sanitized_helper,  # LXDE
  /usr/bin/krusader Cx -> sanitized_helper, # KDE
  /usr/bin/thunar Cx -> sanitized_helper,   # XFCE

  # Print Dialog
  /usr/lib/@{multiarch}/libproxy/*/pxgsettings Cx -> sanitized_helper,

  # For Xubuntu to launch the browser
  include <abstractions/exo-open>

  # For text attachments
  /usr/bin/gedit ixr,

  # For Send to
  /usr/bin/nautilus-sendto Cx -> sanitized_helper,

  # GLib desktop launch helper (used under the hood by g_app_info_launch)
  /usr/lib/@{multiarch}/glib-[0-9]*/gio-launch-desktop rmix,
  /usr/bin/env ixr,

  # allow directory listings (ie 'r' on directories) so browsing via the file
  # dialog works
  / r,
  /**/ r,

  # This is need for saving files in your home directory without an extension.
  # Changing this to '@{HOME}/** r' makes it require an extension and more
  # secure (but with 'rw', we still have abstractions/private-files-strict in
  # effect).
  owner @{HOME}/** rw,
  owner /media/**  rw,
  owner @{HOME}/.local/share/gvfs-metadata/** l,
  owner /{,var/}run/user/*/gvfs-metadata/** l,

  owner @{HOME}/.gnome2/papers/*       rwl,
  owner @{HOME}/.gnome2/accels/        rw,
  owner @{HOME}/.gnome2/accelspapers   rw,
  owner @{HOME}/.gnome2/accels/papers  rw,

  # Maybe add to an abstraction?
  /etc/dconf/**                                       r,
  owner @{HOME}/.cache/dconf/user                     rw,
  owner @{HOME}/.config/dconf/user                    r,
  owner @{HOME}/.config/enchant/*                     rk,
  owner /{,var/}run/user/*/dconf/                     w,
  owner /{,var/}run/user/*/dconf/user                 rw,
  owner /{,var/}run/user/*/dconf-service/keyfile/     w,
  owner /{,var/}run/user/*/dconf-service/keyfile/user rw,

  owner /{,var/}run/user/*/at-spi2-*/   rw,
  owner /{,var/}run/user/*/at-spi2-*/** rw,

  # Allow access to the non-abstract D-Bus socket used by at-spi > 2.42.0
  #   https://gitlab.gnome.org/GNOME/at-spi2-core/-/issues/43
  owner /{,var/}run/user/*/at-spi/bus* rw,

  # from http://live.gnome.org/Evince/SupportedDocumentFormats. Allow
  # read and write for all supported file formats
  /**.[aA][iI]         rw,
  /**.[bB][mM][pP]     rw,
  /**.[dD][jJ][vV][uU] rw,
  /**.[dD][vV][iI]     rw,
  /**.[gG][iI][fF]     rw,
  /**.[jJ][pP][gG]     rw,
  /**.[jJ][pP][eE][gG] rw,
  /**.[oO][dD][pP]     rw,
  /**.[fFpP][dD][fF]   rw,
  /**.[pP][nN][mM]     rw,
  /**.[pP][nN][gG]     rw,
  /**.[pP][sS]         rw,
  /**.[eE][pP][sS]     rw,
  /**.[tT][iI][fF]     rw,
  /**.[tT][iI][fF][fF] rw,
  /**.[xX][pP][mM]     rw,
  /**.[gG][zZ]         rw,
  /**.[bB][zZ]2        rw,
  /**.[cC][bB][rRzZ7]  rw,
  /**.[xX][zZ]         rw,

  # papers creates a temporary stream file like '.goutputstream-XXXXXX' in the
  # directory a file is saved. This allows that behavior.
  owner /**/.goutputstream-* w,

  # allow papers to spawn browsers distributed as snaps (LP: #1794064)
  /{,snap/core/[0-9]*/,snap/snapd/[0-9]*/}usr/bin/snap mrCx -> snap_browsers,
}

/usr/bin/papers-previewer {
  include <abstractions/audio>
  include <abstractions/bash>
  include <abstractions/cups-client>
  include <abstractions/dbus-accessibility>
  include <abstractions/papers>
  include <abstractions/ibus>
  include <abstractions/nameservice>

  include <abstractions/ubuntu-browsers>
  include <abstractions/ubuntu-console-browsers>
  include <abstractions/ubuntu-email>
  include <abstractions/ubuntu-console-email>
  include <abstractions/ubuntu-media-players>

  # For now, let papers talk to any session services over dbus. We can
  # blacklist any problematic ones (but note, papers uses libsecret :\)
  include <abstractions/dbus-session>

  include <abstractions/dbus-strict>
  dbus (receive) bus=system,
  # Allow getting information from various system services
  dbus (send)
      bus=system
      member="Get*"
      peer=(label=unconfined),
  # Allow talking to avahi with whatever polkit allows
  dbus (send)
      bus=system
      interface="org.freedesktop.Avahi{,.*}",
  # Allow talking to colord with whatever polkit allows
  dbus (send)
      bus=system
      interface="org.freedesktop.ColorManager{,.*}",


  # Terminals for using console applications. These abstractions should ideally
  # have 'ix' to restrict access to what only papers is allowed to do
  include <abstractions/ubuntu-gnome-terminal>

  # By default, we won't support launching a terminal program in Xterm or
  # KDE's konsole. It opens up too many unnecessary files for most users.
  # People who need this functionality can uncomment the following:
  #include <abstractions/ubuntu-xterm>

  /usr/bin/papers-previewer mr,
  /usr/bin/yelp Cx -> sanitized_helper,
  /usr/bin/bug-buddy px,

  # Lenient, but remember we still have abstractions/private-files-strict in
  # effect). Write is needed for 'print to file' from the previewer.
  @{HOME}/ r,
  @{HOME}/** rw,

  # Maybe add to an abstraction?
  owner /{,var/}run/user/*/dconf/          w,
  owner /{,var/}run/user/*/dconf/user      rw,
}

/usr/bin/papers-thumbnailer {
  include <abstractions/base>
  include <abstractions/private-files-strict>

  include <abstractions/fonts>
  deny @{HOME}/.{,cache/}fontconfig/** wl,
  deny @{HOME}/missfont.log wl,

  include <abstractions/dbus-session-strict>
  dbus (receive) bus=session,
  dbus (send)
    bus=session
    path="/org/gtk/vfs/mounttracker"
    interface="org.gtk.vfs.MountTracker"
    member="ListMountableInfo"
    peer=(label=unconfined),

  # updating gvfs-metadata for thumbnails is unneeded, so explicitly deny it
  deny dbus (send)
    bus=session
    path="/org/gtk/vfs/metadata"
    interface="org.gtk.vfs.Metadata"
    member="GetTreeFromDevice"
    peer=(label=unconfined),
  deny @{HOME}/.local/share/gvfs-metadata/* r,

  dbus (send)
    bus=session
    path="/org/gtk/vfs/Daemon"
    interface="org.gtk.vfs.Daemon"
    member="List*"
    peer=(label=unconfined),

  # The thumbnailer doesn't need access to everything in the nameservice
  # abstraction. Allow reading of /etc/passwd and /etc/group, but suppress
  # logging denial of nsswitch.conf.
  /etc/passwd r,
  /etc/group r,
  deny /etc/nsswitch.conf r,

  # TCP/UDP network access for NFS
  network inet  stream,
  network inet6 stream,
  network inet  dgram,
  network inet6 dgram,

  /etc/papersize r,

  /usr/bin/papers-thumbnailer mr,

  /etc/texmf/ r,
  /etc/texmf/** r,
  /etc/xpdf/* r,

  /usr/bin/gs-esp ixr,
  # Silence these denials since 'no new privs' drops transitions to
  # sanitized_helper, we don't want all those perms in the thumbnailer
  # and the thumbnailer generates thumbnails without these just fine.
  deny /usr/bin/mktexpk x,
  deny /usr/bin/mktextfm x,
  deny /usr/bin/dvipdfm x,
  deny /usr/bin/dvipdfmx x,
  deny /usr/bin/mkofm x,

  # supported archivers
  /{usr/,}bin/gzip ixr,
  /{usr/,}bin/bzip2 ixr,
  /usr/bin/unrar* ixr,
  /usr/bin/unzip ixr,
  /usr/bin/7zr ixr,
  /usr/lib/p7zip/7zr ixr,
  /usr/bin/7za ixr,
  /usr/lib/p7zip/7za ixr,
  /usr/bin/zipnote ixr,
  /{usr/,}bin/tar ixr,
  /usr/bin/xz ixr,

  # miscellaneous access for the above
  owner @{PROC}/@{pid}/fd/ r,
  owner @{PROC}/@{pid}/mountinfo r,
  /sys/devices/system/cpu/ r,

  # allow read access to anything in /usr/share, for plugins and input methods
  /usr/local/share/** r,
  /usr/share/** r,
  /usr/lib/ghostscript/** mr,
  /var/lib/ghostscript/** r,
  /var/lib/texmf/** r,

  # from http://live.gnome.org/Evince/SupportedDocumentFormats. Allow
  # read for all supported file formats
  /**.[bB][mM][pP]     r,
  /**.[dD][jJ][vV][uU] r,
  /**.[dD][vV][iI]     r,
  /**.[gG][iI][fF]     r,
  /**.[jJ][pP][gG]     r,
  /**.[jJ][pP][eE][gG] r,
  /**.[oO][dD][pP]     r,
  /**.[fFpP][dD][fF]   r,
  /**.[pP][nN][mM]     r,
  /**.[pP][nN][gG]     r,
  /**.[pP][sS]         r,
  /**.[eE][pP][sS]     r,
  /**.[eE][pP][sS][fFiI23] r,
  /**.[tT][iI][fF]     r,
  /**.[tT][iI][fF][fF] r,
  /**.[xX][pP][mM]     r,
  /**.[gG][zZ]         r,
  /**.[bB][zZ]2        r,
  /**.[cC][bB][rRtTzZ7]  r,
  /**.[xX][zZ]         r,

  owner @{HOME}/.texlive*/** r,
  owner @{HOME}/.texmf*/** r,
  owner @{HOME}/.local/share/{,flatpak/exports/share/}mime/** r,
  owner @{HOME}/.local/share/{,flatpak/exports/share/}mime/** r,

  # With the network rules above, this allows data exfiltration for files
  # not covered by private-files-strict.
  @{HOME}/ r,
  owner @{HOME}/[^.]** r,
  owner /media/**  r,

  owner /tmp/.gnome_desktop_thumbnail* w,
  owner /tmp/gnome-desktop-* rw,
  owner /tmp/evince-thumbnailer*/{,**} rw,
  
  # these happen post pivot_root
  / r,
  deny /missfont.log w,

  # Site-specific additions and overrides. See local/README for details.
  include <local/usr.bin.papers>
}