Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AppArmor profiles, 2018-01 edition #310

Merged
merged 14 commits into from
Apr 6, 2018

Conversation

intrigeri
Copy link
Collaborator

This branch includes:

Applying this upgrade to a running system requires special care, see the notes to packagers in the commit messages, that should IMO be copied to the release notes.

…tion.

We already allow the main browser profile to do that but with e10s
plugin-container now needs it as well.
…m signals.

With e10s Firefox does not need to ptrace itself anymore but instead it needs
to ptrace and kill its child plugin-container processes.
…ent Firefox process.

We already allow Firefox to send term signals to plugin-container;
this is the receiving counterpart.

This requires giving the Firefox profile a proper name (torbrowser_firefox)
because this:

  signal (receive) set=("term") peer=/home/*/.local/share/torbrowser/tbb/{i686,x86_64}/tor-browser_*/Browser/firefox

… does not work.

Note to package maintainers
===========================

(This should probably be copied to the release notes.)

Due to the profile renaming, upgrading the
/etc/apparmor.d/torbrowser.Browser.firefox file requires special care. The best
option is probably to strongly recommend users to reboot their system after
this upgrade.

Other options I can think of have unacceptable consequences:

 - if we unload the old profile from the kernel, we will leave any already
   running Tor Browser's Firefox executable unconfined, which is an unacceptable
   violation of the user's security expectations;

 - if we don't unload the old profile from the kernel, surprising behaviour will
   happen such as:

    - any already running Tor Browser's Firefox executable will be left confined
      under the old profile which won't play well with new rules that have
      peer=torbrowser_firefox;
    - unpredictable behavior when a new Tor Browser is started, because two
      profiles matching the Tor Browser's Firefox executable are loaded.
So far we allowed it to do everything in there except a link operation, so let's
be consistent.
We don't currently allow access to the audio subsystem; let's not let AppArmor
spam the logs about it.
This will allow us to handle upgrades more nicely in the future,
e.g. when the executable path changes. Besides, this makes the output of
aa-status and logs much easier to grasp.

Note to packagers: exactly as for the similar change applied to the Tor
Browser's Firefox profile, please consider recommending users to reboot their
system after the upgrade that applies this change.
This fixes support for obfs4 and obfs3.

meek and fte require vastly more extended permissions and thus dedicated
child profiles.
This matches how recent dh-apparmor behaves.
@micahflee micahflee changed the base branch from master to develop February 27, 2018 05:26
@ageis
Copy link

ageis commented Mar 10, 2018

just making a note/reminder, I can help test this branch this weekend. @micahflee

@geor-g
Copy link

geor-g commented Mar 17, 2018

@intrigeri Thanks for the work on this! Should this be tested?

@intrigeri
Copy link
Collaborator Author

intrigeri commented Mar 18, 2018 via email

@rogers0
Copy link
Contributor

rogers0 commented Mar 18, 2018

@intrigeri I tried the bridge feature, and yes, obfs4 and obfs3 are working after applying your patches. Thank you!

But meek and fte still got the kernel audit error as below.
Could you kindly help to fix these?
BTW. My testing system is debian stretch.

[1296232.653070] audit: type=1400 audit(1521382524.268:121): apparmor="DENIED" operation="exec" profile="torbrowser_tor" name="~/.local/share/torbrowser/tbb/x86_64/tor-browser_en-US/Browser/firefox" pid=26051 comm="meek-client-tor" requested_mask="x" denied_mask="x" fsuid=1000 ouid=1000
[1296832.242735] audit: type=1400 audit(1521383123.883:123): apparmor="DENIED" operation="exec" profile="torbrowser_tor" name="/usr/bin/python2.7" pid=26535 comm="fteproxy.bin" requested_mask="x" denied_mask="x" fsuid=1000 ouid=0
@intrigeri
Copy link
Collaborator Author

intrigeri commented Mar 18, 2018 via email

@rogers0
Copy link
Contributor

rogers0 commented Mar 18, 2018

@intrigeri sure.
Good to know that you're already aware of this.

support for obfs4 and obfs3

I confirm obfs4 and obfs3 work well after this patchset.
Looking forward to seeing this gets merged.

@micahflee
Copy link
Collaborator

@intrigeri as we discussed, I've just added you as a collaborator and code owner of /apparmor/: 0e9db70

While it's great to have extra code reviews and testing of the AppArmor profiles, I'm happy with you merging them directly into develop if you think they are ready.

@intrigeri
Copy link
Collaborator Author

intrigeri commented Mar 19, 2018 via email

@rogers0
Copy link
Contributor

rogers0 commented Mar 22, 2018

@intrigeri
since the last commit you pushed in this PR

I'm not sure how to add the patch after your commits in this PR.
Maybe it's better to start a new PR, after you merge this series.

@intrigeri
Copy link
Collaborator Author

intrigeri commented Mar 24, 2018 via email

@micahflee micahflee added this to the 0.3 milestone Mar 26, 2018
@micahflee
Copy link
Collaborator

I'm getting ready to make the 0.3.0 release and I'd love to include these updated AppArmor profiles in it. The develop branch has now merged in major-refactor.

@rogers0 @intrigeri would you mind checking to make sure this PR works with what's in develop and let me know, and then I can merge this into develop and make the release?

@rogers0
Copy link
Contributor

rogers0 commented Mar 27, 2018

@intrigeri
please check the log below.
I think the reason is that setup.py simply refuses to copy a null file.

creating <working-dir>/torbrowser-launcher/debian/torbrowser-launcher/etc
creating <working-dir>/torbrowser-launcher/debian/torbrowser-launcher/etc/apparmor.d
copying apparmor/torbrowser.Browser.firefox -> <working-dir>/torbrowser-launcher/debian/torbrowser-launcher/etc/apparmor.d/
copying apparmor/torbrowser.Browser.plugin-container -> <working-dir>/torbrowser-launcher/debian/torbrowser-launcher/etc/apparmor.d/
copying apparmor/torbrowser.Tor.tor -> <working-dir>/torbrowser-launcher/debian/torbrowser-launcher/etc/apparmor.d/
creating <working-dir>/torbrowser-launcher/debian/torbrowser-launcher/etc/apparmor.d/local
error: can't copy 'apparmor/local/torbrowser.Browser.firefox': doesn't exist or not a regular file

@micahflee thanks! I'll let you know when I finish.

@intrigeri
Copy link
Collaborator Author

I think the reason is that setup.py simply refuses to copy a null file.

@rogers0 actually when that failure happens the source file does not exist so setup.py cannot copy it. That's because the patch format we use does not allow expressing the distinction between emptying a file and deleting it so when debian/patches/0015-AppArmor-remove-boilerplate-from-local-override-file.patch is applied, those files are deleted. So once that patch makes it into an upstream release and the corresponding quilt patch gets removed, it won't cause a FTBFS anymore => case closed. But still, even then I think we'll want to keep debian/patches/0016-Remove-apparmor-local-path-from-setup.py.patch (albeit with an updated description): let's not treat these local overrides as conffiles and instead let dh-apparmor manage them.

@intrigeri
Copy link
Collaborator Author

intrigeri commented Mar 29, 2018 via email

@intrigeri intrigeri merged commit 8a76256 into torproject:develop Apr 6, 2018
@intrigeri intrigeri deleted the apparmor-201801-edition branch April 6, 2018 07:05
@micahflee
Copy link
Collaborator

Thanks for the merge @intrigeri :)

intrigeri added a commit to intrigeri/torbrowser-launcher that referenced this pull request Sep 19, 2018
… to silence logs.

We already allow the main browser profile to do that but with e10s
plugin-container now needs it as well.

This backports part of commit cdb290f
from torproject#310.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants