Apparmor denial for access to SNAP_APP_USER_DATA_PATH as root
| Affects | Status | Importance | Assigned to | Milestone | |
|---|---|---|---|---|---|
| | Snappy |
Critical
|
Unassigned | ||
| | ubuntu-core-security (Ubuntu) |
Critical
|
Jamie Strandboge | ||
Bug Description
So apparently in current snappy, root has less rights than random joe.
That should be fixed.
21:31 < stgraber> [94170.804198] audit: type=1400 audit(143457656
21:32 < jdstrand> stgraber: oh, that is because we are using @{HOMEDIRS}/*/ instead of @{HOME}. @{HOMEDIRS}/*/ does not include /root.
| Jamie Strandboge (jdstrand) wrote : | #1 |
| Changed in ubuntu-core-security (Ubuntu): | |
| status: | New → Incomplete |
| Ted Gould (ted) wrote : | #2 |
It kinda seems to me like SNAP_APP_
| Changed in snappy: | |
| status: | New → Triaged |
| importance: | Undecided → Critical |
| Jamie Strandboge (jdstrand) wrote : | #3 |
This bug affects usability. If you install a snap and run one of its binaries with 'sudo foo.bar' then /home/ubuntu/apps gets created as root and subsequent commands run as non-root will fail to create their user data directories. I like ted's reasoning but ultimately I don't think we shouldn't second guess the application. There is precedent for this all over the place with (OTOH) ssh, gpg and openssl all creating their dot files/directories under /root when they are run as root.
If the application is intentionally using SNAP_APP_
Adding tasks for those (which we can remove later if others think something else should be done).
| Jamie Strandboge (jdstrand) wrote : | #4 |
Actually, the bug description shows that lxd *did* get a directory under /root, but latest stable does not do that.
$ sudo rm -rf /home/ubuntu/apps
$ sudo hello-world.env
$ sudo ls -ld /home/ubuntu/apps
drwxr-xr-x 3 root root 4096 Oct 1 08:18 /home/ubuntu/apps
So something may have changed with the launcher since this bug was originally filed (or lxd was trying to work around it).
| John Lenton (chipaca) wrote : | #5 |
I think the least surprising thing to do would be to use /root/apps/
| Jamie Strandboge (jdstrand) wrote : | #6 |
This came up in the context of another conversation, but then we discussed it. The security team reexamined the current behavior and don't like that SNAP_APP_
Since it seems a few things have changed since this bug was filed, I'll restate the current situation:
* /apps/bin/... wrappers are setting export SNAP_APP_
* /apps/bin/... wrappers mkdir SNAP_APP_
* systemd services use SNAP_APP_
* /root is currently included in /etc/system-
* the apparmor policy does not allow writes to /root/apps/...
Observations:
1. /apps/bin/... wrappers correctly set SNAP_APP_
2. /apps/bin/... wrappers mkdir SNAP_APP_
3. /apps/bin/... wrappers when run under sudo set SNAP_APP_
4. the apparmor policy currently doesn't work with the systemd unit (this bug)
In comment #1 I asked for more information on why we didn't want to use /root/apps/... when run as root, but didn't get a response. It's possible at the time the security policy was written I was instructed to not allow it since /root wasn't writable, but it is now. I also addressed Ted's concern in comment #
In an effort to prod this bug along, I suggest that we clean up all of this with the following:
Proposal #1:
1. continue to have /apps/bin/... wrappers correctly set SNAP_APP_
2. adjust /apps/bin/... wrappers to set SNAP_APP_
3. adjust the apparmor policy accordingly
4. adjust snappy to handle /root in the same manner as /home/$user wrt rollbacks and upgrades.
I suspect rollbacks and upgrades to be the point of contention with this proposal.
Proposal #2:
1. continue to have /apps/bin/... wrappers correctly set SNAP_APP_
2. adjust /apps/bin/... wrappers to set SNAP_APP_
3. adjust the systemd unit to set SNAP_APP_
This introduces the least amount of change to snappy but might be confusing to developers expecting S...
| Gustavo Niemeyer (niemeyer) wrote : | #7 |
There seems to be two related but independent problems here.
The first one is the original problem reported in the description above: the snap user directory is inaccessible to the snap itself. This should indeed be fixed, and there's apparently no reason for us to move this data out of $HOME that is set for uid=0 (proposal #2), as that's what we have for every other user.
The second problem is that sudo works as it usually does, with some of the environment from the calling user. The answer to this one feels slightly less obvious, but I'm tempted to suggest following the usual route of setting the data path to the effective user id, to avoid this sort of ownership problem. Unfortunately, this also implies that applications will no longer run with the context of the calling user under sudo, and I'm not sure of the implications that this will unfold at this point, but perhaps it's okay to try and see.
| Jamie Strandboge (jdstrand) wrote : | #8 |
Thanks Gustavo. We discussed this a little bit more on irc and agree that proposal #1 is the way to go for now. If we need to refine that in the future we can.
| Changed in ubuntu-core-security (Ubuntu): | |
| status: | Incomplete → Triaged |
| assignee: | nobody → Jamie Strandboge (jdstrand) |
| Jamie Strandboge (jdstrand) wrote : | #9 |
ubuntu-
| Changed in ubuntu-core-security (Ubuntu): | |
| status: | Triaged → Fix Committed |
| Jamie Strandboge (jdstrand) wrote : | #10 |
Marking the ubuntu-
| Changed in ubuntu-core-launcher (Ubuntu): | |
| status: | New → Invalid |
| Changed in ubuntu-snappy (Ubuntu): | |
| status: | New → Triaged |
| Changed in ubuntu-core-security (Ubuntu): | |
| importance: | Undecided → Critical |
| Changed in ubuntu-snappy (Ubuntu): | |
| importance: | Undecided → Critical |
| Jamie Strandboge (jdstrand) wrote : | #11 |
Adding ubuntu-snappy task since it needs to be modified for proposal #1. Triaging to the level of the Snappy project task.
| Launchpad Janitor (janitor) wrote : | #12 |
This bug was fixed in the package ubuntu-
---------------
ubuntu-
* ubuntu/default: allow owner match on @{HOME} instead of @{HOMEDIRS}/*/
to allow root access to SNAP_APP_
'/root/
-- Jamie Strandboge <email address hidden> Tue, 01 Dec 2015 13:43:20 -0600
| Changed in ubuntu-core-security (Ubuntu): | |
| status: | Fix Committed → Fix Released |
| Kyle Fazzari (kyrofa) wrote : | #13 |
Any update here?
| Kyle Fazzari (kyrofa) wrote : | #14 |
Bugfix here: https:/
| Changed in snappy: | |
| status: | Triaged → In Progress |
| assignee: | nobody → Kyle Fazzari (kyrofa) |
| Changed in snappy: | |
| status: | In Progress → Confirmed |
| assignee: | Kyle Fazzari (kyrofa) → nobody |
| Michael Vogt (mvo) wrote : | #15 |
root@localhost:
Launching a shell inside the default app confinement. Navigate to your
app-specific directories with:
This works now in snappy 16:
bash-4.3# cd $SNAP_USER_DATA
bash-4.3# pwd
/root/snap/
bash-4.3# touch lala
bash-4.3# ls
lala
| Changed in snappy: | |
| status: | Confirmed → Fix Released |
| Changed in ubuntu-snappy (Ubuntu): | |
| status: | Triaged → Fix Released |
| no longer affects: | ubuntu-core-launcher (Ubuntu) |
| no longer affects: | ubuntu-snappy (Ubuntu) |


This is an easy fix policy-wise. Ie, change all occurrences of '@{HOMEDIRS}/*/' to '@{HOME}/' in the policy. However, we actively decided that '/root' would not be included in the default policy, and I'd like to understand why. Is this for the FHS? How does this affect rollbacks? Is /root handled in the same manner as /home?