Commit Graph

6022 Commits

Author SHA1 Message Date
Simon McVittie
15e0977f0f env.d: Disable gvfs plugins during login
This avoids gvfs-daemon being started when logging in as root via ssh.

Bug-Debian: https://bugs.debian.org/975710
(backported from commit afe7f2bf78)
2021-10-05 14:02:25 +01:00
Mourad De Clerck
81673e42b8 profile.d: Disable gvfs plugins when listing flatpak installations
This avoids gvfs-daemon being started when logging in as root via ssh.

Bug-Debian: https://bugs.debian.org/975710
(cherry picked from commit f69a35ceec)
2021-10-05 14:02:25 +01:00
Phaedrus Leeds
0ad4ebd137 Fix several memory leaks
(cherry picked from commit 404d7c6941)
2021-10-05 00:50:09 +01:00
Alexander Larsson
481e5c88f1 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-10-04 16:35:57 +01:00
Alexander Larsson
c64706240d CI: Add mono apt repo to fix build
For whatever reason parts of mono is installed, but the repo is not
configured so there is a version conflict on update:

libglib2.0-cil is already the newest version (2.12.45-0xamarin19+ubuntu1604b1).
libglib2.0-cil set to manually installed.
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libglib2.0-cil-dev : Depends: libglib2.0-cil (= 2.12.10-6) but 2.12.45-0xamarin19+ubuntu1604b1 is to be installed
E: Unable to correct problems, you have held broken packages.

(cherry picked from commit b6d5e20857)
2021-10-04 16:35:57 +01:00
Simon McVittie
754450e5ad dir: Refuse to export .desktop files with suspicious uses of @@ tokens
This is either a malicious/compromised app trying to do an attack, or
a mistake that will break handling of %f, %u and so on. Either way,
if we refuse to export the .desktop file, resulting in installation
failing, then it makes the rejection more obvious than quietly
removing the magic tokens.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 46b3ede524)
2021-10-04 16:35:57 +01:00
Simon McVittie
cc7526b1d0 dir: Reserve the whole @@ prefix
If we add new features analogous to file forwarding later, we might
find that we need a different magic token. Let's reserve the whole
@@* namespace so we can call it @@something-else.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 1e7e8fdb24)
2021-10-04 16:35:57 +01:00
Ryan Gonzalez
c54e7c3463 Disallow @@ and @@u usage in desktop files
Fixes #4146.

(cherry picked from commit 652a28ffab)
2021-10-04 16:35:57 +01:00
Alexander Larsson
be70cd5024 CI: Use the new --enable-asan
(cherry picked from commit d5de05b608)
2021-10-04 16:35:57 +01:00
Alexander Larsson
0a169383e9 Add --enable-asan option
This passes -fsanitize=address in the right place.
Passing it this way instead of CFLAGS allows us to strategically
not add sanitize in specific places as needed.

(cherry picked from commit 97a153fe0a)
2021-10-04 16:35:57 +01:00
Simon McVittie
f91857c07e dir: Pass environment via bwrap --setenv when running apply_extra
This means we can systematically pass the environment variables
through bwrap(1), even if it is setuid and thus is filtering out
security-sensitive environment variables. bwrap ends up being
run with an empty environment instead.

As with the previous commit, this regressed while fixing CVE-2021-21261.

Fixes: 6d1773d2 "run: Convert all environment variables into bwrap arguments"
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit fb473cad80)
2021-01-21 14:51:41 +01:00
Simon McVittie
93ecea3488 build: Convert environment into a sequence of bwrap arguments
This means we can systematically pass the environment variables
through bwrap(1), even if it is setuid and thus is filtering out
security-sensitive environment variables. bwrap itself ends up being
run with an empty environment instead.

This fixes a regression when CVE-2021-21261 was fixed: before the
CVE fixes, LD_LIBRARY_PATH would have been passed through like this
and appeared in the `flatpak build` shell, but during the CVE fixes,
the special case that protected LD_LIBRARY_PATH was removed in favour
of the more general flatpak_bwrap_envp_to_args(). That reasoning only
works if we use flatpak_bwrap_envp_to_args(), consistently, everywhere
that we run the potentially-setuid bwrap.

Fixes: 6d1773d2 "run: Convert all environment variables into bwrap arguments"
Resolves: https://github.com/flatpak/flatpak/issues/4080
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=980323
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 9a61d2c44f)
2021-01-21 14:51:41 +01:00
Simon McVittie
88444c7523 NEWS: Add CVE reference for CVE-2021-21261
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-01-21 14:21:04 +01:00
Piotr Drąg
2baea8dada Update Polish translation 2021-01-21 14:19:17 +01:00
Alexander Larsson
58dc0ea96c Update pofiles for release 1.8.5 2021-01-14 10:25:23 +01:00
Alexander Larsson
e3d06dd559 Fix tests when installed tests are not enabled
We need a different rpath for libpreload in this case, because
installed_testdir is not set.
2021-01-14 10:23:58 +01:00
Alexander Larsson
b2aff2d19d Bump version to 1.8.5 and update NEWS 2021-01-14 09:38:54 +01:00
Simon McVittie
5019b303f6 tests: Assert that --env= does not go in flatpak run or bwrap environ
For the portal's use of --env-fd= to be safe, we want the environment
variables that it sets to end up in the environment for the program
that is run by `bwrap` as process 2, but they must not go into the
environment that gets used to run `flatpak run` or `bwrap`. Assert
that this is the case.

For completeness, we're testing both --env= and --env-fd= here,
even though the earlier commit
"portal: Do not use caller-supplied variables in environment"
always uses --env-fd=.

Part-of: https://github.com/flatpak/flatpak/security/advisories/GHSA-4ppf-fxf6-vxg2
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-01-14 09:33:24 +01:00
Simon McVittie
26f09bf5fd portal: Do not use caller-supplied variables in environment
If the caller specifies a variable that can be used to inject arbitrary
code into processes, we must not allow it to enter the environment
block used to run `flatpak run`, which runs unsandboxed.

This change requires the previous commit "context: Add --env-fd option",
which adds infrastructure used here.

To be secure, this change also requires the previous commit
"run: Convert all environment variables into bwrap arguments", which
protects a non-setuid bwrap(1) from the same attack.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Part-of: https://github.com/flatpak/flatpak/security/advisories/GHSA-4ppf-fxf6-vxg2
2021-01-14 09:33:24 +01:00
Simon McVittie
7bb78f8099 tests: Exercise --env-fd
Signed-off-by: Simon McVittie <smcv@collabora.com>
Part-of: https://github.com/flatpak/flatpak/security/advisories/GHSA-4ppf-fxf6-vxg2
2021-01-14 09:33:24 +01:00
Simon McVittie
fb1eaefbce portal: Convert --env in extra-args into --env-fd
This hides overridden variables from the command-line, which means
processes running under other uids can't see them in /proc/*/cmdline,
which might be important if they contain secrets.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Part-of: https://github.com/flatpak/flatpak/security/advisories/GHSA-4ppf-fxf6-vxg2
2021-01-14 09:33:24 +01:00
Simon McVittie
57416f3806 context: Add --env-fd option
This allows environment variables to be added to the context without
making their values visible to processes running under a different uid,
which might be significant if the variable's value is a token or some
other secret value.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Part-of: https://github.com/flatpak/flatpak/security/advisories/GHSA-4ppf-fxf6-vxg2
2021-01-14 09:33:24 +01:00
Simon McVittie
6a11007021 tests: Expand coverage for environment variable overrides
This checks that `flatpak run --env=` takes precedence over
`flatpak override --env=`, and that environment variables don't get
onto the bwrap command-line (which would be information disclosure
if their values are secret).

Signed-off-by: Simon McVittie <smcv@collabora.com>
Part-of: https://github.com/flatpak/flatpak/security/advisories/GHSA-4ppf-fxf6-vxg2
2021-01-14 09:33:24 +01:00
Simon McVittie
dcd24941c7 run: Convert all environment variables into bwrap arguments
This avoids some of them being filtered out by a setuid bwrap. It also
means that if they came from an untrusted source, they cannot be used
to inject arbitrary code into a non-setuid bwrap via mechanisms like
LD_PRELOAD.

Because they get bundled into a memfd or temporary file, they do not
actually appear in argv, ensuring that they remain inaccessible to
processes running under a different uid (which is important if their
values are tokens or other secrets).

Signed-off-by: Simon McVittie <smcv@collabora.com>
Part-of: https://github.com/flatpak/flatpak/security/advisories/GHSA-4ppf-fxf6-vxg2
2021-01-14 09:33:24 +01:00
Simon McVittie
d1d05a718b common: Add a backport of G_DBUS_METHOD_INVOCATION_HANDLED
This is syntactic sugar added in GLib 2.67.0, which makes it more clearly
correct when we return TRUE after a GDBus error.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit cc7f863707)
2021-01-14 09:33:24 +01:00
Alexander Larsson
003fa230c6 Update pofiles for release 1.8.4 2020-12-22 15:10:28 +01:00
Alexander Larsson
0bde45cc92 Update for 1.8.4 release 2020-12-22 14:51:31 +01:00
Alexander Larsson
c7cfb8f761 Update variant-schema-compiler to fix ppc64le
We need the fix in:
 04abfc9e53
For flatpak to work on ppc64le.

Fixes https://github.com/flatpak/flatpak/issues/3503
2020-12-07 16:01:29 +01:00
Alexander Larsson
815d4c4f0e Update pofiles for release 1.8.3 2020-11-17 14:29:56 +01:00
Alexander Larsson
5b8349279d Bump version to 1.8.3 2020-11-17 13:58:24 +01:00
Alexander Larsson
1b5b20239c Update NEWS for 1.8.3 2020-11-17 13:58:24 +01:00
Ryan Gonzalez
e5fb1f85b1 transaction: Don't crash on invalid ref names
It is very much possible for an invalid ref name to occur, either due to
lack of validation on Flatpak creation like #3887, or just any
manually-written ref name due to skipping Flatpak tooling or malicious
intent. Regardless, this shouldn't crash, so check the names before
creating the transaction ops.

Fixes #3887.
2020-11-17 13:19:50 +01:00
Philip Withnall
cde0c57bc5 flatpak-transaction: Don’t update metadata when uninstalling
When uninstalling a single app (an example of a transaction which is
entirely local-only), there’s no need to update the repository metadata
beforehand — but the code was doing that.

This avoids an unnecessary download of the `summary.sig` file (or other
repository metadata, depending on what’s out of date) when uninstalling.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-11-17 13:19:50 +01:00
Philip Withnall
7a1c268405 dir: Fix caching of summary files
Cache hits didn’t result in the cache entry’s timeout being extended,
and timeouts didn’t result in the entry being removed from the cache to
free up resources (even though it would never be returned as a cache hit
again).

Signed-off-by: Philip Withnall <withnall@endlessm.com>
(cherry picked from commit 63b4f3a5c1)
2020-11-17 13:19:50 +01:00
Philip Withnall
1ab69d7032 dir: Fix potential overflow when comparing cache timeouts
Also use a constant to clarify the code a little, although it’s
functionally equivalent.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
(cherry picked from commit 9bec865995)
2020-11-17 13:19:50 +01:00
Tomasz Kontusz
fce331b481 Fix DBUS_*_BUS_ADDRESS in flatpak enter
Fixes #3820.

(cherry picked from commit e39b94b26c)
2020-11-17 13:19:50 +01:00
Alexander Larsson
7107f31986 tests: Un-redirect url after trying redirect
After the --redirect-url= test is finished it leaves the remote with a
different url, which is confusing the other tests.

In particular, at some point we remove the remote and add it back,
which gets us back to the old url, but at that point the summary (from
the newer url) has a later mtime than the old one so the old one keeps
getting used.

So, we unset the redirect and set back the old url. Also, the following test
had to be tweaked for this change.
2020-11-17 13:19:50 +01:00
Alexander Larsson
07e6a2cf99 tests: Work around summary mtime cache issue (for 1.8 branch)
This adds a sleep(1) before each summary update (if there is a
pre-existing summary file). This avoids issues where a new summary
file get the same mtime (in seconds precision).

This is kind of a hacky work around, but it is good enought to get
the flatpak-1.8 branch working with latest ostree, and master has a better
fix already.
2020-11-17 13:19:50 +01:00
Alexander Larsson
6dbc968b79 tests: Avoid unnecessarily recreating the summary file
We enforce --no-update-summary when we create test apps and
runtimes, and then we ensure we always manually call update_repo
after all modifications are done.

This means we save work avoiding summary updates, but it also means we
can do special handling in update_summary and guarantee that this is
the only place this happens. For example, we want this to work around
the mtime handling of summary updates.
2020-11-17 13:19:50 +01:00
Phaedrus Leeds
1b0060d357 transaction: Fix ordering of runtime uninstallation
In case a transaction is uninstalling both an app and its runtime,
properly ensure the app is uninstalled first.

(cherry picked from commit c6647c2b14)
2020-11-17 13:19:50 +01:00
Alexander Larsson
631ee3899f Remove some spammy debug spew
as_store_find_app() was constantly spewing things you don't really
need to see.

(cherry picked from commit 4f793a45c2)
2020-11-17 13:19:50 +01:00
Alexander Larsson
97c8ca0a71 Remove should-retry debug spew
Every http operation (even when successfull) was spewing info about
whether to retry it which made it hard to read the logs.

(cherry picked from commit 3ebcd200ca)
2020-11-17 13:19:50 +01:00
Philip Withnall
740e4482c2 http: Return HOST_UNREACHABLE on error 500
Sometimes a server might return a HTTP error 500 (this seems to happen
sometimes with Microsoft’s VSCode server, for example). Map this to
`G_IO_ERROR_HOST_UNREACHABLE` for now, which is a bit more specific than
returning `G_IO_ERROR_FAILED`, but without the hassle of introducing a
new public error domain which could give more detail.

In particular, this should allow gnome-software to show an error message
to the user for such failed downloads, rather than hiding the error and
logging the following:
```
not handling error failed for action download: While downloading http://packages.microsoft.com/repos/vscode/pool/main/c/code/code_1.45.1-1589445302_amd64.deb: Server returned status 500: Internal Server Error
```

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
(cherry picked from commit 6c79a57114)
2020-11-17 13:19:50 +01:00
Alexander Larsson
adb25fb274 oci-authenticator: Fix crash if anon auth fails and no_interaction is set
We were clearing the error from the anon test, and then not doing any
non-anon auth, so error was NULL, causing a crash when returning an
error message.

(cherry picked from commit 180d807d2a)
2020-11-17 13:19:50 +01:00
Alexander Larsson
333e0518c9 transaction: Fix error handling in authentication failures
We were not correctly returning in case of error, which caused
a cascading "owerwrite gerror" problem.

(cherry picked from commit 33d1d7b1a5)
2020-11-17 13:19:50 +01:00
Phaedrus Leeds
7df39e636d info: Only load from specified installation
flatpak_find_deploy_for_ref() will look for a deploy across all
installations, but we want to use the user-specified one, e.g. user if
--user was passed.

Pointed out here:
https://github.com/flatpak/flatpak/pull/3853#discussion_r487711857

(cherry picked from commit d7cca22d7c)
2020-11-17 13:19:50 +01:00
Phaedrus Leeds
ab3aa8d7db portal: Fix unset GError issue
Fix lookup_installation_for_path() to not leave the GError pointer unset
on its error code path. This error is only used by the caller for a
debug message, and shouldn't be hit normally, but it could mean a NULL
pointer dereference when we try to print error->message.

(cherry picked from commit 075c86ca4f)
2020-11-17 13:19:50 +01:00
Alexander Larsson
f4bdcfbbbc Fix extra-data progress reporting
We were never calling the progress callback for extra-data downloaded
bytes.

(cherry picked from commit 7b5a0a5c86)
2020-11-17 13:19:50 +01:00
Alexander Larsson
4e47dba3b3 OCI: Fix progress reporting
Somewhere during the progress reporting cleanup we lost the progress
for OCI pulls, this puts it back.

(cherry picked from commit 7622aab962)
2020-11-17 13:19:50 +01:00
Alexander Larsson
be00050211 Don't loop authentincating if updating to the current version
In case we need to authenticate for updates (in my test case i was
doing an OCI downgrade) we might need to download a commit object (or
in the OCI case a manifest json), so it did a request_required_tokens(),
but that noticed during the flatpak_transaction_normalize_ops() call
that the partial resolve to a particular commit actually was the
same as the local installed commit and marked op->skip = TRUE.

However, when we got back to resolving the op again we didn't actually
look at the skip, so it kept looping wanting (but never doing) auth.

The fix is to just directly resolve ops marked as skipped.

(cherry picked from commit d8086141fb)
2020-11-17 13:19:50 +01:00