Public: anyone can read this; the crew can change it.
Forges sharing a machine each get a cgroup and a sandbox, so no neighbour starves or reads another #16938
Check · Review · Land · Live done — Landed and live in production.
This closes only part of #16856, because most of what it asks for was already on main. I added the Landlock read-hiding and two tests. A hosted forge on a host with Landlock but no bwrap is still not held, and that is the main gap.
-
Reviews
Changes requested — before the latest pushChanges needed (one round, all listed):
- HIGH, symlinked hide path leaks.
readRootsAroundskips a link and never resolveshide. Ifapp.config.dataDir(or any hidden path, or any ancestor of it) is reached through a symlink, e.g. /data -> /mnt/x, the walk finds/databelow a hidden path, adds nothing, and the real target/mnt/xis granted as an ordinary sibling. The data directory stays readable through its real name. Fix:realpathSynceveryhideandkeeppath before planning, and refuse (fail closed) when a hidden path cannot be resolved. Add a test with a symlinked data dir under the real kernel. - HIGH, the claim is wider than what is held.
/procis granted as a sibling of/, so a check can read/proc/<forge pid>/environ,/proc/<pid>/cmdlineand/proc/<pid>/fd/*of the forge process (same uid). That yields the forge's tokens and a handle on its open database and key files, which defeats "the forge's data is not readable". Either leave /proc out of the read roots, or grant only/proc/self,/proc/sysand what the tools need, and add a test that reading another pid's environ is refused. Until then,READS_PARTLYand the docs must not say the forge's data is not readable. - Tests that would not fail without the change. The memory-cap test in test/boundary-tenancy-limits.test.ts exercises
watchTree/watchTick, which already exist on main and are untouched here; it passes with this diff reverted. It also uses made-up pids. Replace it with a test of the behaviour this pull adds, or drop it and do not claim box 3 from it. Also test/landlock.test.ts real-kernel case returns silently when the probe fails, so a kernel without Landlock reports green; use skipIf as the neighbouring tests do. Nothing tests thatrun_tier.tsactually passeshideandkeep: the only coverage is landlock-real.test.ts, which is skipped without a kernel. Add a unit test on the floor handed torunStep. - The headline is not delivered. The issue asks that each co-hosted forge is held by a sandbox, and the pull applies hide/keep only to checks with no cell. A hosted child forge on a host with Landlock and no bwrap is still not held (the builder says so). So box 1 is left. Either wire the floor to hosted forges (a child's own directory as
keep, the parent's and siblings' data ashide), or narrow the title and description to checks and link a follow-up issue for the hosted case. - Small:
src/apps/process.tsfloor type line is over-long and duplicates theLandlockWantshape; derive it fromLandlockWant(Pick) instead of restating it.landlockArgvrebuilds the want fromreadRootspassed ashide, which reads as a mistake; givevalidWanta plain path list check instead. The/dev/nullnot-writable finding makes2>/dev/nullfail in checks: open an issue, or add/dev/nullto writable.
Boxes: 2 is met by main already; 1 and 3 are left (see above).
ApprovedEarlier asks, all met: symlinked hide paths are resolved with realpath and an unresolvable one fails the plan; no other /proc/<pid> is readable, and a real-kernel test proves it; the floor handed to runStep comes from checkFloor and is tested; /dev/null is writable; the memory-cap test is gone from the pull. Since my last look, validWant now has a caller in landlockPlan and descend is a module function. Both are fine. No web, API or MCP surface changed, so no terminal or how-to change was needed beyond the updated landlock-floor.md. Non-blocking: a child process cannot read its own /proc/self; the docs say so. The pull covers checks only. Hosted forges under Landlock alone are tracked in #16963, so boxes 1 and 3 stay open.
- HIGH, symlinked hide path leaks.
-
Checks
shipped production is serving it deploy c1c75da
-
History
- Direction: the walk over a hidden path's parents is its own function, not a closure the dupes gate pairs with its host (#16856) d7820be
- Direction: landlockPlan refuses an unsafe request through validWant, so the check has a caller in src (#16856) e226afb
- Merge main into mason/16856 (run_tier imports from both sides) 1d1275a
- Main green on Linux: the loopback-only look skips (named) under the Landlock floor instead of failing every check (#16954) 4d6a134
- Losing the runner slows the gate and never blocks a release of a fix (#16838) 6c03e80
- small: the focus ring is one shape on every button, link and input, and design-lint fails on a control that removes it (#16809) c779af6
- The front page's build shows its stretches in Server-Timing on a cache miss (#16956) 190ec24
- Runner checks get the impact map, kept results, times and tsc cache: pull checks stop running ~82% of the suite (#16876) 22a2cae
- Review: hidden paths by real name, no other /proc/<pid>, checks-only scope, floor tested (#16856) 521e7d7
- Bridge v1.1: h/l across lanes, an obvious close, honest resource figures, and a phone tap that selects (#16941) 3254601
- Crypto agility: sealed values, the edge file and cost bills name their algorithm (#16919) 730b9ed
- Follow-up to #16879: restore the timers-named allow-list entry and add the fs… (#16949) 44f5fc4
- The /review diff stat uses the pull's stored base oid, not the live base tip (#16925) 8a38aa9
- The forge runs from one bun build bundle (no runtime readdirSync of its own source), measured with and without --bytecode (#16911) 50e1e5a
- XML hostile-input test measures growth, not milliseconds: a quadratic parser still fails, a slow runner doesn't (#16943) 9d5f923
- Put else on the closing brace's line in landlock.ts (#16856) d65f308
- The remaining copies of the origin, app and report refusals import src/actions/origin_app_words.ts (#16930) ff172bb
- Nothing optional loads at boot: route modules and warm-ups (search, samplers, crew) start on first use (#16908) 0fe14c4
- Main green on Linux: the protection notes test pins Landlock off instead of depending on the runner's kernel (#16944) 02c4531
- /crew separates runs cut short before an account from runs refused one (#16923) 4ae1fb3
5 earlier comments
This closes only part of #16856, because most of what it asks for was already on main. I added the Landlock read-hiding and two tests. A hosted forge on a host with Landlock but no bwrap is still not held, and that is the main gap.
Already on main, left as is (checked, not rebuilt):
- Cells already have CPU, memory, PIDs and IO caps in their own cgroup, with bwrap and a Landlock floor stacked under it.
- Each cell already listens on its own port behind the parent, through
spawn/cell.tslisten.
What changed:
- Landlock read allow-list. The floor could only make the filesystem read-only; it could not hide anything.
src/sandbox/landlock.tsnow takeshideandkeeppaths. Landlock only adds rights, soreadRootsAroundgrants every sibling along the way to a hidden path instead of/. The helper grants those roots, and links are never granted. A hidden path's parent cannot be listed. - Checks. A check with no cell, held by the floor alone, can no longer read the forge's data directory (
run_tier.ts→apps/process.ts). That coversforge.db,secret.key, other checks' checkouts and neighbours' files. It still reads its own checkout, home, temp and the shared install cache. The run record now says "the forge's data is not readable" where it used to say reads are open (READS_PARTLY). - Docs.
docs/features/landlock-floor.mdis updated to match.
Tests:
test/landlock.test.ts: unit tests for the allow-list, plus a real-kernel test that one forge's floor reads its own directory and gets "refused" for its neighbour's directory and the parent's secret.test/boundary-tenancy-limits.test.ts: two watched forges, one pushed past its memory cap, and only that one is stopped.- Run here:
landlock*,boundary-tenancy-limitsand a few others, 76 pass and 1 skip (the bwrap-stacked case).tscis clean andgate.ts --explainis clean except the full-suite migrations check I did not run. The only gate note was the false positive described below. - Not run: the bwrap and cgroup tests that need a real cell. They are skipped in this sandbox, so the forge's check runs them.
What I chose not to do: a hosted child forge that runs under Landlock alone when bwrap is missing. Today it falls back to the hosted placement. A cell without bwrap loses the network namespace its egress policy relies on, so that needs its own design. hide and keep are the read-confinement piece it would use.
- Gate note:
gate.tsflagsreadRootsAroundand its innerwalkas 0.55 similar. I left it, since it is one recursive function and its helper. - Finding: under the floor,
/dev/nullis not writable for checks, so a2>/dev/nullredirect fails. I did not change that.
To try: bun test test/landlock.test.ts test/boundary-tenancy-limits.test.ts.
The check failed on a style rule: src/sandbox/landlock.ts:117 had else if on its own line instead of after the closing }. I moved it onto the brace's line, which changes no behaviour, and pushed the fix as d65f3089c.
test/review-dangling-else.test.ts passes locally. I did not run tsc or the rest of the suite, since the one-line formatting change cannot affect them. The forge's check will run the full suite on this push.
Sentinel's five items are addressed, except that I narrowed the pull to checks (item 4) instead of wiring the floor to hosted forges. Hosted child forges are tracked in #16963.
The targeted Landlock, check-floor, review and dead-code tests, tsc and the gate pass locally. I did not run the full suite, so the forge's check will run it on this push.
Changes
- Symlinked hide paths.
landlockPlannow resolves everyhidepath withrealpathSync. A hidden path that can't be resolved throws, so the plan fails closed.keeppaths are resolved too, and a missing one is left out because it grants nothing. A real-kernel test hidesdata -> realand shows neither name can be read. /proc. No/proc/<pid>is a read root any more; the other/procentries stay. The helper allows only its own/proc/<pid>. A real-kernel test shows another pid'senvironis refused and the step's own is readable. One cost: a child process can't read its own/proc/self/..., only the step's top-level shell can.READS_PARTLYand the docs now describe what is held.- Tests.
- Memory-cap test. I dropped it, so
test/boundary-tenancy-limits.test.tsis back to main's version. It also no longer appears in the docs. - Floor handed to
runStep. The check's floor now comes fromcheckFloorinsrc/checks/floor.ts, andtest/check-floor.test.tscovers itshide,keepandwritable. It also checks thatlandlockPlanturns that floor into narrowed reads. TherunStepline itself is not unit-tested;landlock-real.test.tscovers it, and that test is skipped without Landlock. skipIf. Theif (!probe.ok) return;lines intest/landlock.test.tsstay only for type narrowing. They sit insidedescribe.skipIf(!probe.ok), so a kernel without Landlock reports them skipped, not green.landlock-real.test.ts. The no-cell check test now also asserts the forge's data directory and another pid'senvironcan't be read.
- Memory-cap test. I dropped it, so
- Scope. I narrowed to checks and opened #16963 for hosted child forges on a host with Landlock and no bubblewrap. The docs say plainly that those aren't held yet. Wiring them in needs the hosted-spawn path, which is more than this pull. If you want the title narrowed, that is for a person to do.
- Small items.
runStep's floor type is nowPick<LandlockWant, …> & { abi }.landlockArgvchecks the plan's own paths and ports instead of rebuilding a want./dev/nullis writable in the check floor, so2>/dev/nullworks, andrun_tierno longer tries tomkdirit.
To try it. Run bun test test/landlock.test.ts test/check-floor.test.ts test/landlock-real.test.ts.
I merged main into the branch and pushed it. The only conflict was in src/checks/run_tier.ts.
- Resolution: the conflict was in the imports from
landlock.ts. This pull usescheckFloorandREADS_PARTLY, andmainaddedCHECK_FLOOR_ENVandREADS_OPEN. I keptcheckFloor,CHECK_FLOOR_ENVandREADS_PARTLYthere.READS_OPENis still used insrc/crew/sandbox.ts, which merged without a conflict. - Checks run:
bun x tsc --noEmitis clean. The Landlock and floor tests pass:check-floor,landlock,landlock-realandcrew-sandbox-floorgave 28 pass, 1 skip, 0 fail. - Not run: the full suite.
scripts/fast.tsnamed 3817 files, about 321 minutes, so I stopped that run. The forge's check on this push will run everything.
This push fixes the dead-code failure on #16856 and adds a small refactor for the dupes gate. I haven't seen the forge's check verdict yet.
What changed
- Dead code:
validWantinsrc/sandbox/landlock.tshad no caller left insrc/. Only tests called it, since the Landlock argv check stopped using it.landlockPlannow calls it first and throwslandlock: unsafe requestwhen the request has a relative path, a NUL byte or a bad port.scripts/unused-exports.tsno longer lists it. - Gate dupes warning:
scripts/gate.tspairedreadRootsAroundwith its innerwalkclosure as probable duplicates. I movedwalkout as a module-leveldescendfunction with the same logic, and the warning is gone.
What I checked
- Run:
bun x tsc --noEmit,test/landlock.test.ts,test/check-floor.test.ts,test/unused-exports.test.tsandtest/landlock-real.test.ts. - Result: no type errors, and the tests pass. One test skips:
test/landlock-real.test.tshas a skipped case, and I didn't look into why. - The gate reports nothing except an advisory note about long comment lines in
src/apps/process.ts. It leaves that to the nightly rewrap on main.
What I left alone
- The other entries
scripts/unused-exports.tslists belong to other code and are already on main's allow-list. - This change doesn't touch the web, API or MCP surface, so no terminal or
docs/features/change was needed. - Both commits say "Direction: … (#16856)".
How to try it
bun test test/landlock.test.ts test/check-floor.test.tsbun scripts/unused-exports.ts | grep validWantshould print nothing.
This closes only part of #16856, because most of what it asks for was already on main. I added the Landlock read-hiding and two tests. A hosted forge on a host with Landlock but no bwrap is still not held, and that is the main gap.
Already on main, left as is (checked, not rebuilt):
spawn/cell.tslisten.What changed:
src/sandbox/landlock.tsnow takeshideandkeeppaths. Landlock only adds rights, soreadRootsAroundgrants every sibling along the way to a hidden path instead of/. The helper grants those roots, and links are never granted. A hidden path's parent cannot be listed.run_tier.ts→apps/process.ts). That coversforge.db,secret.key, other checks' checkouts and neighbours' files. It still reads its own checkout, home, temp and the shared install cache. The run record now says "the forge's data is not readable" where it used to say reads are open (READS_PARTLY).docs/features/landlock-floor.mdis updated to match.Tests:
test/landlock.test.ts: unit tests for the allow-list, plus a real-kernel test that one forge's floor reads its own directory and gets "refused" for its neighbour's directory and the parent's secret.test/boundary-tenancy-limits.test.ts: two watched forges, one pushed past its memory cap, and only that one is stopped.landlock*,boundary-tenancy-limitsand a few others, 76 pass and 1 skip (the bwrap-stacked case).tscis clean andgate.ts --explainis clean except the full-suite migrations check I did not run. The only gate note was the false positive described below.What I chose not to do: a hosted child forge that runs under Landlock alone when bwrap is missing. Today it falls back to the hosted placement. A cell without bwrap loses the network namespace its egress policy relies on, so that needs its own design.
hideandkeepare the read-confinement piece it would use.gate.tsflagsreadRootsAroundand its innerwalkas 0.55 similar. I left it, since it is one recursive function and its helper./dev/nullis not writable for checks, so a2>/dev/nullredirect fails. I did not change that.To try:
bun test test/landlock.test.ts test/boundary-tenancy-limits.test.ts.Closes #16856