Skip to content

Windows Codex Desktop approval rules match "powershell.exe -Command" instead of inner command #19715

Closed

Description

@JDoucette

Summary

On Windows Codex Desktop, agent tool commands are executed through PowerShell even when the integrated terminal shell is set to Git Bash. Persisted approval prefix rules therefore match the outer PowerShell invocation instead of the user-meaningful inner command, making it impractical or unsafe to blanket-approve common commands such as git add and git commit -m.

Environment

  • Product: Codex Desktop app
  • OS: Windows 11
  • Shell setting: Integrated terminal shell set to Git Bash
  • Observed after full Codex app restart

Reproduction

  1. In Codex Desktop on Windows, set Settings -> General -> Integrated terminal shell to Git Bash.
  2. Restart Codex Desktop.
  3. Open a new chat in a repo.
  4. Ask Codex to run a git add or git commit command.
  5. It will ask to blanket accept all commands starting with powershell.

Expected

  1. It should already be running in a shell
  2. I should be able to dictate that shell
  3. the commands running should be "git add" not "powershell.exe -Command "git add ...""

Activity

  1. added
    bug
    app
    windows-os
    sandbox
    on Apr 26, 2026
  2. github-actions commented on Apr 26, 2026

    @github-actions
    Contributor

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

    Powered by Codex Action

  3. JDoucette commented on Apr 28, 2026

    @JDoucette
    Author

    It is not a duplicate, but it is related.
    If you fixed #19629 or allow a terminal to be set, so that commands can just be the commands themselves and not prefixed with a shell, then this issue goes away.
    But if you only allow another shell via fixing #19629 and continue to force the shell to also launch with each command, then this will not be fixed.

  4. little-wheat commented on Apr 28, 2026

    @little-wheat

    This issue also exists in the Cli. The actual command being run is pwsh, which causes the Rules to not match.

  5. ufthygygh commented on May 2, 2026

    @ufthygygh

    I think this is the same issue as #20713, with a slightly different reproduction.

    Additional evidence from my environment:

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

    Rules such as these validate successfully with codex execpolicy check:

    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", "--list"], decision="allow")

    But 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

    When I select the persistent approval option from the runtime prompt, Codex writes the rule using the PowerShell wrapper. For example, after approving npm test, the persisted line in default.rules is:

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

    So codex execpolicy check reports the inner-command rule as allowed, but the runtime approval path persists the outer PowerShell command instead.

    I closed #20713 as a duplicate of this issue.

  6. ufthygygh commented on May 2, 2026

    @ufthygygh

    One extra detail that may help make the bug clearer: when I select the persistent approval option from the runtime prompt, Codex writes the rule using the PowerShell wrapper, not the inner command.

    For example, after approving npm test, the persisted line in default.rules is:

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

    So the persisted rule is tied to C:\Program Files\PowerShell\7\pwsh.exe -NoProfile -Command ... instead of the documented inner-command form:

    prefix_rule(pattern=["npm", "test"], decision="allow")
  7. kraybit commented on May 4, 2026

    @kraybit

    Seems this was fixed in PR #20336
    Seems 0.129.0-alpha.2 contains the fix.
    Co-Authored-By: GPT-5 : )

  8. Cerber-Ursi commented on Aug 25, 2026

    @Cerber-Ursi

    I've just run into this on 0.149.1: I'm using the skill with an executable wrapper, this wrapper is saved into the default.rules, but when actually calling it, Codex for some reason asks for permission on pwsh.exe -c "path/to/wrapper.exe args", which obviously isn't allowed.

  9. gakera commented on Sep 29, 2026

    @gakera

    This still occurs on Windows with these installed versions:

    • Codex Desktop engine: 0.158.0-alpha.2.1
    • VS Code extension: 26.917.62051, engine 0.155.0-alpha.16.3

    Existing rule:

    prefix_rule(pattern=["npm.cmd", "run", "test:component"], decision="allow")

    The agent submits this directly, with the working directory supplied separately:

    npm.cmd run test:component -- --spec "src/example.cy.tsx"
    

    However, approval is requested for the generated wrapper, effectively:

    "C:\Program Files\PowerShell\7\pwsh.exe" -Command "npm.cmd run test:component -- --spec \"src/example.cy.tsx\""
    

    Selecting cmd.exe produces the same problem:

    "C:\Windows\system32\cmd.exe" /c "npm.cmd run test:component -- --spec \"src/example.cy.tsx\""
    

    “Allow similar commands” saves the wrapper and entire command string, including the spec path. Changing arguments triggers another prompt.

    Both installed versions postdate #20336. Is this a regression or a remaining limitation in wrapper normalization?

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

    appbugsandboxwindows-os

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions