Commit Graph

6443 Commits

Author SHA1 Message Date
Simon McVittie
ed91bba615 Revert "Make --nofilesystem=host/home remove access to subdirs of those"
This caused regressions for some previously-working use cases. For
example, some Flatpak users previously used a global
`flatpak override --nofilesystem=home` or
`flatpak override --nofilesystem=host`, but expected that individual apps
would still be able to have finer-grained filesystem access granted by the
app manifest, such as Zoom's `--filesystem=~/Documents/Zoom:create`. With
the changes in 1.12.3, this no longer has the desired result, because
`--nofilesystem=home` was special-cased to disallow inheriting the
finer-grained `--filesystem`.

This reverts commit 445bddeee6.

This reverts the initial solution to CVE-2022-21682, which we intend to
resolve differently, by introducing a new feature in Flatpak and making
use of it in a new flatpak-builder version.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 917a7f5870)
2022-01-18 16:36:16 +00:00
Simon McVittie
da5ae83cfa Revert "manpages: Document the new details of --nofilesystem behaviour."
The new behaviour caused regressions in some situations that previously
worked, and will be reverted.

This reverts commit 4d11f77aa7.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit dfe868d628)
2022-01-18 16:36:16 +00:00
Simon McVittie
97dd26c02e test-override: Assert that unimplemented suffix is ignored with a warning
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 8a44df04c8)
2022-01-18 01:18:08 +00:00
Simon McVittie
74f02d1e95 test-override: Assert that only the expected term is negated
We weren't distinguishing here between overrides that should have been
negated (xdg-documents) and overrides that should not have been negated
(everything else).

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 4e3d1d8b7b)
2022-01-18 01:18:08 +00:00
Phaedrus Leeds
1dbc175314 Update variant-schema-compiler to fix build
This works with newer versions of pyparsing, while producing generated
files common/flatpak-variant{,-impl}-private.h identical to those produced
by the old variant-schema-compiler when using the pyparsing versions in
Debian 10 and Debian 11. Backporting this commit allows older branches
to be CI-tested successfully.

Fixes https://github.com/flatpak/flatpak/issues/4534

(cherry picked from commit 6cb4a2598e)
(cherry picked from commit a0d8a1dcf3)
[smcv: verified that this has no effect with older pyparsing versions]
2022-01-17 18:49:10 +00:00
Simon McVittie
eb324b9d82 test-metadata-validation.sh: Ensure that mtimes change between iterations
Our old adversary, 1-second timestamp resolution, strikes again!

Signed-off-by: Simon McVittie <smcv@debian.org>
2022-01-12 13:58:17 -08:00
Alexander Larsson
17cc9937ca Update pofiles for release 1.10.6 2022-01-12 15:37:16 +01:00
Alexander Larsson
1fc1c031df Bump version to 1.10.6 2022-01-12 15:08:49 +01:00
Alexander Larsson
8270f8c639 Update NEWS for release 2022-01-12 15:07:09 +01:00
Alexander Larsson
0ceb8eb9ec manpages: Document the new details of --nofilesystem behaviour.
(cherry picked from commit da3e12b319094158c2afa3df380bc45a7626928c)
2022-01-12 14:54:45 +01:00
Alexander Larsson
307ee18dd6 Make --nofilesystem=host/home remove access to subdirs of those
Previously --nofilesystem=host only removed specifically access to the
`host` permissions, and not necessarily other filesystems (like `home`
or `/some/path`). This isn't very useful to limit access because you
don't know what other filesystems the app may have access too.

We change this to mean that `--nofilesystem=host` removes *all* filesystem
access from the parent layer, and `--nofilesystem=home` removes all
file access to the homedir and paths inside it.

The available layers are, in order:

 * app permissions
 * overrides
 * commandline args

This allows you to start from scratch with the filesystem permissions
in the overrides or the commandline. This is a small change in
behaviour, but not a lot of things use --nofilesystem, and the ones
that do probably expects this behaviour.

(cherry picked from commit e2c8863fb62301cb05c64bbb32b04446e88ce11a)
2022-01-12 14:54:40 +01:00
Phaedrus Leeds
ce0bb56c6f Add test for metadata validation
This tests for invalid metadata, missing xa.metadata and mismatched
values in xa.metadata and the real metadata, including the embedded
null leading to the hidden permissions of CVE-2021-43860.

(cherry picked from commit 2c2ce58c54b3e6c62f9c21c15efa0ba22f4bc09b)
2022-01-12 14:53:57 +01:00
Alexander Larsson
574cb11372 Ensure that bundles have metadata on install
If we have a bundle without metadata we wouldn't properly present
the permissions in the transaction.

(cherry picked from commit b250541302187ff2209b0bb1295e8223d0af860f)
2022-01-12 14:53:50 +01:00
Alexander Larsson
bd6948c375 Require metadata in commit also for OCI remotes
This was disables a long time ago because the fedora remotes didn't
contain metadata, but that has been added since then. Requiring fixes
a security concern where an app claims to require no permissions (by
having no metadata in commit) but then actually requires permissions
in the installed app.

(cherry picked from commit f0f3a35f404b5bd533186095db055f8b3d135576)
2022-01-12 14:53:26 +01:00
Alexander Larsson
10367bd7d2 Transaction: Fail the resolve if xa.metadata invalid or missing
If we fail to parse xa.metadata from the summary cache or the commit
xa.metadata we fail the resolve.

If xa.metadata is missing in the commit we fail the resolve (it is
always set in the summary cache, because summary update converts
missing xa.metadata to "", so we either get that, or cache miss which
leads to resolving from the commit.

This means that op->resolved_metadata is always set during install and
updates, which means we will show the app permissions. The transaction
will also always make sure that this data actually matches what gets
deployed.

Before this change an invalid metadata in the summary cache could lead
to a NULL resolved_metadata, which means we wouldn't print the app
permissions, yet we would still deploy some metadata file that could
have permissions. (NOTE: It would fail to deploy unless the
xa.metadata in the commit matched the metadata file, but in this
corner case we would't compare the summary and commit metadata, so
they may differ.)

(cherry picked from commit 5036bca4214d5b77e884dec42e36496a06e74081)
2022-01-12 14:51:10 +01:00
Ryan Gonzalez
3c3dc554e7 Fix metadata file contents after null terminators being ignored
In particular, if a null terminator is placed inside the metadata file,
Flatpak will only compare the text *before* it to the value of
xa.metadata, but the full file will be parsed when permissions are set
at runtime. This means that any app can include a null terminator in its
permissions metadata, and Flatpak will only show the user the
permissions *preceding* the terminator during install, but the
permissions *after* the terminator are applied at runtime.

Fixes GHSA-qpjc-vq3c-572j / CVE-2021-43860

Signed-off-by: Ryan Gonzalez <ryan.gonzalez@collabora.com>
(cherry picked from commit c9c3a667c09a846c0b230cf1cc8ed330028aa03c)
2022-01-12 14:07:46 +01:00
Phaedrus Leeds
23ce2b1bc6 NEWS: Fix typo in 1.10.4 notes 2021-10-12 20:43:39 +01:00
Simon McVittie
083730f59b Write NEWS so far for 1.10.6
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-10-12 20:43:39 +01:00
Simon McVittie
0717aa5535 NEWS: Clarify what was fixed in 1.12.1 and 1.10.5
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-10-12 20:43:39 +01:00
Simon McVittie
ee4a9c4e1c NEWS: Mention CVE-2021-41133
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit ff0c48c780)
2021-10-12 20:43:39 +01:00
Simon McVittie
7ea10dc919 run: Improve error handling/diagnostics for calls into libseccomp
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 53bde36585)
(cherry picked from commit bd2c58fc27)
2021-10-12 20:43:39 +01:00
Simon McVittie
2448522422 Fix handling of syscalls only allowed by --devel
This was incorrectly looking at errno instead of -r.

Fixes: 0b38b0f0 "run: Handle unknown syscalls as intended"
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 3fc8c67267)
(cherry picked from commit 97e128c2c1)
2021-10-12 20:43:39 +01:00
Piotr Drąg
e4a3969dd2 Update Polish translation 2021-10-11 09:45:07 +02:00
Alexander Larsson
c88587af73 Update pofiles 1.10.5 2021-10-08 19:26:20 +02:00
Alexander Larsson
4da2ec4923 Bump version to 1.10.5 2021-10-08 19:18:19 +02:00
Alexander Larsson
878d0d5a82 Update NEWS for 1.10.5 2021-10-08 19:18:08 +02:00
Simon McVittie
0929483fed run: Handle unknown syscalls as intended
The error-handling here was

    if (r < 0 && r == -EFAULT)

but Alex says it was almost certainly intended to be

    if (r < 0 && r != -EFAULT)

so that syscalls not known to libseccomp are not a fatal error.

Instead of literally making that change, emit a debug message on -EFAULT
so we can see what is going on.

This temporarily weakens our defence against CVE-2021-41133
(GHSA-67h7-w3jq-vh4q) in order to avoid regressions: if the installed
version of libseccomp does not know about the recently-added syscalls,
but the kernel does, then we will not prevent non-native executables
from using those syscalls.

Resolves: https://github.com/flatpak/flatpak/issues/4458
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit d419fa6703)
2021-10-08 19:17:16 +02:00
Alexander Larsson
e4a41716d8 Update pofiles for release 1.10.4 2021-10-08 13:05:42 +02:00
Alexander Larsson
d92add03df Bump version to 1.10.4 2021-10-08 12:38:44 +02:00
Alexander Larsson
9a39a35a0c Update NEWS for 1.10.4 2021-10-08 12:38:22 +02:00
Alexander Larsson
8a6a22e24a tests: Fix test-sideload.sh if ostree is built with curl backend
The soup backend and the curl backend give slightly different error
messages, so we need to tweak the 404 assert check to match both.

(cherry picked from commit 9914dff925)
2021-10-08 12:33:27 +02:00
Simon McVittie
7059882069 run: Don't allow chroot()
If we don't allow pivot_root() then there seems no reason why we should
allow chroot().

Partially fixes GHSA-67h7-w3jq-vh4q.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-10-08 12:25:16 +02:00
Simon McVittie
8fc2d96393 run: Don't allow unmounting filesystems
If we don't allow mounting filesystems, we shouldn't allow unmounting
either.

Partially fixes GHSA-67h7-w3jq-vh4q.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-10-08 12:25:16 +02:00
Simon McVittie
aacfed4b0b run: Block setns()
If we don't allow unshare() or clone() with CLONE_NEWUSER, we also
shouldn't allow joining an existing (but different) namespace.

Partially fixes GHSA-67h7-w3jq-vh4q.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-10-08 12:25:16 +02:00
Simon McVittie
a245e402ce run: Disallow recently-added mount-manipulation syscalls
If we don't allow mount() then we shouldn't allow these either.

Partially fixes GHSA-67h7-w3jq-vh4q.

Thanks: an anonymous reporter
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-10-08 12:25:16 +02:00
Simon McVittie
b74dcd136f run: Block clone3() in sandbox
clone3() can be used to implement clone() with CLONE_NEWUSER, allowing
a sandboxed process to get CAP_SYS_ADMIN in a new namespace and
manipulate its root directory. We need to block this so that AF_UNIX-based
socket servers (X11, Wayland, etc.) can rely on
/proc/PID/root/.flatpak-info existing for all Flatpak-sandboxed apps.

Partially fixes GHSA-67h7-w3jq-vh4q.

Thanks: an anonymous reporter
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-10-08 12:25:16 +02:00
Simon McVittie
c8ec3ad50a common: Add a list of recently-added Linux syscalls
Historically, syscalls could take arbitrarily-different values on
different architectures, but new syscalls are added with syscall numbers
that align on each architecture.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-10-08 12:25:16 +02:00
Simon McVittie
bba110c994 run: Add cross-references for some other seccomp syscall filters
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-10-08 12:25:16 +02:00
Simon McVittie
dce883e4c3 run: Add an errno value to seccomp filters
At the moment, if we block a syscall we always make it fail with EPERM,
but this is risky: user-space libraries can start to use new replacements
for old syscalls at any time, and will often treat EPERM as a fatal error.
For new syscalls, we should make the syscall fail with ENOSYS, which is
indistinguishable from running on an older kernel and will cause fallback
to an older implementation, for example clone3() to clone().

In future we should probably move from EPERM to ENOSYS for some of the
syscalls we already block, but for now keep the status quo.

This is a prerequisite for fixing the vulnerability tracked as
GHSA-67h7-w3jq-vh4q.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-10-08 12:25:16 +02:00
Philip Withnall
805c03bc45 Merge pull request #4439 from pwithnall/backport-4436-fix-parental-controls
Backport #4436 “flatpak-dir: Fix parental controls checks for root” to flatpak-1.10.x
2021-09-29 15:30:03 +01:00
Philip Withnall
f8a28c4bd4 flatpak-dir: Fix parental controls checks for root
These checks were broken in commit d762a2f, as the commit failed to
consider the fact that `flatpak_dir_check_parental_controls()` is run
both in the `flatpak` CLI process run by the user, but also in the
`flatpak-system-helper` process which always runs as root, and which
handles any installations done on the system repository.

As a result, parental controls were not working for the system
repository.

Fix that by limiting the scope of the check to only pass if running
without the system helper. flatpak calls from root never go through the
system helper.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #4418
2021-09-29 11:39:39 +01:00
Alexander Larsson
ed8a69f623 Drop old-glib ci test as ubuntu 16.04 is no longer available
As per https://github.com/actions/virtual-environments/issues/3287
the support for ubuntu-16.04 stopped working on september 20:th, so
our CI job stopped starting.

(This matches what we did on master)
2021-09-23 14:21:11 +01:00
Kalev Lember
14ed399095 OCI: Switch to pax format for tar archives
For reasons unknown, libarchive appears to generate broken gnutar format
tar archives when the archive contains files that are larger than 2 GB.
This commit switches to the pax format to work this around.

This should be a better default as it also removes 256 char filename
length limitation and matches what other libraries are doing, e.g.
Python 3.8 switched to the pax format by default as well.

See https://pagure.io/fedora-infrastructure/issue/9840

(cherry picked from commit b90d638601)
2021-09-23 10:19:39 +02:00
Simon McVittie
35bd4697d9 Update translation files for 1.10.3
Signed-off-by: Simon McVittie <smcv@collabora.com>
1.10.3
2021-08-31 18:34:17 +01:00
Simon McVittie
b4c342baed Release v1.10.3
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-08-31 15:50:03 +01:00
Simon McVittie
46e009de85 Update NEWS
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-08-27 11:38:22 +01:00
Simon McVittie
9c12cb44b8 tests: Don't reset XDG_RUNTIME_DIR locally
If we do, it interferes with xdg-dbus-proxy, causing test failure under
some circumstances: the test passes on a development system, but fails
when run on a qemu virtual machine in Debian's autopkgtest framework.

Fixes: 6e5b02e2 "run: Don't let XDG_RUNTIME_DIR from user override the value we set"
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 7bf6ecfaa2)
2021-08-27 11:38:22 +01:00
Simon McVittie
8062e848a1 libtest: Make sure ldconfig and capsh are in the PATH
This gives us better test coverage on Debian derivatives.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 21a5fe5ff1)
2021-08-27 11:38:22 +01:00
Simon McVittie
e14d424bb0 Update NEWS so far
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-08-26 12:35:19 +01:00
Simon McVittie
d3e6e71fee run: Don't let XDG_RUNTIME_DIR from user override the value we set
We use `bwrap --setenv XDG_RUNTIME_DIR` to set it to `/run/user/UID`,
regardless of what it is on the host system, but the changes made
to resolve CVE-2021-21261 unintentionally broke this by overwriting it
with the user's XDG_RUNTIME_DIR.

In practice this worked for most people, who either have
XDG_RUNTIME_DIR set to the same value we use (which is the conventional
setup from systemd-logind and elogind), or entirely unset (if they do not
have systemd-logind or elogind). However, it broke Wayland and other
XDG_RUNTIME_DIR-based protocols for people who intentionally set up an
XDG_RUNTIME_DIR that is different.

Fixes: 6d1773d2 "run: Convert all environment variables into bwrap arguments"
Resolves: https://github.com/flatpak/flatpak/issues/4372
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-08-20 15:09:47 +01:00