Permissions
A package grants the smallest set of permissions that lets the app’s main
feature work, with a comment on each. Everything the app can do beyond that is
left off and documented as a flatpak override command in the app’s
description, so each user decides. Permissions show on every app’s page.
- Files: grant the directory the app works in by default (
xdg-picturesfor a screenshot tool,xdg-musicfor a player), nothome. Files opened through the file chooser need no grant at all. A command-line tool is the exception: it is given files by path, with no file chooser, so it getshome(command-line tools). Check where the app saves without a dialog, too: a quick-save or export default (one screenshot tool writes to~/Desktop) needs that directory, or the file lands in the sandbox and is lost. - The app’s own
~/.something: Flatpak only redirects the XDG directories. An app that writes a dotdir in your home loses it on every restart unless the package grants it. - High-risk permissions (running commands outside the sandbox, devices,
direct PipeWire access, the whole home directory) are declared in
flatpark.yml, argued for in the PR and reviewed by a maintainer. They are granted when the app’s main feature needs them, or when leaving them out would take more overrides than a user can be expected to manage. The app page marks them with a warning. - The developer decides for their own app. When upstream says how they want the package to behave, we follow it, and declare what it needs.
For agents
Optional capabilities as overrides
Put them in the metainfo description, where the app page shows them, with a line that undoes them:
<p>A few optional capabilities are not granted by default; enable the ones you
need with "flatpak override":</p>
<ul>
<li>Reuse your host SSH keys: <code>flatpak override --user --filesystem=~/.ssh:ro org.electerm.Electerm</code></li>
<li>Serial ports: <code>flatpak override --user --device=all org.electerm.Electerm</code></li>
<li>Undo all of these: <code>flatpak override --user --reset org.electerm.Electerm</code></li>
</ul>
Adapted from Electerm.
That other apps on Flathub grant home makes a broad grant acceptable, not
necessary; ship the narrow one.
Home-directory dotdirs
Inside the sandbox $HOME is still /home/<user>, an almost empty overlay;
only XDG_CONFIG_HOME, XDG_DATA_HOME and XDG_CACHE_HOME point into
~/.var/app/<id>/. An app that writes $HOME/.app (Java’s user.home, Node’s
os.homedir(), Go’s UserHomeDir) writes into a tmpfs that disappears on exit.
Check with flatpak run --command=sh <id> -c 'echo $HOME; ls -la $HOME', and
after a restart.
- The app’s own directory:
--filesystem=~/.app:create. It lives in the real home, so it is shared with a native install and the user can find it. Or--persist=.app, which keeps it under~/.var/app/<id>/instead.--persistis ignored whenhomeorhostis also granted. - Another tool’s directory the app reads (an editor reading CLI configs):
grant it without
:create. With it, every tool the user never installed gets an empty directory in their home, and apps that take “the directory exists” to mean “the tool is installed” get it wrong. - A lock file in that directory: apps that keep their single-instance lock there start a second copy when it is lost, which then fails on a port the first one holds.
- Look for the app’s own setting first. An environment variable that moves
a directory (
PI_DESKTOP_DATA_DIR) set in the wrapper needs no grant. A tool that finds its store throughXDG_DATA_HOME(OpenCode, Goose) is never read through a grant alone, since Flatpak points that variable into the sandbox; set the tool’s own variable to the real path instead.
This is the most common severe bug in our history: four apps lost settings or data on every restart for this reason before it was understood.
Single files
Don’t grant a single file (--filesystem=~/.app.json) that the app rewrites by
saving a temporary file and renaming it over the original. The grant is a bind
mount on that file, and the rename fails with EBUSY. Grant the directory
instead.
Declaring high-risk permissions
Every permission the app page shows in red has to be declared under
policy.dangerous_permissions in flatpark.yml, with a reason, and so does
--filesystem=home. The red ones are the sandbox escapes below, the full session
or system bus, --device=all, --filesystem=host, host-os and host-etc,
the PipeWire socket, a path that holds keys, saved
passwords or login sessions (~/.ssh, ~/.gnupg, browser profiles, other apps’
data under ~/.var/app), and the keyring’s bus names
(org.freedesktop.secrets, org.gnome.keyring, org.kde.kwalletd*).
scripts/permission-levels.mjs is the
list; the site and the descriptor audit both read it.
policy:
dangerous_permissions:
- permission: --device=all
reason: >-
Talks to USB security keys directly over hidraw; Flatpak has no
narrower grant for them.
The page puts a ? next to the permission, and the reason shows when it is
hovered or tapped. Write it for a user deciding whether to install: one or two
sentences, in English, on what the app does with the permission, not that it
“needs” it. A :ro, :rw or :create suffix doesn’t matter: a declaration of
--filesystem=home covers --filesystem=home:ro. Argue the permission in the
PR as well.
The descriptor audit fails a red permission that isn’t declared, an entry
without a reason: (or written as a bare string), and an entry the manifest
doesn’t grant.
Reaching outside the sandbox (--filesystem=host, --filesystem=/,
--talk-name=org.freedesktop.Flatpak, and write access to Flatpak’s override
files: xdg-data/flatpak[/overrides], ~/.local/share/flatpak[/overrides],
/var/lib/flatpak[/overrides], since an app that can write them can grant
itself any permission) is granted only when it is declared, argued in the PR,
needed by the app’s feature, and reviewed by a maintainer. Read-only access to
those directories is not an escape.
Enpass is the example.
It checks which browser is behind its extension’s local connection by running
lsof and reading /proc, which can’t work in the sandbox. Instead of
patching Enpass, the package puts small lsof, readlink and cat scripts on
PATH that run the real commands on the host through flatpak-spawn --host.
Nothing is injected into Enpass, but the package needs
--talk-name=org.freedesktop.Flatpak, which lets the app run any host command:
it declares that, and its page says so. See
running commands on the host for when this
applies.
Running commands on the host
Some apps are crippled without command-line tools: editors, IDEs, and above
all AI agent apps, which run git, ssh, node, language servers and
whatever the user has installed. The Platform runtimes have none of the
development tools. In order of preference:
- The Sdk runtime. When what the app runs is
git,ssh,python3,makeor a compiler, take the Sdk matching its Platform (development tools). The tools are in the sandbox, the same on every host, and nothing leaves it. This is the default for IDEs, editors and coding agents. - A script for one or two host tools. When the feature needs a specific
program only the host can have (
lsofon host processes, a CLI the app manages), put a small script onPATHfor each of those commands that runs it throughflatpak-spawn --host, as Enpass does. The package then needs--talk-name=org.freedesktop.Flatpak, declared inpolicy.dangerous_permissions, argued for in the PR, with ahost-commandentry inpackaging:. Forward only what the feature needs: not every command on the host’sPATH.
A few agent packages forward every host command through a script of their own. That was a shortcut, and they will move to the Sdk later. Don’t copy it into a new package.
The PipeWire socket
Sound needs only --socket=pulseaudio: playback, the microphone and recording
what other apps play all go through it, on PipeWire desktops too. Cameras and
screen sharing go through the Camera and ScreenCast portals, which ask the user
and hand the app a PipeWire connection that sees only what was shared. Neither
needs --filesystem=xdg-run/pipewire-0.
That grant puts the PipeWire daemon’s own socket in the sandbox, and WirePlumber gives a Flatpak client read and use rights on every object in the graph. Measured with PipeWire 1.6 and WirePlumber 0.5, an app holding it can:
- open any camera, with no
--devicegrant and no portal asking; - record any other app’s video stream, including the streams the ScreenCast portal creates for another app’s screen share;
- see every device and stream and link any output to any input; the links stay after the app exits.
It can’t change settings: its writes to PipeWire’s metadata (the default
devices) are refused. :ro changes nothing, since a read-only bind of a socket
can still be connected to.
So it is a high-risk permission. Declare it in policy.dangerous_permissions
(the descriptor audit fails otherwise), and grant it only when the app’s main
feature connects to the default socket itself rather than to the fd a portal
returns. XerahS is the
case: it records a ScreenCast node by passing path=<node> to a
gst-launch-1.0 pipewiresrc child, which can only use the default socket. A
feature that merely works better with direct access (a PipeWire output plugin,
a device watcher, sharing an app’s audio with a screen share) is an
override whose line says what else it
opens, as in DeaDBeeF.
To find out whether an app needs it, look in its binaries for
pw_context_connect (the default socket) as opposed to pw_context_connect_fd
(a portal’s fd), then run the feature with
flatpak run --nofilesystem=xdg-run/pipewire-0 <app-id>. Chromium-based browsers
and Electron apps reach cameras and screen sharing through portal fds and don’t
need it.
Declaring changes to how the app runs
Anything a package does beyond starting the vendor’s build goes under
packaging: in flatpark.yml, one entry per change, with a sentence in English
and Chinese. The site shows the resulting
packaging level.
| Kind | When | Level | Allowed for |
|---|---|---|---|
support-files |
Libraries or tools added next to the app (prebuilt stacks, a second download) | Adapted | All; derived from the manifest, not declared |
seeded-config |
Settings written before first launch, e.g. turning off an updater that can’t work | Adapted | All |
injected-code |
An LD_PRELOAD library or other code in the app’s process |
Modified | Closed source only |
file-change |
Files in the vendor’s build added, removed or changed | Modified | Closed source only |
runtime-install |
The vendor’s installer runs at first launch with parts stood in for or its result changed (running it unmodified is not a change) | Modified | Closed source only |
host-command |
The app can run commands on the host (flatpak-spawn --host) |
Reduced isolation | All, declared |
sandbox-off |
The app’s own sandbox is turned off (--no-sandbox, WEBKIT_DISABLE_SANDBOX) |
Reduced isolation | All, declared |
audit-descriptor.mjs fails a package whose scripts show one of these without
the matching entry. A wrapper that only sets environment variables or flags is
Unmodified and declares nothing. Leaving out parts of the vendor package that
can’t work in Flatpak (a setuid chrome-sandbox, a pkexec updater, a
file-manager extension) is not a change.
An open-source app that can’t work without injected code or changed files is not listed; the fix belongs upstream.
When the developer has asked
If upstream states what they want — more permissions, fewer, a different default — apply it in its own PR, declare what needs declaring, and link their request. The narrow default above is for when they haven’t said.
When upstream’s Flatpak manifest changes
The pin sweep rewrites the download and nothing else. Finish-args and modules
stay as they were the day the package was written. A package whose upstream
publishes a Flatpak manifest opts into a diff, in flatpark.yml:
upstream:
manifest: packaging/linux/flatpak/com.example.App.yml
manifest is a path (.yml or .json) in the repository at source_url, which has to be an
https://github.com/owner/repo URL. The update sweep fetches that file
from the default branch twice a day and opens an issue when the finish-args,
the module names, or a shared module’s archive URL differ.
scripts/check-upstream-manifests.mjs does the comparison. It never edits a
manifest, and the pin refresh still merges: the issue is the whole process.
Two ways to close it, both a pull request:
- Grant what a feature needs. A new permission is not always enough. WordCraft’s
print dialog runs
lpstatandlp, which the runtime does not ship, so the CUPS socket comes with the tools. Upstream builds them in a module; here they come from the prebuiltcups-clientstack, in a module of the same name (prebuilt stacks). - Differ on purpose, and say so where the difference is: in the package
manifest’s
finish-argsfor a permission, inflatpark.ymlfor a module.
A permission upstream grants and the package does not stays in finish-args,
commented out under FLATPARK_DROP: and the reason. One the package grants
and upstream does not has FLATPARK_ADD: and the reason on the lines above
it. Metrolist (flatpark#1821)
does both:
finish-args:
# FLATPARK_DROP: Upstream grants the full x11 socket, which sets DISPLAY
# in a Wayland session too and keeps the app on XWayland: touchpad scrolling
# in steps and no fractional scaling (flatpark#1821).
# - --socket=x11
# FLATPARK_ADD: X11 (AWT, and the wry sign-in window parented to it) only
# in an X11 session; native Wayland everywhere else.
- --socket=fallback-x11
The reason follows the colon and may run on over more comment lines. A
FLATPARK_DROP covers the # - --arg lines under its reason, one or more; a
FLATPARK_ADD covers the one - --arg line under its reason, so two added
permissions take two. audit-descriptor fails a directive with no reason or
no finish-arg under it, a commented-out finish-arg with no FLATPARK_DROP
above it, any other spelling of the keywords, and a directive in a package
with no upstream.manifest. When upstream catches up (it stops granting what
was dropped, or grants what was added) the check reports the directive as
stale, so delete it then.
A module upstream builds and the package does not goes in
accept_missing_modules in upstream:, with a comment saying why; one only
the package builds goes in accept_extra_modules.
A permission FlatPark never follows upstream on, across a family of packages
or all of them, goes in config/upstream-manifest-filter.yml
instead of a directive in every package: under missing_permissions or
extra_permissions, with apps: app-id globs to scope it and a comment saying
why. ArtCraft’s self-updater grants (--talk-name=org.freedesktop.Flatpak and
its versions folder) are recorded there for ai.storyteller.* and
ai.artcraft.*. A * in the permission matches any text: --env=* under
extra_permissions keeps the variables a package sets out of the diff, since
they point into the /app/extra layout or work around a bug and are
explained in the manifest and metainfo.
A variable upstream sets and the package does not is still reported, and so
is a different value for one both set.
Only a module that is an archive on both sides has its URL compared. The app’s
own module is a directory upstream and an extra-data tarball here, and that
tarball’s URL moves on every release. A helper that upstream builds and this
package takes from a prebuilt stack as extra-data, such as cups-client, is
skipped too, so a new release of it upstream raises no issue; the stack’s
manifest is where to bump it.