Isolation¶
When you start an app with appjail run, it does not run as an ordinary process of your session. appjail builds a
jail around it: a set of restrictions that the Linux kernel enforces on the app and on every process it starts. This
part explains what the jail is made of, layer by layer, and why each layer is there.
The same construction, with less inside it, also holds the steps that come before an app ever runs: the download, the extraction of the AppImage, the verification of an attestation, the conversion of an icon. Those are the helper jails; the jail the app itself runs in is the app jail.
The layers¶
Read from the inside out:
- Namespaces give the app its own view of the system: its own mount table, process list, user ids, hostname, inter-process communication and network. What it does not see, it cannot reach by name.
- bubblewrap is the program that creates those namespaces without root and fills the new mount table with exactly what the app should see.
- The filesystem view is what appjail asks bubblewrap to put there: the read-only system, the app's own tree, a private home, and the folders and files you grant.
- seccomp limits which requests the app may make to the kernel at all, because a namespace hides things but every system call still reaches the same kernel.
- Landlock closes one gap the namespaces leave open in one configuration: sockets that live in the network namespace rather than in the filesystem.
- Process lifetime makes sure the jail ends when the app ends, and that nothing of it keeps running when appjail is stopped.
Why several layers¶
A namespace decides what a process can see; it does not change what the kernel will do for it. A process that sees nothing can still ask the kernel for a new namespace, load a filter, open a socket of an obscure family or call into a subsystem with a history of privilege-escalation bugs. Each of those requests reaches the same kernel that runs the rest of your session. That is why the namespaces are combined with the removal of every capability, a seccomp filter on system calls, the refusal of nested namespaces, and Landlock: each closes a way around the others.
None of the layers is new. Flatpak builds its sandbox from the same parts, and appjail follows its choices where they apply (the seccomp deny list, the allowed socket families). What differs is what goes in: appjail starts with less (no session bus, no sound, no network, no GPU by default) and checks the openings it makes more closely, because it has to assume that what runs inside was never reviewed by anyone.
Helper jails¶
The helper jails are built from the same parts, with even less inside:
| Helper jail | Sees | Network |
|---|---|---|
| download (also catalogs and pinned tools) | the read-only system, /etc/ssl, the downloader, one staging directory |
a private namespace made by pasta; without pasta the step is refused, unless APPJAIL_ALLOW_HOST_NETWORK=1 gives it the host's, with a warning |
| attestation check | the downloaded file, the attestation bundles, a scratch directory, the pinned gh |
as the download |
| extraction | the AppImage (read-only) and one work directory | none |
manifest history (git) |
appjail's configuration directory | none |
| icon conversion | the SVG and an output directory | none |
| D-Bus proxy | your session bus socket and a private directory for the filtered one | none |
| private audio graph | its own runtime directory and your audio server's socket | none |
Each helper jail also refuses nested namespaces and loads the same seccomp filter as the app jail, because some of them run code taken from the AppImage (the extraction fallback runs the AppImage's own runtime) and all of them parse untrusted data.
References¶
- Flatpak documentation, Sandbox permissions: the sandbox appjail's construction is closest to.
- Michael Kerrisk, Namespaces in operation, part 1, LWN.net, 2013: an introduction to the namespaces the jail is built from.