fix(jail): mount directories before the files that land inside them - #32
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #31, found by running it:
codegraphinstalled 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
sccas the real binary, at the shim's name and then mapped the bin directory the shim's neighbours need — and inside the jail:The specific mount was the whole reason the mapping existed, and it was the one being discarded.
The fix
Compose(wasDedupe, 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:
Against the same jail without the maps,
command -v rtkanswers nothing — which is the bug #31 set out to fix, and it stays fixed.