fix(sandbox): tolerate unreadable directories during Linux writable-root scan - #12414
Merged
Merged
Conversation
marius-kilocode
enabled auto-merge
July 20, 2026 16:06
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (3 files)
Reviewed by claude-sonnet-5 · Input: 16 · Output: 5.3K · Cached: 308K Review guidance: REVIEW.md from base branch |
chrarnoldus
approved these changes
Jul 21, 2026
t7tran
pushed a commit
to t7tran/kilocode
that referenced
this pull request
Aug 14, 2026
…ermission-error fix(sandbox): tolerate unreadable directories during Linux writable-root scan
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.
On Linux, the bubblewrap backend prepares every sandboxed process launch by scanning each writable root for deny-name matches (
.git) that must be re-mounted read-only. That scan used a bare recursivereaddirSync, so a single unreadable directory anywhere beneath a writable path (for example a restricted folder like/kilo/secrets) threwEACCES ... scandirand aborted the entire launch preparation. Every sandboxed tool call then failed with an access error, no matter which path the agent actually tried to write.The deny-name scan in
packages/kilo-sandboxnow tolerates per-directory failures instead of aborting setup:--ro-bind. This fails closed: a directory that cannot be enumerated might hide a.git, so the whole subtree is protected rather than silently skipped. Bind-mounting only needs search permission on the ancestors, so the launch succeeds while the directory stays inaccessible and read-only inside the sandbox. Silently skipping would have left a.gitwritable in the execute-only directory corner.Writable root is not readable: <path>instead of a raw scandir error.The macOS seatbelt backend is unaffected (deny names are enforced by a kernel-level regex, no filesystem scan), so this only changes the Linux bubblewrap path. Writes inside the restricted directory itself remain impossible: a permission-denied directory rejects writes at the OS level regardless of sandbox setup.
The generated mount layout is covered by new tests that build a writable tree containing a permission-denied subdirectory and assert the launch still constructs, with both the discovered
.gitand the unreadable directory mounted read-only. Actualbwrapexecution has not been exercised yet (development machine is macOS), so one quick smoke check on Linux is worthwhile before merge: createproject/plus a restrictedsecrets/inside a writable path, enable the sandbox, and confirm sandboxed writes intoproject/succeed whilesecrets/stays inaccessible.