Skip to content

fix(jail): mount directories before the files that land inside them - #32

Merged
protonspy merged 1 commit into
mainfrom
fix/jail-map-order
Aug 28, 2026
Merged

fix(jail): mount directories before the files that land inside them#32
protonspy merged 1 commit into
mainfrom
fix/jail-map-order

Conversation

@protonspy

Copy link
Copy Markdown
Owner

Follow-up to #31, found by running it: codegraph installed inside WSL2 and the three mapped tools exercised inside a real ai-jail sandbox.

What was wrong

Binds apply in the order they are given, so a directory arriving after a file underneath it hides the file. #31 mapped scc as the real binary, at the shim's name and then mapped the bin directory the shim's neighbours need — and inside the jail:

scc --version
v0.19.0        ← the npm shim, not the binary that started the session

The specific mount was the whole reason the mapping existed, and it was the one being discarded.

The fix

Compose (was Dedupe, which no longer described what it does) emits every directory mount first and keeps the file mounts last, so the specific bind lands on top.

Verified

ai-jail 1.20.1, bubblewrap, Landlock fully enforced, in a scaffolded workspace under WSL2:

$ ai-jail --network --agent-state --map …/bin --map …/lib/node_modules \
    --map /home/…/tools/scc:…/bin/scc --map /home/…/.local/bin/rtk \
    --map …/codegraph/npm-shim.js:…/bin/codegraph -- bash check.sh
▸ Jail Active   ▸ Landlock: fully enforced
/home/…/.local/bin/rtk
/home/…/.nvm/versions/node/v24.18.0/bin/scc
/home/…/.nvm/versions/node/v24.18.0/bin/codegraph
rtk 0.44.2
dev                                                ← the running build, as intended
1.6.0
• no plans or specs yet — `scc plan new <name>`     ← scc map index, against the workspace

Against the same jail without the maps, command -v rtk answers nothing — which is the bug #31 set out to fix, and it stays fixed.

Binds apply in the order they are given, so a directory arriving after a file
underneath it hides the file. Measured inside a real sandbox: scc mapped as "the
real binary, at the shim's name" answered v0.19.0 — the npm shim — because the
bin directory the shim's neighbours needed was mounted on top of it a moment
later. The specific mount was the whole reason the mapping existed, and it was
the one being discarded.

Compose (was Dedupe, which no longer described it) orders directories first and
keeps the file mounts last. Verified against ai-jail 1.20.1 under bubblewrap
with Landlock enforced: rtk, an npm-installed codegraph and the running scc all
resolve by name inside the jail, and scc now reports the build that started it.
@protonspy
protonspy merged commit 7d3cbfb into main Aug 28, 2026
4 checks passed
@protonspy
protonspy deleted the fix/jail-map-order branch August 28, 2026 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant