[codex] Trust only system PowerShell parsers on Windows#30628
Open
bookholt-oai wants to merge 4 commits into
Open
[codex] Trust only system PowerShell parsers on Windows#30628bookholt-oai wants to merge 4 commits into
bookholt-oai wants to merge 4 commits into
Conversation
This was referenced Jun 30, 2026
This was referenced Jul 1, 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 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.
Why
On Windows, PowerShell safety classification recognized
argv[0]by basename and then launched that same model-selected path as a host-side AST parser. A repository-controlledpwsh.exeorpowershell.execould therefore execute before the approval and sandbox boundaries and could forge a parser response.What
argv[0]toCommand::new.powershell.exeandpwsh.exeparser semantics separate while rejecting bare names, relative paths, workspace paths, command wrappers, and missing installs.How
The shared PowerShell parser entry point now resolves the command executable against two fixed, protected Windows installation paths and verifies the selected binary exists. The lower-level process launcher is private, so both Windows safe-command classification and exec-policy unwrapping must pass through the trust check. Tests cover case and separator normalization, extended-length trusted paths, CWD/PATH ambiguity, absolute workspace paths,
.cmdwrappers, path aliases, missing installs, and both PowerShell variants. A Windows-only interface regression copies a real PowerShell binary to workspace-controlledpowershell.exeandpwsh.exepaths and verifies neither is classified as safe.Testing
just fmtjust test -p codex-shell-command— 142 passedjust fix -p codex-shell-commandgit diff --checkWindows-only runtime coverage will run in CI; the path-resolution variants run on every platform.
Linear