Whonix AppArmor Profiles Development Discussion

Went through and ran the TBB profile and got this:

[quote]
root@host:/home/user# sudo apparmor_parser -r /etc/apparmor.d/home.user.tor-browser_en-US.Browser.firefox
AppArmor parser error for /etc/apparmor.d/home.user.tor-browser_en-US.Browser.firefox in /etc/apparmor.d/home.user.tor-browser_en-US.Browser.firefox at line 12: Could not open ‘abstractions/whonix’
[/quote]

Most likely, you have not installed the file “abstractions/whonix”. See http://kkkkkkkkkk63ava6.onion/wiki/AppArmor/abstractions/whonix

I’ll update the profiles pages with a warning. Also, for the TBB downloads/uploads and the attachments in Icedove, you have to create the ~/Downloads directory.

@Patrick: If we choose Downloads (that can be any directory), could that be included in the next update, when the profiles are packaged.

What about my /** /etc/apparmor.d/whonix idea? (Whonix Forum)

~/Downloads folder:
I deleted my ~/Downloads and tested to create it using Tor Browser. Got some denied messages.

Apr  6 14:49:40 host kernel: [63623.752679] type=1400 audit(1396795780.127:50): apparmor="DENIED" operation="open" parent=1 profile="/home/user/tor-browser_en-US/Browser/firefox" name="/home/user/Desktop/" pid=7951 comm="pool" requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000

This is probably because ~/Desktop is the first folder Tor Browser is looking into when ~/Downloads does not exist.

Apr  6 14:49:55 host kernel: [63639.616848] type=1400 audit(1396795795.987:51): apparmor="DENIED" operation="mkdir" parent=1 profile="/home/user/tor-browser_en-US/Browser/firefox" name="/home/user/Downloads/" pid=5672 comm="firefox" requested_mask="c" denied_mask="c" fsuid=1000 ouid=1000

This is probably because the profile does not allow “mkdir ~/Downloads”. I guess adding the “c” flag should do the trick?

you have to create the ~/Downloads directory.
@Patrick: If we choose Downloads (that can be any directory), could that be included in the next update, when the profiles are packaged.
For next Whonix version the /home/user/Downloads folder could be created by default. Not in a AppArmor profile (to keep them generic), but in a Whonix specific postinst script. If that makes sense I go ahead and implement it?
What about my /** /etc/apparmor.d/whonix idea? (https://www.whonix.org/forum/index.php/topic,97.msg1370.html#msg1370)

It’s in the pipeline. Before re-testing, I just want to make sure my backup is 99% proof.

~/Downloads folder: I deleted my ~/Downloads and tested to create it using Tor Browser. Got some denied messages.
Apr  6 14:49:40 host kernel: [63623.752679] type=1400 audit(1396795780.127:50): apparmor="DENIED" operation="open" parent=1 profile="/home/user/tor-browser_en-US/Browser/firefox" name="/home/user/Desktop/" pid=7951 comm="pool" requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000

This is probably because ~/Desktop is the first folder Tor Browser is looking into when ~/Downloads does not exist.

If the “~/Downloads” folder does not exist (and even if it exists), trying anywhere else will flash a message. If you try “File system”, you get “name=”/" pid=xxxx comm=“open” requested_mask=“r” denied_mask=“r”“. To get rid of the message, I would have to give read access to the whole disk (”/** r,").

[code] Apr 6 14:49:55 host kernel: [63639.616848] type=1400 audit(1396795795.987:51): apparmor="DENIED" operation="mkdir" parent=1 profile="/home/user/tor-browser_en-US/Browser/firefox" name="/home/user/Downloads/" pid=5672 comm="firefox" requested_mask="c" denied_mask="c" fsuid=1000 ouid=1000 [/code] This is probably because the profile does not allow "mkdir ~/Downloads". I guess adding the "c" flag should do the trick?

I am not sure I understand. Did you create a folder from the Tor browser? Anyhow, you can create any folder under ~/Downloads, from a terminal or the file manager, and save the downloads there.

or next Whonix version the /home/user/Downloads folder could be created by default. Not in a AppArmor profile (to keep them generic), but in a Whonix specific postinst script. If that makes sense I go ahead and implement it?

It would be OK to create the folder by default. And then recommend the user to set “Save files to → Downloads” in the Tor browser “Edit/Preferences/General” dialog box. That might save some hassle.

It's in the pipeline. Before re-testing, I just want to make sure my backup is 99% proof.
Awesome!
I am not sure I understand. Did you create a folder from the Tor browser?
Yes.
Anyhow, you can create any folder under ~/Downloads, from a terminal or the file manager, and save the downloads there.
Giving mkdir ~/Downloads permissin Tor Browser shouldn't hurt anyway?
It would be OK to create the folder by default. And then recommend the user to set "Save files to -> Downloads" in the Tor browser "Edit/Preferences/General" dialog box. That might save some hassle.
Ideally it would be best if all that would be possible without editing any prefs.
To get rid of the message, I would have to give read access to the whole disk ("/** r,").

“/** r” would be too much. Then the browser could read and leak any file on hdd. What about just “/ r”? Doing an “ls /” doesn’t leak anything useful.

Having apparmor-notifier flashing by default is bad, this would produce loads of bug reports. Not having apparmor-notifier installed on the other hand is also no good idea. There might be dysfunctional features without any indication what is going wrong.

I guess Ubuntu “solved” this by giving full read access to /home. Seems like there is no great solution.

Alright TBB profile works and no errors. Troubador, I think you should add the whoni/abstractions commands to the apparmor page on the clearnet too, so everything is available in one place. Will Whonix ship with a ~/Downloads folder to make the apparmor profile apply seamlessly?

There is no such thing as clearnet version.
cleanet wiki version = .onion wiki version
.onion is just a different domain for our server.

I think we agreed on that. But it will probably never work seamlessly due to technical challenges, unless well, I am not even sure what kind of feature request against AppArmor could be made. Eventually one against Firefox.

Troubador if you know how to add or activate apparmor profiles on a Debian Host, please post that here so I can add it to the KVM page.

Normally, Debian should come with AppArmor enabled. They ship some default profiles from their own.

For your profiles, put them in ‘/etc/apparmor.d’. For each profile, run

sudo apparmor_parser -r /etc/apparmor.d/profile_name

Check ‘/etc/default/grub’. In GRUB_CMDLINE_LINUX_DEFAULT or GRUB_CMDLINE_LINUX, it should read “security=apparmor apparmor=1”. If not. add it, the order does not matter, and run ‘update-grub’.

All the profiles in etc/apparmor.d, if they are not in the disable folder, are loaded at boot.

When using Whonix in Debian, the first package to confine with AppArmor should be VirtualBox: AppArmor. So we (should) have all the network facing packages in whonix apparmored, the virtualization layer with VirtualBox, and the hypervisor itself apparmored.

About KVM, according to Ubuntu where most of the AppArmor work is done, the profiles for libvirt are now part of the source packages. See Ubuntu – Error. From my experience, the profiles are seldom usable out of the box, but that might be worth having a look.

I have updated the TBB profile.

"/** r" would be too much. Then the browser could read and leak any file on hdd. What about just "/ r"? Doing an "ls /" doesn't leak anything useful.

Added “deny / r,”. That does the job, the access is refused without apparmor message. Fine for me.

[quote]Anyhow, you can create any folder under ~/Downloads, from a terminal or the file manager, and save the downloads there.[/quote] Giving mkdir ~/Downloads permissin Tor Browser shouldn't hurt anyway?

~/Downloads has read/write access already. Allowed /usr/bin/mkdir.

[quote] It would be OK to create the folder by default. And then recommend the user to set "Save files to -> Downloads" in the Tor browser "Edit/Preferences/General" dialog box. That might save some hassle.[/quote] Ideally it would be best if all that would be possible without editing any prefs.

Yes, it would be best, but i am facing a problem. I cannot know what the user has in the home folder, so clicking anywhere but the chosen downloads folder in the profile will flash a message. I don’t see a way around that.

I think we agreed on that. But it will probably never work seamlessly due to technical challenges, unless well, I am not even sure what kind of feature request against AppArmor could be made. Eventually one against Firefox.

Firefox is the most likely candidate.
I have added an abstraction (will probably add more) to make the profiles more readable for the maintainers. Also trying to deny access to the files that do not seem necessary to the good functioning of the packages. I put them at the beginning of the profile, for readability too.

All the profiles using X will follow on the same line.

I forgot to mention that I had another unrecoverable problem with a snapshot. I don’t remember exactly the sequence of events that led to the situation, but anyhow, I think It would be best to recommend against using them now. My [.vbox .vmdk ~/.VirtualBox] backup was unusable after the crash.

With latest TBB profile, I still get this message when trying to create the Downloads folder.

Done. Removed it everywhere in the wiki. Removed it from VirtualBox’s VM import text. (Will appear in Whonix [correction] 8.2…)

This bug can really be a pain.

Updated the Icedove profile.

A few lines added, especially for GPG key management (“/usr/lib/gnupg/* rix,”).

Got a new denied message.

[quote=“Patrick, post:144, topic:108”][quote author=troubadour link=topic=97.msg1586#msg1586 date=1397252181]
I forgot to mention that I had another unrecoverable problem with a snapshot. I don’t remember exactly the sequence of events that led to the situation, but anyhow, I think It would be best to recommend against using them now. My [.vbox .vmdk ~/.VirtualBox] backup was unusable after the crash.
[/quote]
Done. Removed it everywhere in the wiki. Removed it from VirtualBox’s VM import text. (Will appear in Whonix 8.2. + 1.)

This bug can really be a pain.[/quote]
Correction 8.2.

Got a new denied message. [code]apparmor="DENIED" operation="open" parent=1 profile="/home/user/tor-browser_en-US/Browser/firefox" name="/etc/group" pid=31425 comm=4D6564696120417564696F requested_mask="r" denied_mask="r" fsuid=1000 ouid=0[/code]

Fixed (with deny).

Added two abastractions (freedesktop.org and user-download) in Tor Browser, Icedove and Pidgin. The profiles look more standardized.

In Pidgin, removed some abstractions and fixed the “Network rules not enforced” message printed when replacing the profile with apparmor_parser.

I am still wary about testing the “/* {…}” profile to replace abstractions/whonix, but it will happen, eventually. In the meantime, more to come toward standardization. and a couple of other things, the help menu in Pidgin and Xchat amongst them.

Good changes. Testing the new profiles.

There are a few Pidgin related denied messages, but those happened with the old as well as with the new profile. Those lead to Pidgin crashing, not finishing startup and exiting.

Apr 15 14:42:34 host kernel: [69482.609494] type=1400 audit(1397572954.020:91): apparmor="DENIED" operation="open" parent=5282 profile="/usr/bin/pidgin" name="/home/user/.config/oxygen-gtk/argb-apps.conf" pid=31142 comm="pidgin" requested_mask="ac" denied_mask="ac" fsuid=1000 ouid=1000
Apr 15 14:42:34 host kernel: [69482.609557] type=1400 audit(1397572954.020:92): apparmor="DENIED" operation="open" parent=5282 profile="/usr/bin/pidgin" name="/home/user/.config/oxygen-gtk/argb-apps.conf" pid=31142 comm="pidgin" requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000
Apr 15 14:42:34 host kernel: [69482.610650] type=1400 audit(1397572954.020:93): apparmor="DENIED" operation="exec" parent=31142 profile="/usr/bin/pidgin" name="/usr/bin/kde4-config" pid=31144 comm="pidgin" requested_mask="x" denied_mask="x" fsuid=1000 ouid=0
Apr 15 14:42:34 host kernel: [69482.629475] type=1400 audit(1397572954.040:94): apparmor="DENIED" operation="exec" parent=31142 profile="/usr/bin/pidgin" name="/usr/bin/kde4-config" pid=31145 comm="pidgin" requested_mask="x" denied_mask="x" fsuid=1000 ouid=0
Apr 15 14:42:34 host kernel: [69482.778195] type=1400 audit(1397572954.188:95): apparmor="DENIED" operation="open" parent=5282 profile="/usr/bin/pidgin" name="/usr/share/fontconfig/conf.avail/10-scale-bitmap-fonts.conf" pid=31142 comm="pidgin" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
Apr 15 14:42:34 host kernel: [69482.778502] type=1400 audit(1397572954.188:96): apparmor="DENIED" operation="open" parent=5282 profile="/usr/bin/pidgin" name="/usr/share/fontconfig/conf.avail/20-unhint-small-vera.conf" pid=31142 comm="pidgin" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
Apr 15 14:42:34 host kernel: [69482.778515] type=1400 audit(1397572954.188:97): apparmor="DENIED" operation="open" parent=5282 profile="/usr/bin/pidgin" name="/usr/share/fontconfig/conf.avail/30-metric-aliases.conf" pid=31142 comm="pidgin" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
Apr 15 14:42:34 host kernel: [69482.778531] type=1400 audit(1397572954.188:98): apparmor="DENIED" operation="open" parent=5282 profile="/usr/bin/pidgin" name="/usr/share/fontconfig/conf.avail/30-urw-aliases.conf" pid=31142 comm="pidgin" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
Apr 15 14:42:34 host kernel: [69482.778545] type=1400 audit(1397572954.188:99): apparmor="DENIED" operation="open" parent=5282 profile="/usr/bin/pidgin" name="/usr/share/fontconfig/conf.avail/40-nonlatin.conf" pid=31142 comm="pidgin" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
Apr 15 14:42:34 host kernel: [69482.778556] type=1400 audit(1397572954.188:100): apparmor="DENIED" operation="open" parent=5282 profile="/usr/bin/pidgin" name="/usr/share/fontconfig/conf.avail/45-latin.conf" pid=31142 comm="pidgin" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0

The Pidgin profile is updated. The usr/share/fontconfig/ and /home/user/.config/oxygen-gtk/ folders are not in my workstation. I 'll put them as default in a local profile for all the packages using an interactive GUI.

I am trying to build the apparmor-profile-torbrowser package. I have some problems and I might need some frequent help there, at least at he beginning.

After installing git, I run

user@host:~$ git clone https://github.com/Whonix/apparmor-profile-torbrowser

then

user@host:~$ cd apparmor-profile-torbrowser
user@host:~/apparmor-profile-torbrowser$./build

First the debuild command was not found. After some research, I installed pbuilder. OK.

Now, the output of debuild:

+ debuild --rootcmd=debian/gain-root-command -sa
 dpkg-buildpackage -rdebian/gain-root-command -D -us -uc -sa
dpkg-buildpackage: source package apparmor-profile-torbrowser
dpkg-buildpackage: source version 0.1-1
dpkg-buildpackage: source changed by Patrick Schleizer <adrelanos@riseup.net>
 dpkg-source --before-build apparmor-profile-torbrowser
dpkg-buildpackage: host architecture i386
dpkg-checkbuilddeps: Unmet build dependencies: dh-apparmor
dpkg-buildpackage: warning: build dependencies/conflicts unsatisfied; aborting
dpkg-buildpackage: warning: (Use -d flag to override.)
debuild: fatal error at line 1357:
dpkg-buildpackage -rdebian/gain-root-command -D -us -uc -sa failed
+ '[' '!' 29 = 0 ']'
+ exit 1