Skip to content

commands: enforce OpenFile write intent checks - #816

Merged
ewhauser merged 1 commit into
mainfrom
ewhauser/openfile-write-policy
Mar 31, 2026
Merged

ewhauser merged 1 commit into
mainfrom
ewhauser/openfile-write-policy

Conversation

@ewhauser

Copy link
Copy Markdown
Owner

Summary

  • treat O_CREATE, O_APPEND, and O_TRUNC as write intent in CommandFS.OpenFile
  • keep O_RDONLY|O_CREATE from bypassing WriteRoots policy checks
  • add a regression test that proves the command-layer denial and verifies no file is created

Root Cause

CommandFS.OpenFile only enforced FileActionWrite for O_WRONLY and O_RDWR. The underlying filesystem treats create/append/truncate flags as mutating operations, so a custom command could open a path with O_RDONLY|O_CREATE and create a file outside allowed write roots.

Impact

This closes a confirmed sandbox-policy bypass in the public commands capability wrapper for embedders that register custom commands and rely on restrictive WriteRoots.

Validation

  • go test ./commands -count=1
  • make lint

@ewhauser
ewhauser marked this pull request as ready for review March 31, 2026 00:27
@ewhauser ewhauser changed the title [codex] commands: enforce OpenFile write intent checks commands: enforce OpenFile write intent checks Mar 31, 2026
@ewhauser
ewhauser merged commit 9293d4a into main Mar 31, 2026
16 checks passed
@ewhauser
ewhauser deleted the ewhauser/openfile-write-policy branch March 31, 2026 00:29
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