AppArmor no longer mediates access to path-based AF_UNIX socket files
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
AppArmor |
Fix Released
|
High
|
John Johansen | ||
apparmor (Ubuntu) |
Fix Released
|
Critical
|
Tyler Hicks | ||
Saucy |
Fix Released
|
Critical
|
Tyler Hicks | ||
apparmor-easyprof-ubuntu (Ubuntu) |
Fix Released
|
Critical
|
Jamie Strandboge | ||
Saucy |
Fix Released
|
Critical
|
Jamie Strandboge | ||
firefox (Ubuntu) |
Fix Released
|
Medium
|
Jamie Strandboge | ||
Saucy |
Fix Released
|
Medium
|
Jamie Strandboge | ||
linux (Ubuntu) |
Fix Released
|
High
|
John Johansen | ||
linux-grouper (Ubuntu) |
Fix Released
|
High
|
John Johansen | ||
linux-maguro (Ubuntu) |
Fix Released
|
High
|
John Johansen | ||
linux-mako (Ubuntu) |
Fix Released
|
High
|
John Johansen | ||
linux-manta (Ubuntu) |
Fix Released
|
High
|
John Johansen |
Bug Description
[Impact]
* AppArmor removed unix domain socket mediation as part of the 2.4 (karmic) rewrite to the security_path hooks so that it could be upstreamed into the main kernel. The result being apparmor no longer mediates access to AF_UNIX socket files. Or more specifically it does not mediation connections between sockets, creation of a socket within the filesystem is mediated
* Confined applications can currently read from and write to any AF_UNIX
socket files
* Existing AppArmor profiles that contain file rules granting write access to
AF_UNIX socket files are effectively being ignored
* The move from the vfs hooks patches (old, out-of-tree) AppArmor and the security_path hooks
apparmor incorporated into mainline in 2.6.36 were the cause of this regression.
apparmor 2.4 (version in karmic) also removed other features are part of the rewrite to
security_path hooks/upstreaming effort.
* For Ubuntu, Karmic 9.10 and all newer, releases are affected.
8.04 LTS used the vfs patches and was not affected.
* Mediation of unix domain filesystem based sockets is needed for 13.10 click apps confinement
[Test Case]
* Confining dbus-send and sending a message to the system bus is an easy
manual testing method. Load a profile for dbus-send:
$ cat << EOF | sudo apparmor_parser -r
#include <tunables/global>
/usr/bin/dbus-send {
#include <abstractions/base>
/usr/
# /var/run/
}
EOF
* Note that the system_bus_socket rule is commented out. Now, run dbus-send
under strace and see if the connect() fails. Here's the unexpected output,
taken from an Ubuntu Saucy system:
$ strace -e connect -- \
dbus-send --system --dest=
/org/freedeskt
connect(3, {sa_family=
+++ exited with 0 +++
* Here's the expected output, taken from an 8.04 LTS system:
$ strace -e connect -- \
dbus-send --system --dest=
/org/freedeskt
connect(3, {sa_family=AF_FILE, path="/
Failed to open connection to system message bus: Failed to connect to socket /var/run/
* Or, you can apply the AppArmor regression test suite patch attached to this
bug and run the automated tests:
$ cd tests/regressio
$ make unix_fd_
$ sudo bash unix_fd_server.sh
$ sudo bash unix_socket_file.sh
[Regression Potential]
* Profiles developed with affected kernels aren't likely to have the necessary
rules because the proper LSM hook was not implemented in those kernels, so
the policy writer didn't need to grant access to AF_UNIX socket files
* The profiles shipped with AppArmor can, and will, be updated to grant access
to AF_UNIX socket files, but local policy modifications cannot be addressed
by upstream/distros. Once updated kernels begin enforcing mediation of
AF_UNIX socket files, rules in local profiles may no longer be sufficient,
resulting in new AppArmor denials for AF_UNIX socket files.
Changed in apparmor (Ubuntu Saucy): | |
importance: | Undecided → Critical |
status: | New → In Progress |
Changed in apparmor-easyprof-ubuntu (Ubuntu Saucy): | |
importance: | Undecided → Critical |
Changed in apparmor (Ubuntu Saucy): | |
assignee: | nobody → Tyler Hicks (tyhicks) |
Changed in apparmor-easyprof-ubuntu (Ubuntu Saucy): | |
assignee: | nobody → Jamie Strandboge (jdstrand) |
status: | New → Triaged |
status: | Triaged → In Progress |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
information type: | Private Security → Public Security |
no longer affects: | evince (Ubuntu) |
no longer affects: | evince (Ubuntu Saucy) |
Changed in firefox (Ubuntu Saucy): | |
status: | New → Triaged |
importance: | Undecided → Medium |
tags: | added: application-confinement |
Changed in linux-grouper (Ubuntu): | |
assignee: | nobody → John Johansen (jjohansen) |
status: | New → Fix Committed |
Changed in linux-maguro (Ubuntu): | |
assignee: | nobody → John Johansen (jjohansen) |
status: | New → Fix Committed |
Changed in linux-mako (Ubuntu): | |
assignee: | nobody → John Johansen (jjohansen) |
status: | New → Fix Committed |
Changed in linux-manta (Ubuntu): | |
assignee: | nobody → John Johansen (jjohansen) |
status: | New → Fix Committed |
Changed in linux (Ubuntu): | |
assignee: | nobody → John Johansen (jjohansen) |
status: | Incomplete → Fix Committed |
Changed in linux (Ubuntu): | |
importance: | Undecided → High |
Changed in linux-grouper (Ubuntu): | |
importance: | Undecided → High |
Changed in linux-maguro (Ubuntu): | |
importance: | Undecided → High |
Changed in linux-mako (Ubuntu): | |
importance: | Undecided → High |
Changed in linux-manta (Ubuntu): | |
importance: | Undecided → High |
Changed in apparmor (Ubuntu Saucy): | |
status: | In Progress → Fix Committed |
Changed in firefox (Ubuntu Saucy): | |
milestone: | none → saucy-updates |
status: | Triaged → Fix Committed |
assignee: | nobody → Jamie Strandboge (jdstrand) |
Back in the days of AppArmor living out-of-tree, it implemented the inode_permission LSM hook. In the upstreamed version of AppArmor, the inode_permission hook is not implemented. That's why mediation occurred back then but not now.
Back then, nameidata was passed to inode_permission, which allowed AppArmor to get to the dentry and vfsmount. Today, nameidata is gone and only the inode is available in inode_permission, making it difficult to simply reintroduce apparmor_ inode_permissio n().
The unix_stream_connect LSM hook may be viable. Using the sock, we could do something similar to unix_getname() to get a buffer containing the path. However, John says that the path may not be valid for the current namespace.