interfaces: misc updates for network-control, firewall-control, unity7 and default policy #2842

Merged
merged 6 commits into from Feb 16, 2017

Conversation

Projects
None yet
5 participants
Contributor

jdstrand commented Feb 13, 2017

  • interfaces/network-control,firewall-control: allow reading module parameters (LP: #1662662)
  • interfaces/unity7: allow registering interest in media keys (LP: #1663565)
  • interfaces: allow /run/user/..., not /dev/user/...

jdstrand added some commits Feb 13, 2017

interfaces/unity7,x11: allow 'network netlink raw' (LP: #1663221)
Unfortunately 'network netlink raw' isn't finely mediated, but since this only
happens on X, adding this rule to the transitional unity7 and x11 interfaces
should be fine. Justification: DAC offers some protections for netlink raw on
the system, most applications using X/unity7 run as non-root, X is insecure so
blocking this particular rule needed by Qt on X is arguably specious, and
breaking out 'netlink raw' into an interface isn't very interesting because it
is entirely too general.
interfaces: allow /run/user/..., not /dev/user/...
When adding the XDG_RUNTIME_DIR path, an alternation of /{dev,run}/user/...
was used for the rule, but /dev/user isn't a thing, so only allow /run/user....

zyga approved these changes Feb 13, 2017

Question and LGTM. Is opening netlink safe? I assume you know what you are doing and that the kernel does smart things (e.g. provides some access control) but can a snap using netlink and running as root do some "damage" (or just be nasty in some way?)

Contributor

jdstrand commented Feb 14, 2017

@zyga - this was covered in the comment:

Unfortunately 'network netlink raw' isn't finely mediated, but since this only
happens on X, adding this rule to the transitional unity7 and x11 interfaces
should be fine. Justification: DAC offers some protections for netlink raw on
the system, most applications using X/unity7 run as non-root, X is insecure so
blocking this particular rule needed by Qt on X is arguably specious, and
breaking out 'netlink raw' into an interface isn't very interesting because it
is entirely too general.

I don't like this rule at all but it is difficult to see an alternative. Mir doesn't need it, and it is required by all ubuntu-ui-toolkit apps to find the keyboard and mouse on systems with X. We could say 'no' to this rule, but that would break app development where people want to have their app work on unity7/x11 and unity8/mir. I found it hard to justify saying 'no' to this rule when X/unity7 are auto-connected already and have gaping security holes.

The only alternative I see is to tell the SDK team to change the toolkit to not talk to udev directly and instead talk to a trusted DBus service that can inform the app where the keyboard and mouse are. Then unity7 is adjusted to allow talking to that service. @tsdgeos - can you comment?

@tyhicks - thoughts?

UPDATE: to answer your question, 'yes, allowing root to use netlink raw would allow root to do bad things'. I forgot to mention that because specifying unity7 or x11 with 'daemon' isn't expected to work anyway, I was going to add a check to the review tools that would flag for human review when doing that. This should mitigate this somewhat.

It did occur to me that I could investigate how Qt is calling socket and use seccomp arg filtering in the x11 and unity7 interfaces to have:

socket AF_NETLINK SOCK_RAW NETLINK_<something for just this access>

I'll look into that.

Contributor

tyhicks commented Feb 14, 2017

@jdstrand until we know what netlink family (see the netlink(7) man page) is required, it is hard to understand what kind of attack surface full netlink access provides. I think the proposed seccomp rule can greatly narrow the scope and is something that we should pursue.

Once we know the netlink family used, we can trace the kernel code for that family to get a better idea about how dangerous this is.

tsdgeos commented Feb 14, 2017

FWIW as I commented in https://bugs.launchpad.net/snapd/+bug/1663221 ubuntu-ui-toolkit is not talking to udev directly but via QInputInfoManager (in QtSystems).

About if ubuntu-ui-toolkit would be able to stop using QInputInfoManager and using some other dbus service, i don't know, i'm not really part of the ubuntu-ui-toolkit developers (just do some minor stuff), you'd have to ask them, but given that dbus service doesn't exist (as far as i know) seems a theoretical discussion and not an actual fix for this problem.

About how dangeroues this is, maybe it can be restricted to allow only protocol NETLINK_KOBJECT_UEVENT ? Not sure if that helps at all or not.

jdstrand added some commits Feb 14, 2017

@jdstrand jdstrand changed the title from interfaces: misc updates for network-control, firewall-control, unity7, x11 and default policy to interfaces: misc updates for network-control, firewall-control, unity7 and default policy Feb 14, 2017

Contributor

jdstrand commented Feb 14, 2017

I removed the netlink raw rule from this PR as the merge window is closing and if implemented, we'll need seccomp arg filtering to implement it and that is blocked on #2810.

zyga approved these changes Feb 14, 2017

LGTM

Contributor

jdstrand commented Feb 15, 2017

@mvo5 - can you consider this for 2.23?

@mvo5 mvo5 added this to the 2.23 milestone Feb 16, 2017

mvo5 approved these changes Feb 16, 2017

@@ -433,6 +433,20 @@ dbus (receive)
member="{GetAll,GetLayout}"
peer=(label=unconfined),
+# Allow requesting interest in receiving media key events. This tells Gnome
@mvo5

mvo5 Feb 16, 2017

Collaborator

❤️

@mvo5 mvo5 merged commit 5e5fde0 into snapcore:master Feb 16, 2017

6 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
xenial-amd64 autopkgtest finished (success)
Details
xenial-i386 autopkgtest finished (success)
Details
xenial-ppc64el autopkgtest finished (success)
Details
yakkety-amd64 autopkgtest finished (success)
Details
zesty-amd64 autopkgtest finished (success)
Details
Contributor

jdstrand commented Feb 16, 2017

Thanks for the review!

@jdstrand jdstrand deleted the jdstrand:policy-updates-xix branch Feb 27, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment