Conversation
pakrym-oai
approved these changes
Jan 13, 2026
viyatb-oai
approved these changes
Jan 13, 2026
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
This fixes a bug where Codex was allowing unsafe commands to run when
SandboxPolicy::ReadOnlywas set on Windows (but should not have).There is some understandable confusion in the codebase, as we currently lack a variant of
SandboxPolicyto express the case where "there is no sandbox available, not because the user did--yolo, but because there just isn't one, sorry."Because many places in our code require a
SandboxPolicyas a parameter, rather than passOption<SandboxPolicy>around everywhere, we simply default toSandboxPolicy::ReadOnlyon Windows. On Mac and Linux, we provide an actual read-only sandbox such that we can allow commands to run freely and rely on the sandbox to prevent anything bad from happening. However, the same assumption does not apply on Windows.Ultimately, the proper fix is to introduce a new variant to
SandboxPolicyto accurately represent the current sandbox state, but for now, I ported therequires_initial_appoval()function inis_dangerous_command.rsthat contained the existing logic over torender_decision_for_unmatched_command()inexec_policy.rsand cleaned it up. Note that this function was originally introduced in #6380 for unified exec, but things have changed such that it has been repurposed for, and used exclusively by, execpolicy. The migrated function is now private toexec_policy.rsso it is not picked up by anyone else.To verify this fixes the existing behavior, I added only the
verify_approval_requirement_for_unsafe_powershell_command()test from this PR onmainand verified that it failed as expected, returningExecApprovalRequirement::Skipinstead ofExecApprovalRequirement::NeedsApprovalforpwsh -Command 'echo hi @(calc)'on Windows. With the changes torender_decision_for_unmatched_command(), now it passes.