0096: Linux sandbox: Landlock plus seccomp, fail closed, launcher for the interpreter, gate verification marker
Status: Accepted (default; pending owner confirmation)
Amends ADR-0056 and ADR-0087.
Context
ADR-0056 defines subprocess behavior and ADR-0087 removes implicit shell fallback. Sandboxed children need filesystem and network restrictions on both backends, without falling back to an unrestricted process.
Decision
Process.sandbox(fs, net) creates a restricted
process capability. The child can read and execute fixed system
roots (/usr, /lib, /lib64,
/bin, /sbin, /etc), use the
selected filesystem root with its read/write mode, and access
/dev/null. Its environment contains only
PATH=/usr/bin:/bin. Root Net preserves
networking; none() denies it, and a non-empty host
restriction is denied because this sandbox cannot enforce host
lists. Unsandboxed cli.process is unchanged.
On Linux, sandboxed spawning uses fork and a
close-on-exec error pipe. The parent prepares Landlock rules using
the best probed ABI and masks unsupported rights. The child
applies no_new_privs, Landlock and seccomp before
execve. The filter validates the audit architecture,
rejects x32, denies socket when network is disabled
(while retaining socketpair), and returns
ENOSYS for io_uring_setup. Unavailable
Landlock returns Denied; no unsandboxed fallback is
allowed. Ordinary spawning is unchanged.
The interpreter uses an embedded-C harness-sandbox
launcher, built with $CC into the build cache, to
apply the same policy. Without a C compiler, sandboxed execution
is denied.
The gate always runs escape tests. If enforcement is
unavailable, tests verify the fail-closed result and report
sandbox: UNVERIFIED (<reason>); the check
surfaces this even in quiet mode.
HARNESS_REQUIRE_SANDBOX=1 makes UNVERIFIED a failure.
Enforcement is verified only by a run reporting enforced
Landlock.
Alternatives considered
- Keep sandboxed execution on
posix_spawn: rejected because the required child setup cannot be performed safely through Rust pre-exec hooks. - Deny only Internet socket families: rejected because pathname Unix sockets can expose host services.
- Skip tests quietly when unsupported: rejected because it hides an unverified security claim.
Consequences
Sandbox setup fails closed. The Linux gate distinguishes a tested enforced environment from an explicit UNVERIFIED result; CI must not treat the latter as proof of containment.