Files
flatpak/common
Alexander Larsson 35598f46a5 extra-data: Don't allow creating files with non-canonical permissions in apply_extra
When installing a flatpak with extra-data we execute the apply_extra
script from the flatpak to extract the extra data files we
created. This script runs with very little filesystem acces, but it
does have write permissions to the location that will eventually be
/app/extra in the finished flatpak. This is especially problematic for
the systemwide install case, because the script is then run as root,
so it could potentially create a setuid file there.

Such a file would not be usable inside the sandbox (because setuid is
disabled in the sandbox), but it could potentially be a problem if the
user could be tricked into running the file directly on the host. This
is the same behaviour as e.g. rpm or deb which both can install setuid
files, but we want to guarantee that flatpak is better than that.

The fix is to run the script with all capabilities dropped (bwrap
--cap-drop ALL) which removes a bunch of possible attack vectors (for
instance setting file capabilities). However, even without
capabilities, it is possible for a user to make any file setuid to the
same user, so we also need to canonicalize the permissions of all
files generated by running the script.

Additionally, while running the script we set the toplevel directory
only be accessible to the user, meaning we will not temporarily leak
any potential setuid files to other users.

Note, this commit actually goes furthen than that and completely
canonicalizes all the file permissions to be the same as those
otherwise used by flatpak. For example we fix up cases where the
script creates files writable or unreadable by non-root users.

Closes: #2323
Approved by: alexlarsson
2018-11-16 10:20:20 +00:00
..
2018-05-24 11:59:52 +00:00
2018-07-08 10:05:37 +00:00
2018-11-10 16:09:47 +00:00
2018-10-02 06:21:49 +00:00
2018-07-08 10:05:37 +00:00
2018-10-02 06:21:49 +00:00
2018-07-08 10:05:37 +00:00
2018-07-08 10:05:37 +00:00
2018-07-08 10:05:37 +00:00
2018-10-02 06:21:49 +00:00
2018-05-24 11:59:52 +00:00
2018-07-08 10:05:37 +00:00
2018-07-08 10:05:37 +00:00
2018-07-08 10:05:37 +00:00
2018-07-08 10:05:37 +00:00
2018-07-08 10:05:37 +00:00
2018-05-24 11:59:52 +00:00
2018-07-08 10:05:37 +00:00
2018-11-15 12:24:00 +00:00
2018-05-24 11:59:52 +00:00
2018-10-08 08:36:23 +00:00
2018-07-08 10:05:37 +00:00