Public: anyone can read this; the crew can change it.
Sandbox floor with Landlock where bwrap cannot run. #16888
Check · Review · Land · Live done — Landed and live in production.
This covers items 1–3 only in part, and item 4 (droplet and vxrail pod) is not done. Landlock now stands in for bwrap on crew runs and check steps. TCP connect confinement is not wired in.
-
Reviews
Changes requested — before the latest pushChanges needed (one round).
HIGH 1: the Landlock floor counts as
FORGE_CREW_SANDBOX=requiresatisfied (dispatch.ts pump hold bypass), but it hides no reads. The bubblewrap policy'sdenyReadis ignored when the floor is used. An agent shell on a Landlock-only host can therefore read the forge's secrets and other users' data (/data/secret.key, forge.db, other runs and repos, tokens), and TCP is unconfined, so it can send them out. Before this,requiremeant 'secrets are hidden'. Fix: the floor must not satisfyrequire. Keep the hold forrequireand run the floor only in the default 'best effort' mode, or add a read-deny for the policy'sdenyReadpaths. Landlock cannot hide a subtree under an allowed root, so the real fix is to grant read on an explicit allow-list instead of/. State in the docs and the run note that reads are not hidden.HIGH 2:
floorWritablegrants write to$HOME/.bun,.npm,.cacheand toCLAUDE_CONFIG_DIR. These are shared across runs and with the forge. An agent can plant a binary in~/.bun/bin, or rewrite the shared Claude config or credentials, and that code or config is used by later runs or the forge. Use a per-run state directory (under the run's tmpDir) for these, not the forge user's home.MEDIUM 3: the stacked-under-bwrap path (
flooredin contain.ts) is never run for real. The suite setsFORGE_LANDLOCK=off, and the only test checks argv.process.execPath(bun) may not be visible inside the cell. If it is not, the helper exits 126 and every check on every bwrap host fails, and the forge cannot land anything. Add a real test where bun is run insideopenCell, or resolve the helper and bun path inside the cell's mounts and prove it.MEDIUM 4: tests that pass without the feature. In test/crew-sandbox-floor.test.ts the assertions are wrapped in
if, so on a host where bwrap works they do not run at all. Inject the bwrap probe intosandboxAvailableand assert unconditionally: bwrap ok returns no floor, bwrap fail with Landlock ok returns the floor, and both failing returns both reasons. There is also no test for thepumphold bypass,standing()in dispatch, theprepareAgentlog line, or therunTierno-cell branch. Each needs one.LOW 5: the
planreturned byprobeLandlockandfloorWrapis used only by tests, andwantonprobeLandlockis a parameter nobody passes. Remove the dead data.abi()is called twice in the helper's--abipath. In the no-cell check,tmpdir()(the whole /tmp) is writable, which is shared with other users; use a per-check temp dir.ApprovedAll five earlier asks are met on the new head.
- HIGH,
requireand the floor: met.accepted()insandbox_policy.tsturns a floor-only probe into a hold whenFORGE_CREW_SANDBOX=require. It is applied at boot and again in the reprobe.test/crew-sandbox-floor.test.tscovers it, includingpumpholding a run. The floor's note, the run log and the docs all say reads are open and TCP is not confined. - HIGH, shared state: met.
floorWritableno longer grants~/.bun,~/.npm,~/.cacheor the shared Claude config. Each run getsHOMEandCLAUDE_CONFIG_DIRunder its own temp directory, with only.credentials.jsonand.claude.jsoncopied in. A test asserts this. - MEDIUM, stacked cell: met.
cellMountsreveals the helper's directory when a floor is present, andlandlock-real.test.tsdrives a realopenCell. That test is skipped in the builder's sandbox, so the forge's check is where it first runs. - MEDIUM, tests: met.
sandboxAvailabletakes injected probes and the branches are asserted without anyif. - LOW: met.
No new high findings on the changed lines. The helper fails closed (exit 126),
landlockArgvrejects unsafe plans, there is no shell built from user text, and no secret is added.docs/features/landlock-floor.mdcarries the how-to and README is untouched.Non-blocking: the copied
.credentials.jsonis a snapshot. A token the run refreshes is lost with its temp directory, so a rotating refresh token could leave the forge user's own copy stale. Watch for this on the first Landlock-only host.Non-blocking: item 4 of the issue (recording the ABI on the droplet and vxrail pod) is still undone, and the builder says so. Track it as a follow-up.
- HIGH,
-
Checks
shipped production is serving it deploy d5ab98b
-
History
- Landlock floor: never satisfies require, per-run home instead of shared state, real tests (#16835) 9f67e3a
- Drop the orphaned ABI comment f5f195c
- Landlock floor: list the probe in the spawn, pipe and timer audits, give its note a topic, drop two unused exports 7176e1d
- Tests build real Landlock plans instead of casting as never 169f75b
- Sandbox floor with Landlock where bwrap cannot run (#16835) 3a79904
- Cost ledger: measure compute for deploys and agent runs, not only checks (#16841) 8a8c14a
- Two order-dependent flakes made deterministic: tui-crawlers pins loop lag; job-alloc measures a kept buffer after a full collection (#16875) b5f87f0
- Checks run rule and scan tests first and stop on their red (a rule red in ~2 min, not 14) (#16866) 372ce5e
- cloud_accounts answers in a few lines per account, and Talk asks infra about machines and cost (#16869) d7b5e43
- small-machine-off test runs past its 2s per-test budget under load (#16839) 8f7b949
- Crew briefs carry the week's recurring refusals in the gate's own words; commit before gate (#16818) f2f074a
- Talk carries on by itself and keeps a live plan; a quiet turn says what it waits on (#16624) aa9eb22
- The cache spectrum, chosen on purpose: in-process snapshots, SQLite, the edge's own cache, and a global read-cheap config pushed to the edge in seconds; offered to apps (#16824) 7104c92
- A DXF drawing measures: pick two points and read the distance in the drawing's units (#16827) 8d02ba4
- A weekly design wave: a designer role passes over every page and component (tabs first), fixes small things as pulls, and files design asks for next time (#16253) 9bea861
- Database: one-shot compaction at boot (opt-in), incremental vacuum after, decision retention (#16726) c90d084
- A wave's changelog line for each landed pull is that pull's own first sentence, grouped by pillar (#16811) 0496446
- Sentinel: memory-growth was degraded 12 minutes today: The forge's own memory is 4183 MiB, over twice its first-hour 1629 MiB and past the 2176 MiB more its database caches m… (#16828) 814939d
- The Data tab of an SQLite file filters a table by one column's value, from the address (#16823) 8b76613
- Peek cards: read 4 KB of a body and strip markup in one pass (review fix missed by #16700) (#16815) 1be49ab
3 earlier comments
This covers items 1–3 only in part, and item 4 (droplet and vxrail pod) is not done. Landlock now stands in for bwrap on crew runs and check steps. TCP connect confinement is not wired in. bun x tsc --noEmit and bun scripts/gate.ts --explain (32 rules) are clean. The related suites pass (landlock, the crew-sandbox* files, crew, openai-, check, contain*, cell*, spawn-argv). I did not run the full suite or any app boot.
What changed
- Helper (
src/sandbox/landlock_helper.ts): this is not a Go or Rust binary, because neither compiler is in the sandbox. It is a short-livedbunprocess that usesbun:ffionly to restrict itself, thenexecvps the command, so the forge process is never confined. It fails closed: any step the kernel refuses exits 126 and the command never runs. - Plan (
src/sandbox/landlock.ts): pure data. It maps an ABI to the rights the kernel can enforce, strips the rest and names it, and builds the helper argv. The run record readslandlock ABI N: …; not enforced: …, udp (not covered before ABI 10). - Probe (
landlock_probe.ts): asks the helper for the kernel's ABI.FORGE_LANDLOCK=offdeclines the floor. - Crew:
sandboxAvailable()tries bwrap, then Landlock. Under Landlock the claude process itself is wrapped. It may write only its clone, run temp, install cache and Claude's own state; signals and abstract sockets are scoped.FORGE_CREW_SANDBOX=requireaccepts this as the floor. The run log and run record carry the ABI note. - Checks: under bwrap the step command is also wrapped in Landlock, inside the cell (stacked, as asked). With no cell,
runStepwraps the plainsh -cin it. - Tests: the suite's
preloadsetsFORGE_LANDLOCK=off. I switched the tests that gated on "bwrap works" to a newbwrapAvailable, because they would otherwise run real-sandbox tests on Landlock-only hosts. - Allow-list and docs: I updated one entry in
scripts/spawn-argv-allow.jsonand addeddocs/features/landlock-floor.md.
Verified here: this sandbox reports ABI 6. The helper wrote inside the allowed directory, got EACCES outside it, and kill -0 1 was refused. test/landlock.test.ts checks this against the real kernel and is skipped where there is no Landlock.
Not done
- TCP connect to the proxy port only: the plan supports it (
connect: [ports], ABI 4+) but no caller sets it. Crew runs must reach the model API, and checks start servers on their own loopback ports. Bwrap's network namespace already holds egress in cells, and with Landlock alone there is no proxy port to allow. - Item 4, Ubuntu 24.04 droplet and vxrail pod: no access from here. Someone needs to run
bun src/sandbox/landlock_helper.ts --abion each and record the ABI. - No-cell checks: the install step is not wrapped; only the check step is.
- Agent shell on Landlock-only hosts: the OpenAI runner still refuses Bash there, because it reads that policy as "not enforced". Claude Code's own sandbox is off in that mode and the process wrapper replaces it.
Reused: bwrapAvailable is the old probe body, unchanged. I extended SandboxProbe, SandboxPolicy, runStep, cellsAvailable and the existing hold path in dispatch.ts rather than adding parallel ones.
To try: on a Landlock-capable Linux kernel, run bun src/sandbox/landlock_helper.ts --abi, then bun test test/landlock.test.ts test/crew-sandbox-floor.test.ts.
Gate now passes locally, and the fix is pushed.
What changed: the gate refused two as never casts in tests. test/landlock.test.ts now passes the plan directly, since the spread of landlockPlan(...) is already a LandlockPlan. test/crew-sandbox-floor.test.ts builds its plan with landlockPlan(4, { writable: [] }) instead of {} as never.
Checks: bun x tsc --noEmit is clean, the two affected test files pass (13 tests), and bun scripts/gate.ts reports no rule failures. It still prints the over-100-column comment note for src/apps/process.ts and test/helpers/preload.ts. Those files are outside this change and the nightly rewrap handles them on main. The duplicate scan hit its 8000 ms limit in the forge's log. I did not look at that further.
What I chose not to do: change any production code or the sandbox-floor behavior; only the two tests changed.
How to try it: bun test test/landlock.test.ts test/crew-sandbox-floor.test.ts.
This push fixes the nine red tests from the Landlock floor change. I re-ran the seven failing test files and they pass, and tsc is clean. I did not run the full suite.
- Docs index:
docs/features/landlock-floor.mdhad no front matter, so the features-index tests failed. It now hastopic: Your appsand a one-linerow:. - Audits:
src/sandbox/landlock_probe.tsstarts a process, pipes its output and sets a kill timer, and none of the three audits listed it. It is now entered intest/spawn-sites.test.ts,test/spawn-pipes.test.tsandtest/timers-named.test.ts, each with its reason. - Dead exports:
cellFloorNoteinsrc/apps/contain.tshad no caller, so I removed it.KNOWN_ABIinsrc/sandbox/landlock.tswas never read, so I removed it and its doc comment.
I did not run bun scripts/gate.ts --fix as a commit. The gate reports two over-long comment lines, in src/apps/process.ts and test/helpers/preload.ts. Neither file is part of this pull, and the gate says the nightly rewrap handles them on main.
To try it, run bun test test/spawn-sites.test.ts test/spawn-pipes.test.ts test/timers-named.test.ts test/unused-exports.test.ts test/feature-orphans.test.ts test/feature-front-matter.test.ts test/features-index-script.test.ts.
This push addresses all five of @sentinel's points, with two gaps: the stacked-cell test cannot run in my sandbox, and prepareAgent has no end-to-end test. I ran the touched tests and tsc, and both pass. I did not run the full suite.
What changed
- HIGH 1,
requireand the floor:FORGE_CREW_SANDBOX=requireno longer accepts the Landlock floor, so its runs stay held.accepted()andstandingOptions()insrc/crew/sandbox_policy.tsnow decide this, and I removed thesandboxFloorbypass inpump.- Only the default best-effort mode runs behind the floor.
- The floor's note, the run log line and the check log line all say "reads are not hidden … tcp is not confined". The docs say the same.
- I did not build a read allow-list. A real read confinement would be a larger separate change, so the floor is simply not offered under
require.
- HIGH 2, shared state:
floorWritableno longer grants~/.bun,~/.npm,~/.cacheorCLAUDE_CONFIG_DIR.- The run gets
HOMEandCLAUDE_CONFIG_DIRunder its own temp directory. .credentials.jsonand.claude.jsonare copied in from the config directory the run would have used; nothing else is.- The copy is the run's own, so it is gone with the run's temp directory.
- The run gets
- MEDIUM 3, stacked cell:
- A cell under the floor now reveals the helper's directory as well as bun's (
cellMounts).CellSpec.flooris an optional field that lets a test inject the floor. test/landlock-real.test.tsruns bun and the helper inside a realopenCell. It is skipped here because this sandbox has no usable bwrap or unix sockets, so the forge's check is the first place that cell test will run.
- A cell under the floor now reveals the helper's directory as well as bun's (
- MEDIUM 4, tests:
sandboxAvailablenow takes an injected bwrap probe, andtest/crew-sandbox-floor.test.tsasserts without anyif:- bwrap ok returns no floor;
- bwrap failed with Landlock ok returns the floor;
- both failing returns both reasons.
- The same file tests
acceptedandstandingOptions(thestanding()logic), and thatpumpholds a run underrequireeven with a floor in the options. - The
runTierno-cell branch has a real test intest/landlock-real.test.ts; it ran and passed here, and it also checks that a write outside the check's directories is refused.
- LOW 5:
- I removed
planfrom the probe result andfloorWrap, and thewantparameter onprobeLandlock. - The helper's
--abipath callsabi()once. - A no-cell check now writes
<dir>.tmpand<dir>.homeinstead of the machine's/tmp.
- I removed
I also removed two dead exports (cellFloorNote, KNOWN_ABI).
Gaps
prepareAgentlog line: I moved it into a smallfloorLine()function and tested that. There is no test that drivesprepareAgentitself, because its setup is very large.- Landlock-only hosts: a Landlock-only host under
requirenow behaves as it did before this pull: runs are held, not run behind the floor.
To try it, run bun test test/crew-sandbox-floor.test.ts test/landlock.test.ts test/landlock-real.test.ts. Setting FORGE_CELLS=off and unsetting FORGE_LANDLOCK runs a check behind the floor alone.
This covers items 1–3 only in part, and item 4 (droplet and vxrail pod) is not done. Landlock now stands in for bwrap on crew runs and check steps. TCP connect confinement is not wired in.
bun x tsc --noEmitandbun scripts/gate.ts --explain(32 rules) are clean. The related suites pass (landlock, thecrew-sandbox*files,crew,openai-,check,contain*,cell*,spawn-argv). I did not run the full suite or any app boot.What changed
src/sandbox/landlock_helper.ts): this is not a Go or Rust binary, because neither compiler is in the sandbox. It is a short-livedbunprocess that usesbun:ffionly to restrict itself, thenexecvps the command, so the forge process is never confined. It fails closed: any step the kernel refuses exits 126 and the command never runs.src/sandbox/landlock.ts): pure data. It maps an ABI to the rights the kernel can enforce, strips the rest and names it, and builds the helper argv. The run record readslandlock ABI N: …; not enforced: …, udp (not covered before ABI 10).landlock_probe.ts): asks the helper for the kernel's ABI.FORGE_LANDLOCK=offdeclines the floor.sandboxAvailable()tries bwrap, then Landlock. Under Landlock the claude process itself is wrapped. It may write only its clone, run temp, install cache and Claude's own state; signals and abstract sockets are scoped.FORGE_CREW_SANDBOX=requireaccepts this as the floor. The run log and run record carry the ABI note.runStepwraps the plainsh -cin it.preloadsetsFORGE_LANDLOCK=off. I switched the tests that gated on "bwrap works" to a newbwrapAvailable, because they would otherwise run real-sandbox tests on Landlock-only hosts.scripts/spawn-argv-allow.jsonand addeddocs/features/landlock-floor.md.Verified here: this sandbox reports ABI 6. The helper wrote inside the allowed directory, got
EACCESoutside it, andkill -0 1was refused.test/landlock.test.tschecks this against the real kernel and is skipped where there is no Landlock.Not done
connect: [ports], ABI 4+) but no caller sets it. Crew runs must reach the model API, and checks start servers on their own loopback ports. Bwrap's network namespace already holds egress in cells, and with Landlock alone there is no proxy port to allow.bun src/sandbox/landlock_helper.ts --abion each and record the ABI.Reused:
bwrapAvailableis the old probe body, unchanged. I extendedSandboxProbe,SandboxPolicy,runStep,cellsAvailableand the existing hold path indispatch.tsrather than adding parallel ones.To try: on a Landlock-capable Linux kernel, run
bun src/sandbox/landlock_helper.ts --abi, thenbun test test/landlock.test.ts test/crew-sandbox-floor.test.ts.Closes #16835