Commit Graph

6078 Commits

Author SHA1 Message Date
Alexander Larsson
199a05c8c9 Update po-files for release 1.8.7 2022-02-03 12:55:58 +01:00
Alexander Larsson
2e7a447271 Bump version to 1.8.7 2022-02-03 12:43:23 +01:00
Alexander Larsson
fb5b7f0a4e Update NEWS for release 2022-02-03 12:43:14 +01:00
Simon McVittie
f85a239b7a test-override: Exercise --nofilesystem=host:reset
Signed-off-by: Simon McVittie <smcv@collabora.com>
Co-authored-by: Alexander Larsson <alexl@redhat.com>
(cherry picked from commit 4aa70d2d72)
(cherry picked from commit 2c89fc3ef3)
2022-02-03 12:38:17 +01:00
Simon McVittie
521b3f358f test-context: Exercise some corner cases for merging filesystems
Signed-off-by: Simon McVittie <smcv@collabora.com>
Co-authored-by: Alexander Larsson <alexl@redhat.com>
(cherry picked from commit fab0f8ed7c)
[smcv: Also backport the scaffolding to create this test-case]
(backported from commit 4206d681c5)
2022-02-03 12:38:17 +01:00
Simon McVittie
25f3b20258 test-exports: Exercise host:reset and related filesystem tokens
Signed-off-by: Simon McVittie <smcv@collabora.com>
Co-authored-by: Alexander Larsson <alexl@redhat.com>
(cherry picked from commit f3d12dc793)
(cherry picked from commit d2128c5418)
2022-02-03 12:38:17 +01:00
Simon McVittie
4e0640f605 test-override: Assert that --nofilesystem with suffix yields a warning
This was added as part of implementing the :reset suffix.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit ab0169ee39)
(cherry picked from commit b543933ce1)
2022-02-03 12:38:17 +01:00
Simon McVittie
981a12b57c context: Introduce new --nofilesystem=host:reset
This reintroduces the special case that existed in Flatpak 1.12.3, but
under a different name, so that it will be backwards-compatible. With
this change, flatpak-builder will be able to resolve CVE-2022-21682 by
using --filesystem=host:reset.

We want to implement this as a suffix rather than as a new keyword,
because unknown suffixes are ignored with a warning, rather than causing
a fatal error. This means that the new version of flatpak-builder will
be able to run against older versions of flatpak: it will still be
vulnerable to CVE-2022-21682 in that situation, but at least it will run.

Co-authored-by: Alexander Larsson <alexl@redhat.com>
(cherry picked from commit 5709f1aaed)
(cherry picked from commit 92b8cfe46b)
2022-02-03 12:38:17 +01:00
Simon McVittie
3750973225 test-override: Assert pre-1.12.3 behaviour of --nofilesystem=home, host
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 813e1f0b3b)
(cherry picked from commit 734047a1d7)
2022-02-03 12:38:17 +01:00
Simon McVittie
b0364b946d run, override: Clarify the effect of --nofilesystem
There are two reasonable interpretations for --nofilesystem=home:
either it revokes a previous --filesystem=home (as in Flatpak 1.12.2 and
older versions), or it completely forbids access to the home directory
(as in Flatpak 1.12.3). Clarify the man pages to indicate that it only
revokes a previous --filesystem=home. This will hopefully reduce
mismatches between the design and what users expect to happen, as
in flatpak#4654.

A subsequent commit will introduce a way to get the Flatpak 1.12.3
behaviour in a way that is more backwards-compatible with Flatpak 1.12.2
and older versions.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 7bbeed2b87)
(cherry picked from commit fe3954ff63)
2022-02-03 12:38:17 +01:00
Simon McVittie
4030670eaa tests: Expand exports test coverage
This doesn't assert the presence of /run/host/os-release because
7872935e "run: implement sandbox host os-release interface" is absent
from this branch, and it's better to keep it that way since it
introduces a new runtime ABI.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(backported from commit 27870f681d)
2022-02-03 12:38:17 +01:00
Simon McVittie
3f3b89db75 context: Implement MODE_NONE in unparse_filesystem_flags
flatpak doesn't yet use -Wswitch-enum, but perhaps it should at some
point. Now that FLATPAK_FILESYSTEM_MODE_NONE is a member of the enum,
it should be handled; and if we're doing that, we might as well make
the same function fully responsible for it.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 5a83c73ed8)
2022-02-03 12:38:17 +01:00
Simon McVittie
17418e534c tests: Exercise flatpak_context_save_metadata
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit e55dcf5e2b)
2022-02-03 12:38:17 +01:00
Simon McVittie
be0195b0c7 tests: Use a temporary HOME directory to test contexts and exports
This gives us control over the paths that get shared (or not) and
whether they are symlinks, so that we can expand coverage later.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 354b9a2257)
2022-02-03 12:38:17 +01:00
Simon McVittie
fc64778fb3 context: Normalize home/path to ~/path, and ~ to home
Historically we didn't accept them, but there's no real reason why not.
They're normalized to the form in which earlier Flatpak releases would
want to see them.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(backported from commit 09424423b9)
2022-02-03 12:38:17 +01:00
Simon McVittie
ceea3cefad context: Forbid --filesystem=/
Making it an equivalent of --filesystem=host would be misleading,
because it wouldn't do what you'd think it does: host mounts some host
system directories in their usual places, but others below /run/host.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 02094b4f39)
2022-02-03 12:38:17 +01:00
Simon McVittie
7eeefa43b1 context: Do some syntactic normalization on filesystems
Paths containing ".." are rejected: they're almost certainly a
terrible idea.

Paths containing "." or multiple slashes are syntactically normalized.

This assumes that nobody is going to use "--filesystem=/foo/bar/" to
mean "make /foo/bar available, unless it's a non-directory, in which
case fail".

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit aafe1d36e0)
2022-02-03 12:38:17 +01:00
Simon McVittie
52dfa31b7b tests: Add basic unit tests for FlatpakExports, FlatpakContext
There's a limit to how many assertions we can make here right now,
because what we do here is very dependent on the "shape" of the host
filesystem. This could be extended in future by using a mock home
directory whose contents we control.

This doesn't assert the presence of /run/host/os-release because
7872935e "run: implement sandbox host os-release interface" is absent
from this branch, and it's better to keep it that way since it
introduces a new runtime ABI.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(backported from commit c0faab35fa)
2022-02-03 12:38:17 +01:00
Simon McVittie
5c51d6f30a context: Expose flatpak_context_parse_filesystem for testing
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 55b27b1393)
2022-02-03 12:38:17 +01:00
Simon McVittie
0964eb59fc exports: Add assertions to distinguish between mode representations
When we're talking about a "mode", sometimes we mean a
FlatpakFilesystemMode, sometimes we mean a FlatpakFilesystemMode that
must be strictly greater than NONE, and sometimes we're willing to
accept the FAKE_MODE constants too.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 115d82e6ff)
2022-02-03 12:38:17 +01:00
Simon McVittie
50056d48bf context: Only parse filesystem/mode strings in one place
This gives us the ability for the parse function (the former verify
function) to carry out a normalization step as well.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 517ad25b5f)
2022-02-03 12:38:17 +01:00
Simon McVittie
ffb230c5c2 test-override: Assert that unimplemented suffix is ignored with a warning
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 8a44df04c8)
(cherry picked from commit 97dd26c02e)
2022-02-03 12:38:17 +01:00
Simon McVittie
5d16152956 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)
(cherry picked from commit 74f02d1e95)
2022-02-03 12:38:17 +01:00
Simon McVittie
3da6c017d5 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>
(cherry picked from commit eb324b9d82)
2022-02-03 12:38:17 +01:00
Phaedrus Leeds
167af4c9e1 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)
(cherry picked from commit ce0bb56c6f)
2022-02-03 12:38:17 +01:00
Alexander Larsson
d5fc9fb8de 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)
(cherry picked from commit 574cb11372)
2022-02-03 12:38:17 +01:00
Alexander Larsson
00b8adedd0 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)
(backported from commit bd6948c375)
2022-02-03 12:38:17 +01:00
Alexander Larsson
7ee257cfac 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)
(backported from commit 10367bd7d2)
2022-02-03 12:38:17 +01:00
Ryan Gonzalez
b045d69da8 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)
(backported from commit 3c3dc554e7)
2022-02-03 12:38:17 +01:00
Alexander Larsson
c1953cae5c Update po-files for release 1.8.6 2022-01-25 09:52:46 +01:00
Debarshi Ray
25adc7ddde Update NEWS 2022-01-25 09:38:28 +01:00
Alexander Larsson
16290b544f system-helper: Fix deploys of local remotes
For updates in remotes with a local (file:) uri we just do a deploy
with a LOCAL_PULL flag set and an empty arg_repo_path. However, our
arg_repo_path checking at some point seemed to stop properly handling
the case where it is empty. I got it to report "No such file" wich
broke the tests.

(cherry picked from commit 49e8bfcea5)
(cherry picked from commit c8b9069ab1)

Fixes: #4339
2022-01-25 09:38:28 +01:00
Simon McVittie
fb6f1ead1f system-helper: Return G_DBUS_METHOD_INVOCATION_HANDLED where appropriate
Signed-off-by: Simon McVittie <smcv@collabora.com>
(backported from commit 86dd000dd1)
2022-01-25 09:38:28 +01:00
Alexander Larsson
16825efc34 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)
(cherry picked from commit 8a6a22e24a)
2022-01-24 18:59:26 +01:00
Phaedrus Leeds
c34d185ab7 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)
(cherry picked from commit 1dbc175314)
[smcv: verified that this has no effect with older pyparsing versions]
2022-01-24 18:59:26 +01:00
Alexander Larsson
c2621b894f Bump version to 1.8.6 2022-01-24 11:38:34 +01:00
Simon McVittie
6d2c1db38b Update NEWS
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-01-21 20:46:19 +00:00
Simon McVittie
90296e4562 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)
(cherry picked from commit 9c12cb44b8)
2022-01-21 20:46:19 +00:00
Simon McVittie
02eff8fd6e 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>
(cherry picked from commit d3e6e71fee)
2022-01-21 20:46:19 +00:00
Simon McVittie
8af646e68c tests: Remove hard-coded references to x86_64
Distributions run these tests on other architectures, but hard-coding
x86_64 to look for in output dooms that to failure.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit ba381ae936)
(cherry picked from commit 4089b69769)
2022-01-21 20:46:19 +00:00
Simon McVittie
6570eba9c5 portal: Remap --env-fd into child process's fd space
Just because we can allocate a new, unused fd in the portal's fd space,
that doesn't mean that fd number is going to be unused in the child
process's fd space: we might need to remap it.

Resolves: flatpak/flatpak#4286
Fixes: aeb6a7ab "portal: Convert --env in extra-args into --env-fd"
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 526dae9241)
(cherry picked from commit 101a3c5515)
2022-01-21 20:46:19 +00:00
Simon McVittie
1eb9885e21 portal: Use a GArray to store fds
This will allow us to add additional mapping entries for fds to be
used internally by `flatpak run`, in particular --env-fd.

Defer the second pass through the fd array until the last possible
moment, so that any extra fds we want to add (like the --env-fd) have
already been added by then.

Helps: flatpak/flatpak#4286
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit a09d07f085)
(cherry picked from commit 77b484cb2e)
2022-01-21 20:46:19 +00:00
Simon McVittie
b649c793b5 portal: Don't leak fd used for serialized environment
Otherwise we'll run out of file descriptors eventually, when starting
a sufficiently large number of subsandboxes.

Resolves: flatpak/flatpak#4285
Fixes: aeb6a7ab "portal: Convert --env in extra-args into --env-fd"
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit f2fbc75827)
(cherry picked from commit b4c6aa1cc8)
2022-01-21 20:46:19 +00:00
Michael Catanzaro
ff0ca9ac6f Fix build with GCC 11
See:
fab561f8d0
(cherry picked from commit 9b34768fa7)
2022-01-21 20:46:19 +00:00
Simon McVittie
4464a4a578 NEWS: Update with changes so far
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-10-26 15:54:55 +01:00
Simon McVittie
adaa0259e8 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-26 15:54:55 +01:00
Simon McVittie
da503e0d90 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-26 15:54:55 +01:00
Simon McVittie
a0055e4f84 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)
(cherry picked from commit 270701f900)
2021-10-26 15:54:55 +01:00
Simon McVittie
8f8769642f 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-26 15:54:55 +01:00
Simon McVittie
758b8ca8c8 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-26 15:54:55 +01:00