Merge lp:~sdeziel/apparmor-profiles/usr.bin.thunderbird-profile into lp:apparmor-profiles

Proposed by Simon Déziel on 2016-01-12
Status: Merged
Merged at revision: 160
Proposed branch: lp:~sdeziel/apparmor-profiles/usr.bin.thunderbird-profile
Merge into: lp:apparmor-profiles
Diff against target: 267 lines (+263/-0)
1 file modified
ubuntu/16.04/usr.bin.thunderbird (+263/-0)
To merge this branch: bzr merge lp:~sdeziel/apparmor-profiles/usr.bin.thunderbird-profile
Reviewer Review Type Date Requested Status
AppArmor Developers 2016-01-12 Pending
Review via email: mp+282383@code.launchpad.net
To post a comment you must log in.
Seth Arnold (seth-arnold) wrote :

Thanks! I have some thoughts inline.

Simon Déziel (sdeziel) wrote :
Download full text (9.2 KiB)

On 2016-01-12 07:35 PM, Seth Arnold wrote:
> Thanks! I have some thoughts inline.

I should have made it explicit that this started as a copy of the
Firefox profile. I tried to kept them relatively in sync.

> Diff comments:
>
>> === added file 'ubuntu/16.04/usr.bin.thunderbird'
>> --- ubuntu/16.04/usr.bin.thunderbird 1970-01-01 00:00:00 +0000
>> +++ ubuntu/16.04/usr.bin.thunderbird 2016-01-12 22:16:34 +0000
>> @@ -0,0 +1,274 @@
>> +# vim:syntax=apparmor
>> +# Author: Simon Deziel <simon.deziel at gmail_com>
>> +# This apparmor profile is provided as-is
>> +
>> +# Declare an apparmor variable to help with overrides
>> +@{MOZ_LIBDIR}=/usr/lib/thunderbird
>> +
>> +#include <tunables/global>
>> +
>> +# We want to confine the binaries that match:
>> +# /usr/lib/thunderbird/thunderbird
>> +# /usr/lib/thunderbird/thunderbird
>> +# but not:
>> +# /usr/lib/thunderbird/thunderbird.sh
>> +/usr/lib/thunderbird/thunderbird{,*[^s][^h]} {
>
> I don't understand what the first two "we want to match" lines mean, they look identical to me no matter how much I squint :) -- but I really dislike this profile name. If the attachment specification has to be this complicated, please give the profile a specific profile name like "thunderbird":

Honestly, I never understood the need for this complicated name.

> profile thunderbird /usr/lib/whatnot { ...
>
> We made the mistake of giving firefox a terrible profile name and it upsets me every time I see it. Maybe we can fix it before 16.04 LTS is released...

That would be great. I will try with TB ASAP.

>> + #include <abstractions/audio>
>> + #include <abstractions/aspell>
>> + #include <abstractions/cups-client>
>> + # TODO: finetune this for required accesses
>> + #include <abstractions/dbus>
>> + #include <abstractions/dbus-accessibility>
>> + #include <abstractions/dbus-session>
>> + #include <abstractions/gnome>
>> + #include <abstractions/ibus>
>> + #include <abstractions/nameservice>
>> + #include <abstractions/p11-kit>
>> + #include <abstractions/private-files>
>> + #include <abstractions/ssl_certs>
>> + #include <abstractions/ubuntu-browsers>
>> + #include <abstractions/ubuntu-helpers>
>> +
>> + # for crash reports?
>> + ptrace (read,trace) peer=/usr/lib/thunderbird/thunderbird{,*[^s][^h]},
>
> This could be peer=@{profile_name}

Good point, should also be replicated in FF's profile.

>> +
>> + # Pulseaudio
>> + /usr/bin/pulseaudio Pixr,
>> +
>> + owner @{HOME}/.{cache,config}/dconf/user rw,
>> + owner /run/user/[0-9]*/dconf/user rw,
>> + owner @{HOME}/.config/gtk-3.0/bookmarks r,
>> + deny owner @{HOME}/.local/share/gvfs-metadata/* r,
>> +
>> + # potentially extremely sensitive files
>> + audit deny @{HOME}/.gnupg/** mrwkl,
>> + audit deny @{HOME}/.ssh/** mrwkl,
>> +
>> + # rw access to HOME is useful when sending/receiving attachments
>> + owner @{HOME}/** rw,
>> +
>> + # Required for LVM setups
>> + /sys/devices/virtual/block/dm-[0-9]*/uevent r,
>> +
>> + # Addons (too lax for thunderbird)
>> + ##include <abstractions/ubuntu-browsers.d/firefox>
>> +
>> + # for networking
>> + network inet stream,
>> + network inet6 stream,
>> + @{PROC}/[0-9]*/net/if_inet6 r,
>> ...

Read more...

157. By Simon Déziel on 2016-01-13

usr.bin.thunderbird: incorporate Seth Arnold's feedback:

- simplify profile name
- use ptrace ... peer=@{profile_name},
- drop unneeded deny rule for failed thumbnails
- prevent gpg1/2 from using hardcoded names under /tmp

Simon Déziel (sdeziel) wrote :

It turned out that gpg2 no longer used /tmp/encfile* so I dropped it for both gpg version. I hope someone can test the older GPG version for me.

When sending an email with an attachment, TB (no GPG involved) creates the following files under /tmp: nscopy.tmp, nsemail.eml and nsmail.tmp. If I pre-create those, TB appends a "-1" before the extension. This seems to be prone to TOCTOU. I haven't check TB's source but maybe they safely create tmp files to have them renamed to something prettier?

158. By Simon Déziel on 2016-01-13

usr.bin.thunderbird: gpg2 needs read access to /tmp/data.sig
for signature verification

159. By Simon Déziel on 2016-01-15

usr.bin.thunderbird: shorthen profile name

160. By Simon Déziel on 2016-02-09

usr.bin.thunderbird: drop unused rules and use owner where appropriate

Also allow rw access to /tmp/encfile that is needed to support PGP inline.

Simon Déziel (sdeziel) wrote :

ping?

161. By Simon Déziel on 2016-04-01

usr.bin.thunderbird: update subprofile for GnuPG 2.1

162. By Simon Déziel on 2016-04-05

usr.bin.thunderbird/gpg2: add rules for dirmngr

Seth Arnold (seth-arnold) wrote :

Hmm, is this still missing? or was it caught in another merge?

Thanks

Simon Déziel (sdeziel) wrote :

It was merged by Steve Beattie already. Thanks for checking.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'ubuntu/16.04/usr.bin.thunderbird'
--- ubuntu/16.04/usr.bin.thunderbird 1970-01-01 00:00:00 +0000
+++ ubuntu/16.04/usr.bin.thunderbird 2016-04-05 20:06:19 +0000
@@ -0,0 +1,263 @@
1# vim:syntax=apparmor
2# Author: Simon Deziel <simon.deziel at gmail_com>
3# This apparmor profile is derived from firefox profile
4# by Jamie Strandboge <jamie@canonical.com>
5
6# Declare an apparmor variable to help with overrides
7@{MOZ_LIBDIR}=/usr/lib/thunderbird
8
9#include <tunables/global>
10
11profile thunderbird /usr/lib/thunderbird/thunderbird {
12 #include <abstractions/audio>
13 #include <abstractions/aspell>
14 #include <abstractions/cups-client>
15 # TODO: finetune this for required accesses
16 #include <abstractions/dbus>
17 #include <abstractions/dbus-accessibility>
18 #include <abstractions/dbus-session>
19 #include <abstractions/gnome>
20 #include <abstractions/ibus>
21 #include <abstractions/nameservice>
22 #include <abstractions/p11-kit>
23 #include <abstractions/private-files>
24 #include <abstractions/ssl_certs>
25 #include <abstractions/ubuntu-browsers>
26 #include <abstractions/ubuntu-helpers>
27
28 # for crash reports?
29 ptrace (read,trace) peer=@{profile_name},
30
31 # Pulseaudio
32 /usr/bin/pulseaudio Pixr,
33
34 owner @{HOME}/.{cache,config}/dconf/user rw,
35 owner /run/user/[0-9]*/dconf/user rw,
36 owner @{HOME}/.config/gtk-3.0/bookmarks r,
37 deny owner @{HOME}/.local/share/gvfs-metadata/* r,
38
39 # potentially extremely sensitive files
40 audit deny @{HOME}/.gnupg/** mrwkl,
41 audit deny @{HOME}/.ssh/** mrwkl,
42
43 # rw access to HOME is useful when sending/receiving attachments
44 owner @{HOME}/** rw,
45
46 # Required for LVM setups
47 /sys/devices/virtual/block/dm-[0-9]*/uevent r,
48
49 # Addons (too lax for thunderbird)
50 ##include <abstractions/ubuntu-browsers.d/firefox>
51
52 # for networking
53 network inet stream,
54 network inet6 stream,
55 @{PROC}/[0-9]*/net/if_inet6 r,
56 @{PROC}/[0-9]*/net/ipv6_route r,
57 @{PROC}/[0-9]*/net/dev r,
58 @{PROC}/[0-9]*/net/wireless r,
59
60 # should maybe be in abstractions
61 /etc/ r,
62 /etc/mime.types r,
63 /etc/mailcap r,
64 /etc/xdg/*buntu/applications/defaults.list r, # for all derivatives
65 /etc/xfce4/defaults.list r,
66 /usr/share/xubuntu/applications/defaults.list r,
67 owner @{HOME}/.local/share/applications/defaults.list r,
68 owner @{HOME}/.local/share/applications/mimeapps.list r,
69 owner @{HOME}/.local/share/applications/mimeinfo.cache r,
70 owner /tmp/** m,
71 owner /var/tmp/** m,
72 /tmp/.X[0-9]*-lock r,
73 /etc/udev/udev.conf r,
74 # Doesn't seem to be required, but noisy. Maybe allow 'r' for 'b*' if needed.
75 # Possibly move to an abstraction if anything else needs it.
76 deny /run/udev/data/** r,
77
78 /etc/timezone r,
79 /etc/wildmidi/wildmidi.cfg r,
80
81 # thunderbird specific
82 /etc/thunderbird/ r,
83 /etc/thunderbird/** r,
84 /etc/xul-ext/** r,
85 /etc/xulrunner-2.0*/ r,
86 /etc/xulrunner-2.0*/** r,
87 /etc/gre.d/ r,
88 /etc/gre.d/* r,
89
90 # noisy
91 deny @{MOZ_LIBDIR}/** w,
92 deny /usr/lib/thunderbird-addons/** w,
93 deny /usr/lib/xulrunner-addons/** w,
94 deny /usr/lib/xulrunner-*/components/*.tmp w,
95 deny /.suspended r,
96 deny /boot/initrd.img* r,
97 deny /boot/vmlinuz* r,
98 deny /var/cache/fontconfig/ w,
99 deny @{HOME}/.local/share/recently-used.xbel r,
100 deny @{HOME}/.* r,
101
102 # TODO: investigate
103 deny /usr/bin/gconftool-2 x,
104
105 owner @{PROC}/[0-9]*/mountinfo r,
106 owner @{PROC}/[0-9]*/stat r,
107 owner @{PROC}/[0-9]*/task/[0-9]*/stat r,
108 /sys/devices/pci[0-9]*/**/uevent r,
109 /etc/mtab r,
110 /etc/fstab r,
111
112 # Needed for the crash reporter
113 owner @{PROC}/[0-9]*/environ r,
114 owner @{PROC}/[0-9]*/auxv r,
115 /etc/lsb-release r,
116 /usr/bin/expr ix,
117 /sys/devices/system/cpu/ r,
118 /sys/devices/system/cpu/** r,
119
120 # about:memory
121 owner @{PROC}/[0-9]*/statm r,
122 owner @{PROC}/[0-9]*/smaps r,
123
124 # Needed for container to work in xul builds
125 /usr/lib/xulrunner-*/plugin-container ixr,
126
127 # allow access to documentation and other files the user may want to look
128 # at in /usr and /opt
129 /usr/ r,
130 /usr/** r,
131 /opt/ r,
132 /opt/** r,
133
134 # so browsing directories works
135 / r,
136 /**/ r,
137
138 # per-user thunderbird configuration
139 owner @{HOME}/.thunderbird/ rw,
140 owner @{HOME}/.thunderbird/** rw,
141 owner @{HOME}/.thunderbird/**/storage.sdb k,
142 owner @{HOME}/.thunderbird/**/*.{db,parentlock,sqlite}* k,
143 owner @{HOME}/.thunderbird/plugins/** rm,
144 owner @{HOME}/.thunderbird/**/plugins/** rm,
145 owner @{HOME}/.cache/thunderbird/ rw,
146 owner @{HOME}/.cache/thunderbird/** rw,
147
148 #
149 # Extensions
150 # /usr/share/.../extensions/... is already covered by '/usr/** r', above.
151 # Allow 'x' for downloaded extensions, but inherit policy for safety
152 owner @{HOME}/.thunderbird/**/extensions/** mixrw,
153 owner @{HOME}/.mozilla/extensions/** mixr,
154 /usr/share/xul-ext/**/*.sqlite rk,
155 /usr/lib/xul-ext/**/*.sqlite rk,
156 /usr/lib/thunderbird-addons/extensions/**/*.sqlite rk,
157
158 deny @{MOZ_LIBDIR}/update.test w,
159 deny /usr/lib/mozilla/extensions/**/ w,
160 deny /usr/lib/xulrunner-addons/extensions/**/ w,
161 deny /usr/share/mozilla/extensions/**/ w,
162 deny /usr/share/mozilla/ w,
163
164 # Miscellaneous (to be abstracted)
165 # Ideally these would use a child profile. They are all ELF executables
166 # so running with 'Ux', while not ideal, is ok because we will at least
167 # benefit from glibc's secure execute.
168 /usr/bin/mkfifo Uxr, # investigate
169 /bin/ps Uxr,
170 /bin/uname Uxr,
171
172 /usr/bin/gpg Cx -> gpg,
173
174 profile gpg {
175 #include <abstractions/base>
176
177 # Required to import keys from keyservers
178 #include <abstractions/nameservice>
179 #include <abstractions/p11-kit>
180
181 # For smartcards?
182 /dev/bus/usb/ r,
183 /dev/bus/usb/[0-9]*/ r,
184 /dev/bus/usb/[0-9]*/[0-9]* r,
185
186 # LDAP key servers
187 /etc/ldap/ldap.conf r,
188
189 /usr/bin/gpg mr,
190 /usr/lib/gnupg/gpgkeys_* ix,
191 owner @{HOME}/.gnupg r,
192 owner @{HOME}/.gnupg/gpg.conf r,
193 owner @{HOME}/.gnupg/random_seed rwk,
194 owner @{HOME}/.gnupg/pubring.gpg{,~} rw,
195 owner @{HOME}/.gnupg/secring.gpg rw,
196 owner @{HOME}/.gnupg/trustdb.gpg rw,
197 owner @{HOME}/.gnupg/*.gpg.{lock,tmp} rwl,
198 owner @{HOME}/.gnupg/.#*[0-9] rw,
199 owner @{HOME}/.gnupg/.#*[0-9]x rwl,
200 owner @{HOME}/** r,
201
202 owner /run/user/[0-9]*/keyring-*/gpg rw,
203
204 # for inline pgp
205 owner /tmp/encfile rw,
206 owner /tmp/encfile-[0-9]* rw,
207 }
208
209 /usr/bin/gpg2 Cx -> gpg2,
210 /usr/bin/gpgconf Cx -> gpg2,
211 /usr/bin/gpg-connect-agent Cx -> gpg2,
212
213 # TB tries to create this file but has no business doing so
214 deny @{HOME}/.gnupg/gpg-agent.conf w,
215
216 profile gpg2 {
217 #include <abstractions/base>
218
219 # Required to import keys from keyservers
220 #include <abstractions/nameservice>
221 #include <abstractions/p11-kit>
222 /usr/lib/gnupg2/gpg2keys_hkp ix,
223
224 # For smartcards?
225 /dev/bus/usb/ r,
226 /dev/bus/usb/[0-9]*/ r,
227 /dev/bus/usb/[0-9]*/[0-9]* r,
228
229 # LDAP key servers
230 /etc/ldap/ldap.conf r,
231
232 /usr/bin/gpg-connect-agent mr,
233 owner @{HOME}/.gnupg/S.gpg-agent rw,
234 owner @{HOME}/.gnupg/S.dirmngr rw,
235
236 /usr/bin/gpg2 mr,
237 owner @{HOME}/.gnupg/ rw,
238 owner @{HOME}/.gnupg/gpg.conf r,
239 owner @{HOME}/.gnupg/random_seed rwk,
240 owner @{HOME}/.gnupg/pubring.gpg{,~} rw,
241 owner @{HOME}/.gnupg/secring.gpg rw,
242 owner @{HOME}/.gnupg/trustdb.gpg rw,
243 owner @{HOME}/.gnupg/*.gpg.{lock,tmp} rwl,
244 owner @{HOME}/.gnupg/.gpg-*.lock rwl,
245 owner @{HOME}/.gnupg/gnupg_spawn_*.lock rwl,
246 owner @{HOME}/.gnupg/.#lk0x[0-9a-f]* rwl,
247 owner @{HOME}/.gnupg/.gpg-v[0-9]*-migrated rw,
248 owner @{HOME}/** r,
249
250 # for inline pgp
251 owner /tmp/encfile rw,
252 owner /tmp/encfile-[0-9]* rw,
253
254 # for signature verifications
255 owner /tmp/data.sig r,
256 owner /tmp/data-[0-9]*.sig r,
257
258 owner /tmp/gpg-[a-zA-Z0-9]*/S.gpg-agent rw,
259 }
260
261 # Site-specific additions and overrides. See local/README for details.
262 #include <local/usr.bin.thunderbird>
263}

Subscribers

People subscribed via source and target branches

to status/vote changes: