Sandbox: enforce the deny list on Linux with default-allow, and add a network allowlist
Summary
The native command sandbox has no network policy, and on Linux the default-allow profile does not enforce its credential deny list. So on Linux there is no profile that is both usable for everyday work and a real boundary for secrets or network egress.
Current state (main, 92084f102, docs/config.md "Native command sandbox")
- Linux
relaxedgrants broad Landlock access and only reports its read/write denies as unenforced (config.md:673): "It must not be treated as a secret or write boundary on Linux." Landlock grants are additive, so they cannot subtract~/.sshor a credential store from an allowed home directory. - Linux
strictenforces an allowlist, but "TCP/DNS remain open" (config.md:678). No profile restricts network destinations on any platform. sandbox.read_denyadds paths to protect, but on Linux it is enforced only understrict.
Prior art: Claude Code's sandbox has a strict network allowlist (sandbox.network.strictAllowlist, 2.1.219) and a filesystem deny list.
Proposal
- Linux deny list with default-allow. Add a Linux backend that can subtract paths. For example, bubblewrap with the home directory bound and each deny target replaced by an empty tmpfs or masked file, or a mount namespace that does the same. With it,
relaxedon Linux would enforce the same fixed denies andread_denyentries as macOS. Keep Landlock forstrict. - Network allowlist. A
sandbox.networksetting:open(current),deny, orallow: ["github.com:443", "crates.io:443", ...]. On Linux, this can be a private network namespace plus a filtering proxy that AFT starts (HTTP CONNECT/SOCKS, set throughHTTPS_PROXY/ALL_PROXY). Landlock ABI v4 can also restrict TCP connect by port, but not by host. Report what is enforced, the same way the sandbox reports unenforced denies today. - Out of scope here: credential substitution at egress (the command sees a sentinel value and a proxy puts in the real one). That is credential custody, and it belongs to a custody service such as cortexkit/claustrum, not to AFT. AFT's part would be a proxy hook that such a service can plug into. This issue does not ask AFT to hold credentials.
Update at v0.68.0, with a smaller proposal for item 1. It is for read denies only, and it adds no dependency.
Measured at v0.68.0 (Linux, Landlock ABI 11). I added a sandbox.read_deny entry for a folder that holds a planted test file. Then I ran a foreground, a background and a PTY command that read the file:
relaxed: AFT installs Landlock, but all three commands read the file. This agrees withsandbox_spawn.rs:2286-2288("Relaxed Linux grants all of/and enforces no deny") anddocs/config.md:894.strict: all three reads stop withPermission denied. Butstrictalso confines the command to the project roots. Thus it is not usable for a head session that works in many folders.
Proposal. On Linux, let relaxed apply read_deny. To do this, divide the root read grant along each deny path. strict divides project reads with the same procedure today (docs/config.md:900).
For a deny path /a/b/c, grant read access to all children of / but not a. Then grant all children of /a but not b, and all children of /a/b but not c. Use the children that are there at launch. A path that does not go to a deny keeps one broad grant. Writes stay as they are today. If the same procedure can also apply the built-in read denies, that is a bonus.
Limits to put in the docs:
- A new entry at a divided level stays unreadable to the current command. The next command calculates the grants again and can read it. An example is a new file directly in the home folder when the deny is below the home folder. The
strictprofile has the same limit for project roots today. - A Landlock right on an ancestor also applies below it. Thus, if the ancestors keep the right to list directories, a command can list the names in the denied folder. It cannot read the file contents.
- Landlock does not control Unix-socket connections. Thus a command can tell an unconfined process, for example the service manager, to read the path. The docs say this for
strict(docs/config.md:899). - The launch report must move the read denies that AFT applies out of
unenforced=[...].
Item 2 (network) and the write denies stay open in this issue.
Thanks for measuring this at 0.68.0, and for the smaller proposal.
Some context first. Since 0.68.0 we've built sandbox levels for shell commands (Off, Credentials, Standard and Strict; not released yet). On Linux, read denies are applied with bubblewrap mounts that hide the path when bubblewrap is installed. Without bubblewrap, the Credentials and Standard levels report the denies as unenforced, which is the same gap you found in relaxed.
Your split of the read grant closes that gap with no new dependency, and Strict already uses the same procedure for project roots. We'll add it as the fallback when bubblewrap isn't available, after the levels ship. It will cover the built-in credential denies as well as sandbox.read_deny. The docs will list the limits you described: a new entry at a split level stays unreadable until the next command, names in a denied folder can still be listed, and Unix sockets aren't controlled. The launch report will stop listing the denies it applies as unenforced.
Item 2 (network) and the write denies stay open here.