You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Some --filesystem options such as --filesystem=/run make Flatpak apps fail to start #5205
This issue is not a report of a security vulnerability (see here if you need to report a security issue).
Flatpak version
1.15.1
What Linux distribution are you using?
Arch Linux
Linux distribution version
N/A
What architecture are you using?
x86_64
How to reproduce
Grant all applications full access to a core runtime folder, e.g. with flatpak override --user --filesystem /run/
Try to launch any app (flatpak run foo.bar.baz)
Expected Behavior
Instead of allowing the override, Flatpak should check for permission issues (just like it does when --user is not specified)
Actual Behavior
Permissions are not checked, allowing this override to break all apps
Additional Information
I've noticed this in a situation where an end user wanted to give one specific application access to a subfolder in /run/ (flatpak override --filesystem /run/someFolder foo.bar.baz), but they've accidentally cut the command short, running flatpak override --user --filesystem /run/ instead.
From an experienced user's standpoint, it's somewhat clear what has happened: /run/ in its entirety is no longer sandboxed, but Flatpak tries to mirror some files from the actual system to /run/host/. Since we doesn't have write access to /run/, trying to create /run/host/ fails.
Solving this is as simple as, for example, resetting all overrides (flatpak override --user --reset), but it's not easy for a non-technical user to come to this conclusion
Simply not trying to mirror over files into /run/host/ if /run/ is not sandboxed is of course also an option, although I'd say that this wouldn't address the core issue
changed the title [-][Bug]: Permissions are not checked when `override`ing `--filesystem` access on the `--user` installation[/-][+][Bug]: Some --filesystem options such as --filesystem=/run make Flatpak apps fail to start[/+]on Dec 9, 2022
Flatpak should check for permission issues (just like it does when --user is not specified)
Does it really? I think you might be misunderstanding the difference between sudo flatpak override and flatpak override --user.
When you use flatpak override, all you are doing is setting up a list of permissions that will be overridden when running an app later on. To use flatpak override without --user (which is equivalent to flatpak override --system), you have to be root, but only because you are doing something that will affect every user. Nothing is written to /run at this stage.
Later, when you use flatpak run, Flatpak combines all the permissions from several sources:
defaults specified by the app maintainer (lowest precedence)
flatpak run command-line options (highest precedence)
Specifying --filesystem=/run at any of those levels has exactly the same effect, unless it is overridden by something like --nofilesystem=/run at a higher-precedence level.
The effect of --filesystem=/run is that instead of /run being a tmpfs like it is by default, you are asking Flatpak to share the host system's /run with the app's sandbox. That can't work[1], because Flatpak needs to set up directories inside /run for its own purposes (mainly /run/host and /run/flatpak), and ordinary users don't have the ability to create mount points for those directories.
The only way a permission check affects this is that you are allowed to change configuration (and maybe break Flatpak) for yourself only, whereas root is allowed to change configuration (and maybe break Flatpak) for everyone.
Probably Flatpak should just reject --filesystem=/run, ideally with a warning, similar to the way it already ignores some specific directories like --filesystem=/usr and --filesystem=/app.
[1] Technically it can work if root runs flatpak run, but don't do that. flatpak run is not designed to be run as root.
I think you might be misunderstanding the difference between sudo flatpak override and flatpak override --user.
I was indeed, thanks for clarifying! It was probably obvious from my post, but I don't use Flatpak myself. An end user of a program I work on encountered this issue, we managed to narrow it down to this, and I though I'd at least let you guys know
Probably Flatpak should just reject --filesystem=/run, ideally with a warning, similar to the way it already ignores some specific directories like --filesystem=/usr and --filesystem=/app.
I wonder if there's a "list" somewhere in the codebase with all (normally non-writable/non-existent?) sandboxed directories. Going through that list & checking if the specified path would share this sandbox directory (and if it does, don't allow the override) seems more robust than adding directories one by one
I wonder if there's a "list" somewhere in the codebase with all (normally non-writable/non-existent?) sandboxed directories.
Yes and no. The directories that are conceptually "owned" by the sandboxing framework are set up imperatively rather than declaratively (they really have to be, since each one has a different purpose and is set up in a different way), but there are also declarative and semi-declarative lists of paths that are different levels of special (dont_export_in and never_export_as_symlink() in flatpak-exports.c, and dont_mount_in_root in flatpak-context.c). /run is already in dont_mount_in_root, which excludes it from --filesystem=host.
Putting /run in dont_export_in (with /usr and /app) would be too strong: the purpose of dont_export_in is to not allow anything below that point either, like --filesystem=/usr/share/blahblah (which can't work even if we wanted to allow it, because /usr is read-only, so we would be unable to create the mount point). However, we do want you to be able to use something like --filesystem=/run/blahblah/one-specific-socket. What we should not be allowing is --filesystem=/run specifically, or anything below --filesystem=/run/flatpak or --filesystem=/run/host, or possibly others.
Maybe the ideal thing would be to expand the semantics of dont_export_in so that in addition to not allowing paths below those directories to be exported, we also don't allow paths above those directories to be exported? So that dont_export_in[] = { ..., "/run/host", ... } would imply not allowing /run/host/foo (already true) or /run (new), but would still allow /run/foo, where foo can be anything?
#5213 avoids this by refusing to share all of /run with the app, with a warning message.
Maybe the ideal thing would be to expand the semantics of dont_export_in so that in addition to not allowing paths below those directories to be exported, we also don't allow paths above those directories to be exported?
Description:
Based on a Google search, I discovered that providing access to Docker from the host requires overriding the filesystem of com.visualstudio.code with /var/run/docker.sock. However, this approach has led to complications, impacting the normal startup of Visual Studio Code.
Activity
CommandMC commentedon Dec 7, 2022
Simply not trying to mirror over files into
/run/host/if/run/is not sandboxed is of course also an option, although I'd say that this wouldn't address the core issue[-][Bug]: Permissions are not checked when `override`ing `--filesystem` access on the `--user` installation[/-][+][Bug]: Some --filesystem options such as --filesystem=/run make Flatpak apps fail to start[/+]smcv commentedon Dec 9, 2022
Does it really? I think you might be misunderstanding the difference between
sudo flatpak overrideandflatpak override --user.When you use
flatpak override, all you are doing is setting up a list of permissions that will be overridden when running an app later on. To useflatpak overridewithout--user(which is equivalent toflatpak override --system), you have to be root, but only because you are doing something that will affect every user. Nothing is written to/runat this stage.Later, when you use
flatpak run, Flatpak combines all the permissions from several sources:flatpak override --show --system)flatpak override --show --system org.gnome.Recipes)flatpak override --show --user)flatpak override --show --user org.gnome.Recipes)flatpak runcommand-line options (highest precedence)Specifying
--filesystem=/runat any of those levels has exactly the same effect, unless it is overridden by something like--nofilesystem=/runat a higher-precedence level.The effect of
--filesystem=/runis that instead of/runbeing a tmpfs like it is by default, you are asking Flatpak to share the host system's/runwith the app's sandbox. That can't work[1], because Flatpak needs to set up directories inside/runfor its own purposes (mainly/run/hostand/run/flatpak), and ordinary users don't have the ability to create mount points for those directories.The only way a permission check affects this is that you are allowed to change configuration (and maybe break Flatpak) for yourself only, whereas root is allowed to change configuration (and maybe break Flatpak) for everyone.
Probably Flatpak should just reject
--filesystem=/run, ideally with a warning, similar to the way it already ignores some specific directories like--filesystem=/usrand--filesystem=/app.[1] Technically it can work if root runs
flatpak run, but don't do that.flatpak runis not designed to be run as root.CommandMC commentedon Dec 9, 2022
I was indeed, thanks for clarifying! It was probably obvious from my post, but I don't use Flatpak myself. An end user of a program I work on encountered this issue, we managed to narrow it down to this, and I though I'd at least let you guys know
I wonder if there's a "list" somewhere in the codebase with all (normally non-writable/non-existent?) sandboxed directories. Going through that list & checking if the specified path would share this sandbox directory (and if it does, don't allow the override) seems more robust than adding directories one by one
smcv commentedon Dec 12, 2022
Yes and no. The directories that are conceptually "owned" by the sandboxing framework are set up imperatively rather than declaratively (they really have to be, since each one has a different purpose and is set up in a different way), but there are also declarative and semi-declarative lists of paths that are different levels of special (
dont_export_inandnever_export_as_symlink()inflatpak-exports.c, anddont_mount_in_rootinflatpak-context.c)./runis already indont_mount_in_root, which excludes it from--filesystem=host.Putting
/runindont_export_in(with/usrand/app) would be too strong: the purpose ofdont_export_inis to not allow anything below that point either, like--filesystem=/usr/share/blahblah(which can't work even if we wanted to allow it, because/usris read-only, so we would be unable to create the mount point). However, we do want you to be able to use something like--filesystem=/run/blahblah/one-specific-socket. What we should not be allowing is--filesystem=/runspecifically, or anything below--filesystem=/run/flatpakor--filesystem=/run/host, or possibly others.Maybe the ideal thing would be to expand the semantics of
dont_export_inso that in addition to not allowing paths below those directories to be exported, we also don't allow paths above those directories to be exported? So thatdont_export_in[] = { ..., "/run/host", ... }would imply not allowing/run/host/foo(already true) or/run(new), but would still allow/run/foo, wherefoocan be anything?exports, context: List unexported paths one per line in sorted order
exports: Never try to export paths below /run/flatpak or /run/host
exports: Never try to export /.flatpak-info
exports: Make _exports_path_expose produce a GError on failure
exports: Move error handling up into caller
exports: Don't export parent or ancestor of reserved directories
exports: Assert that recently-excluded paths are excluded
smcv commentedon Dec 12, 2022
#5213 avoids this by refusing to share all of
/runwith the app, with a warning message.That's (a large part of) what I did in #5213.
exports, context: List unexported paths one per line in sorted order
54 remaining items
exports, context: List unexported paths one per line in sorted order
exports: Never try to export paths below /run/flatpak or /run/host
exports: Never try to export /.flatpak-info
exports: Make _exports_path_expose produce a GError on failure
exports: Move error handling up into caller
exports: Don't export parent or ancestor of reserved directories
exports: Assert that recently-excluded paths are excluded
exports, context: List unexported paths one per line in sorted order
exports: Never try to export paths below /run/flatpak or /run/host
exports: Never try to export /.flatpak-info
exports: Make _exports_path_expose produce a GError on failure
exports: Move error handling up into caller
exports: Don't export parent or ancestor of reserved directories
exports: Assert that recently-excluded paths are excluded
byteshiva commentedon Jan 3, 2024
I'm sharing my insights and solutions.
Issue with File Overrides: Impact on Visual Studio Code Startup
Issue:
Encountering challenges with file overrides while attempting to provide access to Docker from the host for Visual Studio Code via Flatpak.
flatpak override --user --filesystem=/run/docker.sock com.visualstudio.codesudo flatpak override --nofilesystem=/var/run/docker.sock com.visualstudio.codeDescription:
Based on a Google search, I discovered that providing access to Docker from the host requires overriding the filesystem of com.visualstudio.code with /var/run/docker.sock. However, this approach has led to complications, impacting the normal startup of Visual Studio Code.
Guide Link:
Resolving Flatpak File Override Issues: A Step-by-Step Guide