Skip to content

The filesystem view

Part of Isolation. Previous: bubblewrap. Next: seccomp.

What it is

Inside its jail an app sees a filesystem that appjail assembled for it in a new mount namespace. Nothing of your filesystem is visible unless it was placed there, and each piece is placed read-only unless there is a reason for it to be writable.

Path in the jail What it is Access
/usr, /bin, /sbin, /lib, /lib32, /lib64 the host's system directories, so the app's libraries can find what they need read-only
/etc only fonts, the dynamic linker's cache and configuration, the local time, alternatives; with network, the files that name resolution and TLS need (hosts, nsswitch.conf, resolv.conf, ssl, CA certificates); with gpu, the Vulkan and GLVND configuration; a generated passwd and group read-only
/app the extracted AppImage read-only
/home/app the app's private home, kept between runs in ~/.local/share/appjail/apps/NAME/home read-write
/tmp, /run empty, private, discarded when the app exits read-write
/run/user/UID the runtime directory: only the Wayland socket and, per grant, the audio sockets, the filtered D-Bus socket and the portal's document folder as granted
/proc, /dev the jail's own process list; basic devices only, plus GPU and camera nodes when granted
folders and files you grant at the same path, or under /home/app for paths in your home read-only unless :rw

The app's working directory is its home, and HOME points there, so an app that writes its settings to ~/.config/... writes them into its private home and finds them again the next time.

Everything else of yours (your home, your documents, other apps, appjail's own data and manifests) does not exist in the app's world.

Why it matters

Most of what a malicious program would want from you is in files: credentials, keys, browser sessions, documents, the history of your shell. Equally important is what it would write: a program that can add a line to ~/.bashrc, drop a file in ~/.config/autostart or ~/.local/bin, or install a systemd user unit gets to run again later, outside any sandbox. The filesystem view decides both.

How appjail uses it

The extracted tree

AppImages are normally mounted with FUSE, which does not work well inside user namespaces. appjail instead extracts the AppImage once, in a helper jail with no network, validates the result (no device files, no set-id bits, no symbolic link that leaves the tree, an AppRun that resolves inside it) and records a hash of the whole tree: every path, type, permission, content and link target. Before every start, the stored AppImage must still match its pinned hash, or appjail refuses to run it; and the tree must still match its recorded digest, or appjail extracts it again from the verified image, with a warning. A tree changed on disk is never run.

Granting folders and files

You can give an app a folder (perms APP --add-dir ~/Documents/notes, read-only; :rw for read-write), a folder for one run only (run APP --dir PATH), or a single file for one run (run APP --file PATH, which also passes its path in the jail to the app). Opening a file from the desktop's menu entry does the same as --file. A path in your home appears at the same place under /home/app; a path elsewhere appears at the same path.

Some paths are never granted, whatever the mode:

  • credentials and secrets: ~/.ssh, ~/.gnupg, cloud and container credentials (~/.aws, ~/.kube, ~/.docker, ...), package-registry tokens, password stores and vaults, messaging sessions, browser profiles, mail, shell histories, and files named like keys or password databases (*.pem, *.key, *.kdbx, ...); also any folder above one of these locations, such as ~/.config, which holds ~/.config/gh (grant a subfolder instead). The check is by path: appjail does not search a granted folder for secrets you keep elsewhere in it;
  • too broad: /, your home directory or any of its parents, ~/.config, ~/.local, ~/.cache, and the system trees (/etc, /usr, /proc, /sys, /dev, /run, ...);
  • shared temporary directories: /tmp and /var/tmp. Programs keep their unix sockets there (the X server's, tmux's, agents'), and a bind mount does not stop a process from connecting to a socket, even when it is read-only: an app given /tmp could drive those programs. A single regular file there can still be opened, since a file carries no socket;
  • appjail's own files, which hold the pins and the manifests.

Some paths are refused read-write only, because something outside the jail would later run or decode what an app wrote there: ~/.local/bin, ~/.local/lib (where every Python of yours, appjail included, looks for modules), ~/.config/autostart, ~/.config/systemd, the menu entries in ~/.local/share/applications, icon themes (the desktop decodes icons outside any sandbox), thumbnailers, file-manager scripts, ~/.cargo/bin, and shell, editor and terminal-multiplexer startup files. A directory that holds one of those files counts as the file: ~/.config/git is refused read-write because git reads ~/.config/git/config. The same holds for the toolkit settings, themes and fonts that your other apps apply (~/.config/gtk-3.0, ~/.config/kdeglobals, ~/.local/share/themes, ~/.local/share/fonts, ...): a style sheet written there changes how every GTK app of yours looks, and a font is parsed by the desktop outside any jail. Read-only grants of these stay possible.

There is no override for these. The way around a refusal is always a narrower grant.

Grants are bound by descriptor

A check made on a path and a bind made later on the same path are two lookups, and between them a symbolic link can be swapped in: the check approves ~/Documents/notes, then a component is replaced with a link to ~/.ssh, and the bind follows the link. This is a classic time-of-check to time-of-use race, and it was a real flaw in Flatpak (CVE-2024-42472).

appjail opens each granted path once, then makes every check on the file it actually opened, through its descriptor: its type, where it really is, whether that place is allowed. It then passes the descriptor itself to bubblewrap (--bind-fd, --ro-bind-fd, added in bubblewrap 0.10 for this purpose), so the bind uses exactly the file that was checked, whatever happens to the path afterwards.

With network, the jail starts inside a network namespace made by pasta, which closes every inherited descriptor. A small wrapper between pasta and bubblewrap then opens each path again and refuses to start unless it is the same file (same device and inode) that was checked; appjail keeps its own descriptors open meanwhile, so those numbers cannot be reused by another file.

Connections

  • bubblewrap builds the view; namespaces make it the only one the app has.
  • The runtime directory's contents depend on other grants: the Wayland socket for the window, the audio sockets, the filtered D-Bus socket, the document portal.
  • The portal file chooser is the other way to give an app a file: you pick it in a dialog the app does not control, and the app gets that file alone.
  • The network namespace is why /tmp is not the only place sockets hide: abstract sockets live in the network namespace, which Landlock covers.
  • Decision: Extract, never mount.
  • Decision: Paths that are never granted.
  • Decision: Grants bound by descriptor.

Limits

  • What you grant, the app can read, and with :rw change or delete.
  • The system directories are readable. They hold no secrets of yours, but they reveal what software is installed.
  • A file granted read-write with --file cannot be replaced, only rewritten in place: apps that save by writing a new file and renaming it over the old one fail on such a file. Grant its folder, or use the portal file chooser.
  • A folder whose path contains : cannot be granted (the character separates the mode).
  • /run is a system tree and is refused whole, except a mount point below your own /run/media/USER (where udisks mounts removable media on Fedora; Debian and Ubuntu use /media/USER) and what is inside it. See removable media.
  • A secret is recognised by where it is, not by what it is: a key file kept in an ordinary folder you grant is visible to the app.
  • The private home is persistent and is deleted only by appjail remove, or by appjail reset, which keeps the app; an app can keep state there between runs, as any app does.

References