Honest Inputs, Silent Sandboxes
Contents
- 1. A cache is a promise (and Bazel’s sandbox isn’t security)
- 2. Who pays for strictness—and what tools actually isolate
- 3. An evaluation score relies on the same invariant
- 4. Absence vs. Prohibition (and why neither guarantees a loud error)
- 5. Shaping the agent’s profile through failing probes
- 6. The silent Seatbelt failure: symlinks, firmlinks, metadata, and logs
- 7. Checking Bazel’s darwin-sandbox in source and live
- 8. What the sandbox still doesn’t cover
- 9. Checklist
- Reproduce
1. A cache is a promise (and Bazel’s sandbox isn’t security)
A build cache promises: same declared inputs → same output. Two things break that promise without raising an error: action non-determinism (timestamps, random seeds, locale) and undeclared inputs (reading host headers, $HOME, or ambient tools that were never hashed). Locally that yields a stale artifact; in a shared remote cache, one dishonest action poisons builds for every developer on the team (Bazel Sandboxing, Bazel Hermeticity).
Bazel’s sandbox exists to keep that cache key honest and match remote execution—not to provide security or confidentiality. Bazel’s own documentation states this plainly: “Sandboxing doesn’t hide the host environment in any way. Processes can freely access all files on the file system.” On macOS, Bazel’s darwin-sandbox starts with (allow default) and leaves reads open unless you explicitly pass --sandbox_block_path.
2. Who pays for strictness—and what tools actually isolate
Strict input enforcement costs build engineers, rule maintenance, and developer friction. One stylized way to think about the payoff is a toy model: if per-build time saved over native tooling is Δ(N) for N engineers, then total daily savings scale as N × builds/day × Δ(N) while platform cost scales closer to F + τ·N. Under the assumption that Δ(N) grows linearly with repo coupling (≈ N), benefit scales as N² against linear cost N and eventually crosses over.
That N² curve is an assumption, not an empirical law, and three realities routinely flatten it: modern native and mid-tier tools already ship incremental builds and shared remote caches that eat most of Δ; modular repos and polyrepos bound the subgraph any single engineer touches so Δ(N) plateaus; and migrating fast-moving ecosystems imposes step-function rule costs rather than a smooth tax τ·N. Public evidence for strict builds paying off comes mainly from large, tightly coupled monorepos paired with remote execution—for example, Buck2 reports 2–4× faster CI and user-populated caches via sandboxed remote execution (Buck2 Compared to Buck1).
Across real build tools, “isolation” means very different things—and local OS sandboxing is much rarer than folklore suggests:
| Tool | Input hashing | Local isolation | Remote cache / RE |
|---|---|---|---|
| Gradle | Task inputs (@InputFiles, properties, classpath) | None (host workspace); missing inputs cause bad hits | Shared HTTP cache; docs advise only clean CI writes |
| Turborepo | Files + declared env / globalEnv (Caching) | Strict Env Mode strips undeclared env vars (v2+); no OS FS sandbox | Team remote cache; missing env vars still fail silently if app falls back |
| Nx | Declared file, env, and runtime inputs | Open-source local Nx has no OS FS sandbox; Nx Cloud Ultracache traces file reads on Workers (Remote Cache) | Local + Nx Replay remote cache (tracing observes, does not block) |
| Pants | Content-addressed digests + dep inference | Ephemeral per-process TempDir with declared inputs (local.rs); no namespaces or Seatbelt locally | Optional docker_environment (Environments) or REAPI |
| Buck2 | Action digest (command + inputs) via DICE | Runs directly in checkout / buck-out (local.rs); --isolation-dir isolates daemon state, not FS reads (Isolation Dir) | RE-first: sandboxing lives on RE workers so all users write to cache |
| Bazel | Action digest (command, env, inputs, toolchains) | processwrapper (symlinked execroot); linux-sandbox (namespaces, RO host FS, opt-in --experimental_use_hermetic_linux_sandbox); darwin-sandbox (sandbox-exec: writes restricted, reads open) | Remote cache + REAPI; local sandboxing acts as a parity check for RE |
3. An evaluation score relies on the same invariant
I ran into the same input-honesty invariant while building wteval to evaluate coding agents (agent-isolation.md). In a build system, the key is the hash of declared inputs and the artifact is the output. In an agent evaluation, the experimental condition is the key and the score is the output:
| Build system | Coding-agent evaluation |
|---|---|
| Cache key (declared inputs) | Task statement + workspace at base commit + agent config |
| Cached output | The evaluation score (pass/fail verdict) |
| Undeclared input | Reference fix, later git commits, prior runs, other sessions’ transcripts |
| Dishonest result | An unearned pass attributed to the base prompt |
| Symptom in the log | None. The record looks completely clean. |
The agent does not have to be adversarial for this to happen, only resourceful. When a task is hard, it searches—and a search that wanders outside the workspace silently invalidates the measurement.
4. Absence vs. Prohibition (and why neither guarantees a loud error)
There are two structural ways to keep an undeclared input out of a process: absence (the file does not exist in the filesystem view the process can see) and prohibition (the file is on disk, and an OS policy denies access).
It is tempting to say “absence fails loudly with ENOENT, whereas prohibition fails silently.” That is false for missing required inputs. In a build system, a symlinked execroot still fails silently whenever tools have lookup fallbacks: shells fall back to PATH (/usr/bin), C/C++ compilers fall back to /usr/include or host SDKs, interpreters fall back to sys.path, optional configs fall back to defaults, and Bazel’s darwin-sandbox leaves absolute host paths readable.
Absence’s real advantage shows up when withholding forbidden inputs (secrets or evaluation answers): a file that literally does not exist in a container, VM, or mount namespace cannot be read, even if the process ignores ENOENT. Prohibition leaves the answer sitting on disk and bets everything on a deny rule matching the kernel’s path:
| Dimension | Absence (VM / container) | Prohibition (host Seatbelt) |
|---|---|---|
| Mechanism | File is never mounted in process view | File is on disk; policy denies it |
| Build analogy | RE worker; hermetic Linux sandbox | Bazel --sandbox_block_path on macOS |
| Agent-eval analogy | Ephemeral VM/container, base commit only | Outer sandbox-exec on workstation |
| Missing required input | Still falls back (PATH, /usr/include) | Same |
| Withheld forbidden input | Cannot be read (not mounted) | Rule mismatch → silent allow |
A local coding agent needs a home directory, provider authentication, and host toolchains, so on a macOS workstation we started with prohibition. That put the entire isolation guarantee on the bottom-right box.
5. Shaping the agent’s profile through failing probes
We tested the agent CLI’s built-in isolation options first, because they are the obvious answer (agent-isolation.md):
| Layer | What the probe showed |
|---|---|
| The agent CLI’s sandbox flag | Restricted the shell tool only; the built-in file tool still read home directories |
| The agent CLI’s workspace-only setting | No effect in print mode |
| Outer Seatbelt profile around full argv | Kernel-enforced, inherited by every child; held for both shell and file tool (inner sandbox disabled because nested sandbox_apply fails) |
Every rule in the outer profile was then forced by a probe that came back wrong:
| Probe came back wrong | Fix |
|---|---|
Keychain query answered errSecItemNotFound (keychain reachable) | Deny ~/Library/Keychains and securityd mach services (errSecParam) |
| Keychain CLI binary still executed despite a read denial | deny process-exec (literal "/usr/bin/security"), not just file-read* |
| Agent read its own CLI store holding 127 prior conversations | Generate profile per run: deny every conversation artifact present at launch |
| A sibling IDE agent’s store held orchestrator transcripts | Enumerate every agent front end installed on the machine |
| Agent listed the run’s parent directory | deny file-read-data (literal <dir>); verified on macOS 27.0.1 that file-read-metadata and file-read* break git init (rc=128) |
| Profile copied from another machine denied nothing | Render paths on the host machine and verify every rule path exists |
6. The silent Seatbelt failure: symlinks, firmlinks, metadata, and logs
On macOS, /tmp, /var, and /etc are symlinks into /private, users create symlinks mid-path, and APFS firmlinks expose /private under /System/Volumes/Data/private (/usr/share/firmlinks). Seatbelt matches (deny …) rules only against the kernel’s canonical path:
Measured on macOS 27.0.1 (build 26A434, 2026-11-30) via scripts/probe_seatbelt_symlinks.sh using one-rule (allow default) profiles. First, path resolution across symlinks and APFS firmlinks:
| Category | Deny rule (file-read*) | Access tested | Result |
|---|---|---|---|
/tmp symlink | subpath "/tmp/…/blocked" (pre- or post-mkdir) | /bin/cat via /tmp/… or /private/tmp/… | ALLOWED — ignored |
/tmp resolved | subpath "/private/tmp/…/blocked" | /bin/cat via /tmp/… or /private/tmp/… | DENIED |
/var/tmp symlink | subpath "/var/tmp/…/blocked" | /bin/cat via /var/tmp/… or /private/var/tmp/… | ALLOWED — ignored |
/var/tmp resolved | subpath "/private/var/tmp/…/blocked" | /bin/cat via /var/tmp/… or /private/var/tmp/… | DENIED |
/etc symlink | literal "/etc/hosts" vs "/private/etc/hosts" | /bin/cat /etc/hosts | /etc ALLOWED; /private/etc DENIED |
| Mid-path symlink | subpath "…/mid_link/sub" (abs or rel) | /bin/cat via link or real_dir | ALLOWED for both |
| Symlink node | subpath "…/mid_link" | /bin/cat via link vs real_dir | Link DENIED; real_dir ALLOWED |
| Resolved target | subpath "…/real_dir/sub" | /bin/cat via link or real_dir | DENIED for both |
| APFS firmlink | subpath "/private/tmp/…/blocked" | /bin/cat /System/Volumes/Data/private/tmp/… | DENIED (no bypass) |
| APFS firmlink rule | subpath "/System/Volumes/Data/private/tmp/…" | /bin/cat via /private/tmp/… or /System/Volumes/Data/… | ALLOWED — ignored (realpath keeps prefix) |
Second, Python operations (open, os.stat, os.listdir), rule scopes, and (debug deny) unified logs:
| Probe | Rule | Result |
|---|---|---|
Python (open, stat, listdir) | file-read*, file-read-metadata, or file-read-data on /tmp/… | ALLOWED across all 3 ops and all 3 rules |
Python (open, stat, listdir) | file-read-metadata on /private/tmp/… | stat DENIED; open & listdir ALLOWED |
Python (open, stat, listdir) | file-read-data on /private/tmp/… | open & listdir DENIED; stat ALLOWED |
(debug deny) + log show | Ignored /tmp/… rule (sender=="Sandbox") | ALLOWED, stderr none, 0 log entries |
(debug deny) + log show | Matched /private/tmp/… rule (sender=="Sandbox") | DENIED (EPERM), logged (deny(1) file-read-data /private/tmp/…) |
Two subtle takeaways came directly out of expanding these probes. First, realpath alone is not enough on APFS macOS: os.path.realpath("/System/Volumes/Data/private/tmp/…") preserves /System/Volumes/Data because firmlinks are not symlinks, yet Seatbelt silently ignores any rule carrying that prefix. Second, (debug deny) and macOS Unified Logging only catch rules that fire: actual denials appear under sender=="Sandbox", whereas an unmatched rule falls through to (allow default) with zero stderr warnings and zero log lines.
7. Checking Bazel’s darwin-sandbox in source and live
Reading Bazel master at 24c5dcf (DarwinSandboxedSpawnRunner.java, SandboxOptions.java, FileSystem.java, UnixFileSystem.java, unix_jni.cc) and running Bazel 9.3.3 with --spawn_strategy=darwin-sandbox --sandbox_debug shows how Bazel handles the same macOS Seatbelt semantics (seatbelt-symlink-probe.md):
| Dimension | Bazel darwin-sandbox | Agent-eval profile (make_base_profile.py) |
|---|---|---|
| Base policy | (allow default) + (debug deny) | (allow default) |
| Writes | (deny file-write*), then allowlist (/dev, /private/tmp, /private/var/tmp, execroot, Caches) | Allowed except enumerated deny list |
| Reads | Unrestricted unless --sandbox_block_path | Denied for enumerated list (per-run) |
| Other rules | (allow process-exec (with no-sandbox) (literal "/bin/ps")) | deny process-exec (keychain CLI), deny mach-lookup (securityd) |
| Network | Allowed by default (--sandbox_default_allow_network=true, SandboxOptions.java:292); when off, network-inbound remote filter “compiles but has no effect” (DarwinSandboxedSpawnRunner.java:287–294) | Not blocked for the agent |
| Path handling | resolveSymbolicLinks(); spells /private/tmp, /private/var/tmp | realpath; reports missing paths |
Bazel resolves symlinks before rendering sandbox.sb, with one fallback path in SandboxOptions.getInaccessiblePaths: when blockedPath.resolveSymbolicLinks() throws IOException, Bazel catches it and adds the raw blockedPath. Tracing FileSystem.resolveSymbolicLinks (FileSystem.java:485–493) → appendSegment (FileSystem.java:417–446) → UnixFileSystem.resolveOneLink (UnixFileSystem.java:72–85) → JNI NativePosixFiles_readlink confirms what happens on macOS: readlink(2) returns EINVAL for non-symlinks (handled as nullptr), but returns ENOENT for missing paths, throwing FileNotFoundException (IOException). Catching it discards the already-resolved /private/tmp prefix—whereas Python’s os.path.realpath resolves existing parent prefixes even when the leaf is missing.
Running a minimal genrule workspace on Bazel 9.3.3 (--spawn_strategy=darwin-sandbox --sandbox_debug) verified all four cases:
| Bazel flag | Rule emitted in sandbox.sb | Action result |
|---|---|---|
| (none — default) | (no deny file-read*, no deny network*) | Read /tmp/…/existing_dir/secret.txt succeeded |
--sandbox_block_path=/tmp/…/existing_dir | (subpath "/private/tmp/…/existing_dir") | Read DENIED |
--sandbox_block_path=/tmp/…/missing_dir | (subpath "/tmp/…/missing_dir") | Action created dir (/private/tmp writable) and read it: succeeded |
--sandbox_block_path=/tmp/…/dangling_link | (subpath "/tmp/…/dangling_link") | readlink succeeded; after target creation, read succeeded |
Excerpt of the actual sandbox.sb captured from Bazel 9.3.3 for the missing-path run (user home/temp paths redacted):
(version 1)
(debug deny)
(allow default)
(allow process-exec (with no-sandbox) (literal "/bin/ps"))
(deny file-write*)
(allow file-write*
(subpath "/dev")
(subpath "<HOME>/Library/Caches")
(subpath "<DARWIN_USER_TEMP_DIR>")
(subpath "/private/var/tmp")
(subpath "<HOME>/Library/Developer")
(subpath "<HOME>/Library/Logs")
(subpath "/private/tmp/.../execroot/_main")
(subpath "/private/tmp")
(subpath "<DARWIN_USER_CACHE_DIR>")
(literal "/private/tmp/.../stats.out")
)
(deny file-read*
(subpath "/tmp/.../missing_dir")
)
Scope matters here: for pre-existing host directories (the normal use case of --sandbox_block_path, such as blocking /opt/homebrew or /usr/local), Bazel resolves symlinks cleanly and blocks reads as designed. The fallback fails open only in two narrow cases: a blocked path under a symlinked prefix (/tmp, /var) that does not exist when the action starts and appears before read, or a pre-existing dangling symlink under /tmp or /var—where even readlink succeeds despite SandboxOptions.java:226–227 explicitly assuming the symlink itself will remain blocked.
8. What the sandbox still doesn’t cover
| Gap | Current mitigation |
|---|---|
Network: a single curl fetched a public reference file under an otherwise working profile | Private target repo whose reference is not on the public internet (a property of the task set, not the sandbox) |
| Scoring executes agent-edited code on the host | Separate workspace, evaluator’s own tests, deny-network profile |
| The agent CLI’s own auth token stays readable | Required to authenticate to the provider; accepted |
| A deny list covers only what someone enumerated | Re-probe after every CLI upgrade |
sandbox-exec is deprecated by Apple (SANDBOX-EXEC(1)) | Accepted for host wrappers; moving to true Absence requires a Linux VM or container boundary |
9. Checklist
| Do | Because |
|---|---|
Resolve every rule path with realpath and strip /System/Volumes/Data | Unresolved symlinks and APFS firmlink prefixes silently match nothing |
| Report rule paths that don’t exist at render time | A missing path can leave a dead rule or trigger a raw-path fallback |
| Probe the expected denial, not only task success | Under (allow default), a passing run proves nothing about isolation |
Do not expect (debug deny) logs to flag dead rules | Unified Logging records matched denials, never unmatched rules that fall through |
| Probe both the shell and the agent’s built-in file tool | One has held while the other leaked |
| Record rendered profile text + SHA-256 hash in provenance | Unreconstructable isolation is not audit evidence |
| Re-probe after OS, profile, runner, or agent CLI upgrades | Each of those four has silently broken isolation |
Reproduce
The self-contained probe script is pinned at scripts/probe_seatbelt_symlinks.sh (full recorded results and Bazel 9.3.3 notes in docs/seatbelt-symlink-probe.md, red-team evidence table in docs/drafts/honest-inputs-review.md).
Run it directly on macOS (no sudo, ~3 seconds, cleans up its temporary directories under /tmp and /var/tmp on exit):
curl -fsSL https://raw.githubusercontent.com/zywkloo/wteval/2a2effb8361771ade6ae52afa2eb71a02194c864/scripts/probe_seatbelt_symlinks.sh | bash @misc{zhang2026honestinputssilent,
title = {{Honest Inputs, Silent Sandboxes}},
author = {Victor Zhang},
year = {2026},
month = nov,
howpublished = {\url{https://zywkloo.github.io/blog/honest-inputs-silent-sandboxes/}},
url = {https://zywkloo.github.io/blog/honest-inputs-silent-sandboxes/},
}