Commit Graph

72 Commits

Author SHA1 Message Date
Leorize
df0b9d98b5 flatpak-run: unset GIO_EXTRA_MODULES
This variable contains paths to load GIO modules from. For the most
part, they refer to paths outside of the sandbox or if they happen
to be in the sandbox, would contain modules that are incompatible with
the sandbox runtime (ie. different libc).

While I've not found programs that would crash outright, it may cause
unexpected behaviors (eg. Apostrophe not being able to render math in
preview panel).

This variable is set by NixOS for its dependency boxing.
2022-12-07 16:20:51 -06:00
Leorize
751ff11d3a flatpak-run: unset XKB_CONFIG_ROOT
This variable is typically used to configure the use of a custom
set of XKB definitions. In those cases, it's mostly meant for the
X11 server or Wayland compositor. NixOS is known to employ this
variable for their custom XKB layout implementation.

When the path it points to is unreachable (due to the sandbox),
most GTK+/Qt applications will crash on Wayland.

Unsetting this does not seem to negatively impact the use of custom
XKB layouts with Flatpak applications.
2022-12-01 20:01:14 -06:00
Simon McVittie
26fbf692cd doc: Update flatpak-run(1) for #5168
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-11-17 17:44:18 +00:00
Michael Catanzaro
1c32317841 Block KRB5CCNAME from inheriting into sandbox
If this environment variable is set on the host, it's going to mess up
authentication in the sandbox. For example, if the host has:

KRB5CCNAME=KCM:

then the sandboxed process will try to use the host KCM socket, which is
not available in the sandboxed environment, rather than the gssproxy
socket that we want it to use. We need to unset it to ensure that
whatever configuration we ship in the runtime gets used instead. We have
switched the GNOME runtime to use an empty krb5.conf and it works as
long as we don't break it with this environment variable meant for the
host.
2022-09-19 09:03:48 +02:00
Nick Reiley
764e5a4d0c Add --socket=gpg-agent 2022-08-16 13:29:06 +02:00
Phaedrus Leeds
ff8490a91e app: Add -u alias for --user
Save folks a few keystrokes. There is a command which already has a '-u'
option, document-export, but it doesn't support --user so there should
be no conflict. However '-s' is used by the info command among others,
so we can't use that for --system.
2022-08-16 10:50:29 +02:00
Patrick Griffis
6540f85511 Allow sub-sandboxes to own MPRIS names
We already allow normal apps to own MPRIS names but subsandboxes could not.

This allows them with the same dbus restrictions that they must be
prefixed by $app_id.Sandboxed.

This will be used by WebKitGTK.
2022-08-16 10:48:00 +02:00
Phaedrus Leeds
b95525eae2 doc/flatpak-run: Update docs about env vars 2022-04-23 14:54:58 +01:00
Phaedrus Leeds
f4727eacb6 doc/flatpak-run: Add more info 2022-04-23 14:54:58 +01:00
Simon McVittie
5709f1aaed 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>
2022-01-18 15:30:12 +00:00
Simon McVittie
7bbeed2b87 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>
2022-01-18 15:30:12 +00:00
Simon McVittie
dfe868d628 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>
2022-01-18 15:30:12 +00:00
Alexander Larsson
4d11f77aa7 manpages: Document the new details of --nofilesystem behaviour. 2022-01-12 19:48:34 +01:00
Simon McVittie
3acdb37fc6 doc: Mention how to get a compatible ~/.local/state with older versions
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-11-15 11:07:57 +01:00
Simon McVittie
871e684eab doc: Mention that setting XDG_STATE_HOME is a new feature
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-11-15 11:07:57 +01:00
Lionir
0fda062c96 Add XDG_STATE_HOME and HOST_XDG_STATE_HOME env variables
This gives new support for the new XDG_STATE_HOME addition to XDG_BASE_DIRS
which allows applications to use this without breaking because they would
assume $HOME/.local/state which may be unavailable to the flatpak

This adds it as .local/state as to make --persist=.local/state the same behaviour
as in new flatpak. This in turn means that the transition should be seamless between
old and new flatpak.

This also has the benefit of working if the application doesn't follow XDG spec thanks
to --persist=.local/state.

This fixes https://github.com/flatpak/flatpak/issues/4477

[smcv: Don't call nonexistent g_get_user_state_dir(); fix a reference
to XDG_STATE_DIR]
2021-11-15 11:07:57 +01:00
Simon McVittie
3ebf371fc2 run: Allow caller to replace /app and/or /usr
The pressure-vessel container tool in Steam will want to use this, to
replace /usr with a Steam Runtime container supplied by the Steam CDN,
instead of using the same Flatpak runtime that is used to run the Steam
client and non-containerized games.

If a custom /usr is used, the "official" Flatpak runtime is still the
one reflected in the metadata. It is also mounted at /run/parent,
with all its extensions, so that pressure-vessel has the option of using
its graphics drivers (by populating the custom /usr with symlinks into
/run/parent and/or /run/host).

When doing this, we need to put an empty directory on /app, because
the real /app expects to be run on top of the real runtime. It would
also be reasonable to substitute a custom replacement for /app, so
I've included support for that too.

Partially addresses #3797.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-04-07 09:52:50 +02:00
Simon McVittie
4108e02245 context: Add --unset-env option and a corresponding override
This follows up from GHSA-4ppf-fxf6-vxg2 to fix missing functionality
that I noticed while resolving that vulnerability, but is not required
for fixing the vulnerability.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-01-14 09:33:24 +01:00
Simon McVittie
6e5ae7a109 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
bbf6debec2 Add an option to share the pid namespace with the parent flatpak
As with flatpak run --parent-expose-pids, this will only work if we have
a working, non-setuid bwrap. Systems where user namespace creation is
restricted and bwrap needs to be setuid (Debian 10, RHEL/CentOS 7,
Arch Linux linux-hardened kernel) will have degraded functionality.

This option is similar to --expose-pids, except that instead of making
the subsandbox use a nested pid namespace inside the parent's, it makes
the subsandbox share the parent's pid namespace as-is, so that process
IDs in the parent and the subsandbox are interchangeable. This will
be useful if the parent and the subsandbox communicate via protocols
that assume a global view of the process ID namespace, for example
passing process IDs across an AF_UNIX socket or in shared memory.

In particular, this will be useful for Steam's pressure-vessel container
tool: the IPC between the Steam client and the "game overlay" loaded into
Steam games uses process IDs, and becomes confused if they don't match up.

This weakens the security boundary between a subsandbox and the parent,
but that's OK in some cases, especially if the subsandbox is being used
as a way to get a different runtime /usr (flatpak-spawn --latest-version
or #4018) rather than as a security boundary.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-01-12 09:55:23 +01:00
Jan Tojnar
eb57c7c07b Unify DocBook DTDs
Previously, there were three different DTDs used. Let's switch to a single one.

We will go with 4.5, since it is latest version that does not have any backwards incompatible changes.
2020-08-10 15:14:38 +02:00
Luca Boccassi
7872935e12 run: implement sandbox host os-release interface
If available, always read-only bind-mount /etc/os-release as
/run/host/os-release (or /usr/lib/os-release as fallback)
as suggested by the os-release specification:

https://www.freedesktop.org/software/systemd/man/os-release.html
2020-07-24 10:28:30 +02:00
Ryan Gonzalez
f687f6b2eb run: Add --instance-id-fd 2020-06-09 13:51:02 +02:00
Matthew Leeds
a994cdb30e tree-wide: Replace usages of whitelist/blacklist
The terms whitelist and blacklist are hurtful to some people, and per
our code of conduct Flatpak is an inclusive community. Replace them with
allowlist and blocklist which are also more clear. This terminology
change is being implemented more broadly in the software industry; see
e.g. https://go-review.googlesource.com/c/go/+/236857/
2020-06-09 09:24:48 +02:00
Simon McVittie
fe2536b844 exports: Add host-etc and host-os keywords
These are subsets of the host keyword, which provide access to operating
system files but not to users' personal files.

In particular, the experimental support for namespace-based sandboxes
in the Steam Runtime[1] uses the graphics stack from the host system,
which requires access to the host /usr/libQUAL, /libQUAL (even if the
host OS has undergone the /usr merge, the canonical paths of ELF
interpreters start with /lib), /etc/ld.so.cache, and for some libraries
on Debian-based systems, /etc/alternatives. It will not be possible to
do similar things in Flatpak without either allowing full host
filesystem access (which exposes personal files, and in any case cannot
be done by the Steam app because it is incompatible with --persist=.),
or adding the ability to expose /usr and related directories without
including the rest of the host filesystem.

To the best of my knowledge, host-etc is not necessary for anything;
I've mainly provided it for symmetry, since it's the other significant
thing that we mount in /run/host and cannot get via --filesystem=/path.

Some notes on the security/privacy implications of the new keywords:

- Neither new keyword allows anything that was not already allowed
  by "host".
- Neither new keyword can allow anything that was not already allowed
  to the user outside the sandbox.
- "host-os" allows enumeration of the installed packages on the host
  system, and often their version numbers too. A malicious app could
  use this to look for exploitable security vulnerabilities on the
  host system. An app could also use this for fingerprinting, although
  this is not a regression, because the systemd/D-Bus machine ID,
  MAC addresses, hostname, kernel boot UUID, DMI product ID and many
  other unique or relatively unique properties are already available
  inside the sandbox.
- "host-os" allows read access, and possibly write access (if the user
  has it outside the sandbox, for example members of group 'staff' in
  older Debian installations), to /usr/local.
- "host-etc" allows reading configuration files whose contents might
  be considered sensitive, such as /etc/passwd.

[1] https://steamcommunity.com/app/221410/discussions/0/1638675549018366706/

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-02-14 15:41:59 +01:00
Simon McVittie
851a34b355 doc: Point to flatpak-metadata(5) for the meanings of filesystem keywords
Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-01-23 18:40:01 +00:00
Alexander Larsson
39903eab40 Add --device=shm permission
This new permission exposes the host /dev, which is normally not visible
even with --device=all, as it is not really a device node but rather
a bunch of shared memory blocks available on the host.

This access is needed by jack, as explained at:
https://github.com/flatpak/flatpak/issues/1509

Long term I think a better solution for pro audio (like pipewire) is
a better solution, but for now we should at least allow jack apps to work.
2020-01-17 11:47:04 +01:00
Jan Grulich
a61f61870e Add support for CUPS socket 2019-12-13 17:56:22 +01:00
Matthias Clasen
cb2cadb3ad run: Improve help output for --parent-pid
Show a placeholder to indicate that this option
takes an argument. Update docs to match.
2019-12-01 16:12:36 -05:00
Alexander Larsson
e6ae979cc4 run: Document new --parent-pid and --parent-expose-pid args 2019-11-27 14:21:25 +01:00
Alexander Larsson
c486cc461e run: Document the sandbox related swtiches 2019-11-26 09:52:07 +01:00
Philip Withnall
ab5c0968e6 flatpak-run: Add parental controls support for filtering apps
Prevent the user from running a flatpak app if that app is filtered by
the parental controls applied to the user.

If flatpak is running as a system user (UID < 1000), ignore failure to
load the app filter. This could happen if a flatpak is run in the
gnome-initial-setup session, before the user’s account is created.

Includes contributions by André Magalhães.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://github.com/flatpak/flatpak/pull/2797
2019-10-03 10:42:04 +02:00
Matthew Leeds
d8853f424c doc: Improve docs for --arch options
It's not obvious what values are valid, so add a hint.

Closes: #2930
Approved by: matthiasclasen
2019-05-30 12:12:12 +00:00
Valentin David
8ce289b4c3 Add support for PCSC socket
Closes: #2778
Approved by: alexlarsson
2019-04-12 06:37:44 +00:00
Matthias Clasen
44c540a1c4 Allow overriding bus names to none
flatpak override could set a bus name policy to
talk or own, but not to none. Fix this oversight.

Closes: https://github.com/flatpak/flatpak/issues/2722

Closes: #2818
Approved by: alexlarsson
2019-04-12 06:31:05 +00:00
Matthew Leeds
d3b7bfa92d doc: Fix capitalization of gedit
It's gedit not GEdit[1][2].

[1] https://wiki.gnome.org/Apps/Gedit
[2] https://flathub.org/apps/details/org.gnome.gedit

Closes: #2788
Approved by: matthiasclasen
2019-03-30 13:02:10 +00:00
Matthias Clasen
497b784d21 doc: Add a missing comma
Fix a pervasively copied typo.

Closes: #2553
Approved by: matthiasclasen
2019-01-09 18:45:38 +00:00
Matthias Clasen
f453544aaa Document the --cwd option
Closes: #2443
Approved by: alexlarsson
2018-12-20 15:35:23 +00:00
Matthias Clasen
1bab520197 Document FLATPAK_ID
Mention this environment variable in flatpak-run(1).

Closes: #2447
Approved by: alexlarsson
2018-12-19 14:35:39 +00:00
Matthias Clasen
07a0fd2811 Document the new env vars
Closes: #2440
Approved by: alexlarsson
2018-12-17 08:14:43 +00:00
Matthew Leeds
aa19b18ee0 fixup! doc: Mention xdg vars 2018-12-11 21:32:00 -08:00
Matthias Clasen
f3748affc4 doc: Mention xdg vars
When I made the list of overridden environment variables,
I forgot the 3 most important ones, XDG_{DATA,CACHE,CONFIG}_HOME.
2018-12-11 23:36:19 -05:00
Matthias Clasen
bf7af547aa Small fixes to many man pages
Make synopses more concise in various place, improve
consistency of formatting, and fix some small mistakes
and oversights.

Closes: #2307
Approved by: matthiasclasen
2018-11-12 14:28:41 +00:00
Matthias Clasen
dd7a163a28 run: Document new options
Document --user, --system nd --installation.

Closes: #2158
Approved by: alexlarsson
2018-10-01 13:05:12 +00:00
Matthias Clasen
d83adbc71a docs: Document environment variable handling
Mention how flatpak run handles environment variables,
and include the blacklist of variables we always override.

Closes: #2141
Approved by: alexlarsson
2018-09-27 07:29:18 +00:00
Alexander Larsson
2d3f493f27 run: Add --die-with-parent to run
This is similare to the already existing arg in flatpak build.

Closes: #1946
Approved by: alexlarsson
2018-08-08 12:09:14 +00:00
Matthew Leeds
d5606cd43a doc: Fix documentation of shared options
The --verbose and --ostree-verbose options are global to all
subcommands, but --version can only be used with the main "flatpak"
command, so fix the man pages to reflect that.
2018-06-26 00:10:55 -07:00
Joonas Sarajärvi
59ecad0f29 Add ssh-auth socket support
SSH authentication sockets can be placed in a number of places, so it
is difficult for applications to just mount a fixed directory or
directories, hoping that SSH_AUTH_SOCK points somewhere inside the
mounted content.

Closes: #1764
Approved by: alexlarsson
2018-06-19 07:11:36 +00:00
Alexander Larsson
7739209a74 context: Add --allow=bluetooth
This gives access to AF_BLUETOOTH sockets in the seccomp rules. You additionally
need to give network access for the sockets to really work, because the
kernel doesn't (yet) namespace bluetooth sockets.

Closes: #1721
Approved by: alexlarsson
2018-05-28 13:06:50 +00:00
Alexander Larsson
f33fac310c Add fallback-x11 socket permission
This means use x11 if no alternative is present, and should be used
for applications that support both X11 and wayland, but want to be
sandboxed when running under a wayland compositor (but still want to
run under an X server).

Closes: #1416
Approved by: alexlarsson
2018-02-14 09:19:56 +00:00