procage 0.6.0

Process sandboxing for Rust on macOS (Seatbelt, without sandbox-exec) and Linux (Landlock, seccomp, namespaces)
Documentation

procage

๐Ÿ›ก๏ธ Process sandboxing for Rust. procage runs a child process in an OS sandbox on macOS (Seatbelt, without the deprecated sandbox-exec) and on Linux (Landlock, seccomp and namespaces). No helper binaries, no root.

It is built for programs that run commands on someone else's behalf: coding agents, MCP servers, build orchestrators. The code inside the child runs with your user id, whether it is an LLM following injected instructions or a project's build script.

cargo add procage
use procage::native::{Cage, Grants};
use procage::policy::{AbsPath, presets};

let workspace = AbsPath::new("/Users/me/project")?;
let cage = Cage::new(&presets::agent_readonly::v3(&workspace))?;
let status = cage
    .spawn(&mut std::process::Command::new("make"), &Grants::new())?
    .wait()?;

From Python (pip install procage, macOS arm64 and Linux):

import procage

policy = procage.Policy.preset("agent_readonly", 3, workspace="/Users/me/project")
done = procage.run(policy, ["make"])  # runs in the workspace

๐Ÿ“– Documentation ยท ๐Ÿ” Threat model ยท ๐Ÿ“ Design records ยท ๐Ÿ“ Changelog ยท ๐Ÿšจ Report an escape

๐Ÿšง Pre-1.0. The API may change between minor versions. Read the threat model for what procage contains and where it stops.

โœจ Features

  • ๐Ÿงฉ One typed policy, lowered per OS. Anything a host cannot enforce is a named capability gap, never a weaker rule. Cage::fit relaxes only what you name and says what would lift each relaxation.
  • ๐Ÿ”’ A hard-deny tier in every policy. Secrets, git hooks, shell startup files, launch agents, your service manager and container engines are denied last and waivable only by name.
  • ๐Ÿงน Hygiene and lifetime. Inherited descriptors are closed, secret-looking variables dropped, and every process a run started is killed when it ends, double-forked daemons included.
  • ๐Ÿงญ Explain and diff. Cage::explain names the rule that allows or denies reading, writing or executing a path and the narrowest change that would allow it; explain::diff shows what a policy change allows. The kernel checks every answer on every CI lane.
  • ๐Ÿงพ Receipts. Every finished run says how it was caged: policy digest, backend and tier, and everything accepted short of the policy.
  • ๐Ÿ”Ž Violation reports. A cage can say what the sandbox denied and which rule denied it: every denial on macOS, every refused system call on Linux. procage::suggest turns a denial into the narrowest change that would allow it on the next spawn, marking those that lift a protection.
  • ๐ŸŒ Egress through an allowlist. With the proxy feature, a run reaches the hosts an allowlist names through a proxy of its own, and no other route (macOS, Linux T1). One canonical host parser, checked resolution, no allow-all.
  • โšก Async (tokio). With the tokio feature, Cage::spawn_async returns an awaitable child, and violations arrive as a stream.
  • ๐Ÿ“ฆ Frozen presets and base profiles that let ordinary programs and developer tools start, and Cage::exec and Cage::exec_session for helpers that become the caged command.

๐Ÿ–ฅ๏ธ Platforms

Platform Mechanism Needs
๐ŸŽ macOS Seatbelt, applied through libsandbox A caller that is not itself sandboxed
๐Ÿง Linux T1 Namespaces, mounts, Landlock, seccomp Unprivileged user namespaces, Landlock ABI 1 (Linux 5.13)
๐Ÿง Linux T2 Landlock, seccomp Landlock ABI 1 (Linux 5.13), e.g. Docker's defaults

procage picks the strongest tier the host allows and never runs a child unsandboxed.

Tested releases. Supported means a green CI lane: every push runs the kernel facts and all suites on each of these runners.

Runner Release Arch Tier Measured
macos-26 macOS 26.6.2 (25G83) arm64 โ€” 2026-11-03
xcode-27 macOS 27.0.1 (26A434) arm64 โ€” 2026-11-03
ubuntu-24.04 Ubuntu 24.04.5, Linux 7.0.0-1017-azure x86_64 T2 as shipped, T1 with the sysctl 2026-11-03
ubuntu-24.04-arm Ubuntu 24.04.5, Linux 7.0.0-1017-azure aarch64 T2 as shipped, T1 with the sysctl 2026-11-03
ubuntu-26.04 Ubuntu 26.04.1, Linux 7.0.0-1017-azure x86_64 T2 as shipped, T1 with the sysctl 2026-11-03

T1 needs sysctl kernel.apparmor_restrict_unprivileged_userns=0, the setting Ubuntu documents; the tests run as an ordinary user. CI also boots mainline kernels 5.15 to 7.3 (Landlock ABI 1 to 11). Untested: macOS 15 and earlier (on 15.8.2 the developer tools fail under base V2 and V3), Intel Macs.

Known limits: no Linux PID namespace, no loopback networking on Linux and no proxy-only networking on tier T2, Landlock's file and network denials are not reported, allows on a case-sensitive macOS volume are refused, and Linux case-folding directories are untested.

โฑ๏ธ Performance

Median overhead of a caged spawn over a plain one (just bench):

Host procage, cached cage Comparison
Apple M4 Pro, macOS 26.6.2 1.0 ms sandbox-exec -p: 10.9 ms
Linux 7.0 aarch64 (Docker) T1 1.0 ms, T2 0.27 ms bwrap: 1.4 ms

On macOS a new policy costs 11.6 ms once, to compile its profile. Details: benchmarks.

๐ŸŽฏ Threat model

procage contains adaptive code running as your user inside the child, and keeps it away from your secrets, files outside the granted paths, your terminal and session, and persistence locations. An OS sandbox reduces this risk but does not remove it: kernel and OS service bugs are out of scope, so use a microVM where such an escape is unacceptable.

The threat model lists every known escape class and its status. A class counts as handled only when caged canaries on a real kernel show the refusal. Every change is specified, threat-modelled and verified in the open: see the design records.

๐Ÿ› ๏ธ Development

just ci            # every local gate: fmt, lints, tests, docs, deny, MSRV (1.99), no_std, semver
just escape        # the macOS escape suite
just linux-t1      # the Linux tests in Docker, tier T1 (`just linux` for T2)
just kernel        # the Linux suites on mainline kernels, one per Landlock ABI step
just test-outside  # the kernel facts, from a terminal outside any sandbox

The kernel facts (crates/procage-kernel-facts) re-verify on the running kernel the OS behaviour procage relies on. Facts that apply a sandbox fail rather than skip inside another Seatbelt sandbox, such as an AI agent's.

๐Ÿ“„ License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.