Skip to content

Windows PowerShell runtime approvals ignore execpolicy prefix_rule for external executables #20713

Closed as not planned

Description

@ufthygygh

Description

On Windows with PowerShell, .codex/rules/default.rules / ~/.codex/rules/default.rules prefix rules validated by codex execpolicy check do not consistently suppress runtime approval prompts for external executables.

The runtime approval path appears to match or persist the outer PowerShell command / rendered command string instead of consistently applying the documented inner-command prefix_rule matching.

Rules example

prefix_rule(pattern=["npm", "test"], decision="allow")
prefix_rule(pattern=["npm", "run", "build"], decision="allow")
prefix_rule(pattern=["node", "--test"], decision="allow")
prefix_rule(pattern=["git", "config", "--get"], decision="allow")
prefix_rule(pattern=["git", "config", "--global", "--get"], decision="allow")
prefix_rule(pattern=["git", "config", "--list"], decision="allow")
prefix_rule(pattern=["git", "config", "--global", "--list"], decision="allow")

Expected behavior

After restarting Codex, commands matching those prefixes should not prompt again.

Examples:

npm test
npm run build
node --test --version
git config --list
git config --get user.name

Actual behavior

Runtime shell execution can still ask for approval for commands covered by those rules, including:

npm test
npm run build
node --test --version
git config --list
git config --get user.name

The approval UI offered overly specific persisted prefixes such as:

node --test --version
git config --get user.name
git config --global --get user.name

When persisted from the prompt, rules also appeared to be saved in wrapper form involving PowerShell. For example, after approving npm test, the persisted line in default.rules is shaped like:

prefix_rule(pattern=["C:\\Program Files\\PowerShell\\7\\pwsh.exe", "-NoProfile", "-Command", "npm test"], decision="allow")

instead of the documented inner-command form:

prefix_rule(pattern=["npm", "test"], decision="allow")

Evidence

codex execpolicy check reports decision: "allow" for the same rules, but runtime shell execution can still ask for approval. This suggests that codex execpolicy check and the runtime approval path for Windows/PowerShell shell commands may not be using the same matching mechanism.

Environment

  • OS: Microsoft Windows NT 10.0.26200.0
  • Shell: PowerShell 7.6.1
  • Codex version: codex-cli 0.128.0

Activity

  1. added
    bug
    CLI
    windows-os
    sandbox
    tool-calls
    on May 2, 2026
  2. github-actions commented on May 2, 2026

    @github-actions
    Contributor

    Potential duplicates detected. Please review them and close your issue if it is a duplicate.

    Powered by Codex Action

  3. ufthygygh commented on May 2, 2026

    @ufthygygh
    Author

    Closing as a duplicate of #19715. I added the extra reproduction details and environment info there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIbugsandboxtool-callswindows-os

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions