Enforce read-only in pathSandbox.open#12
Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 3 commits intomainfrom Mar 9, 2026
Merged
Enforce read-only in pathSandbox.open#12gh-worker-dd-mergequeue-cf854d[bot] merged 3 commits intomainfrom
gh-worker-dd-mergequeue-cf854d[bot] merged 3 commits intomainfrom
Conversation
Co-authored-by: AlexandreYang <49917914+AlexandreYang@users.noreply.github.com>
|
Bits Dev status: ✅ Done Comment @DataDog to request changes |
thieman
approved these changes
Mar 9, 2026
matt-dz
approved these changes
Mar 9, 2026
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Member
Author
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
|
This was referenced Mar 12, 2026
Merged
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.
What does this PR do?
Adds a defense-in-depth check in
pathSandbox.openthat allowlists onlyos.O_RDONLY. Any other flag combination is rejected withos.ErrPermissionbefore the file is ever opened. This is safer than a denylist because it automatically rejects unknown or future flags.Motivation
Currently, write redirections (
>,>>, etc.) are blocked at AST validation time, and both internal callers (catbuiltin,<redirect) only passos.O_RDONLY. However, the sandboxopenmethod itself had no enforcement — it passed flags straight through toos.Root.OpenFile. This means a future code change, a parser bug, or a new feature could accidentally open files for writing inside the sandbox. Rejecting everything exceptO_RDONLYat the sandbox layer ensures the filesystem remains read-only regardless of what happens upstream.Testing
TestPathSandboxOpenRejectsWriteFlagscovering all write flag combinations and confirming read-only still works.go test ./...).Checklist
PR by Bits
View session in Datadog
Comment @DataDog to request changes