default.rules is not honored for sandbox-escaping commands even when execpolicy returns allow

Open 💬 7 comments Opened Mar 20, 2026 by mdca
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

What version of the Codex App are you using (From “About Codex” dialog)?

26.313.41514

What subscription do you have?

Pro

What platform is your computer?

Microsoft Windows NT 10.0.26200.0 x64 (Windows 11 Pro)

What issue are you seeing?

default.rules is not being treated as sufficient authorization for commands that need sandbox escape.

I reproduced this in both the Codex desktop app and the Codex CLI on Windows with:

  • trusted project
  • windows.sandbox = "elevated"
  • default.rules containing an allow rule for the command

Example rules tested:

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

Then I verified both forms with codex execpolicy check in PowerShell:

codex execpolicy check --pretty --rules $HOME\.codex\rules\default.rules -- git add -A

Result:

{
  "matchedRules": [
    {
      "prefixRuleMatch": {
        "matchedPrefix": ["git", "add"],
        "decision": "allow"
      }
    }
  ],
  "decision": "allow"
}

And also:

codex execpolicy check --pretty --rules $HOME\.codex\rules\default.rules -- "C:\Program Files\PowerShell\7\pwsh.exe" -Command git add -A

Result:

{
  "matchedRules": [
    {
      "prefixRuleMatch": {
        "matchedPrefix": [
          "C:\\Program Files\\PowerShell\\7\\pwsh.exe",
          "-Command",
          "git",
          "add"
        ],
        "decision": "allow"
      }
    }
  ],
  "decision": "allow"
}

Despite that, asking Codex to run git add -A still produces a manual approval prompt when the command needs to escape the sandbox to write under .git.

Inside the sandbox, the failure is expected:

fatal: Unable to create '.../.git/index.lock': Permission denied

What seems wrong is that a command already allowed by default.rules still requires manual confirmation instead of being treated as authorized.

What steps can reproduce the bug?

  1. On Windows, set windows.sandbox = "elevated".
  2. Mark the repo as trusted.
  3. Add an allow rule to ~/.codex/rules/default.rules for git add, for example:
prefix_rule(pattern=["git", "add"], decision="allow")
  1. Restart Codex.
  2. Confirm the rule matches:
codex execpolicy check --pretty --rules $HOME\.codex\rules\default.rules -- git add -A
  1. Ask Codex in the desktop app or CLI to run:
git add -A
  1. Observe that Codex still prompts for manual approval when the command needs sandbox escape to write under .git, even though execpolicy check already says the command is allowed.

I also tested the wrapped PowerShell form and got the same result:

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

codex execpolicy check returns allow for that form too, but the actual command still prompts.

What is the expected behavior?

If default.rules allows a command, and codex execpolicy check returns allow for that same command, Codex should be able to run it without a second manual approval prompt.

At minimum, default.rules should be sufficient authorization for the required sandbox escape for that allowed command.

If that is not the intended model, the docs should say clearly that default.rules only affects execpolicy matching and does not suppress sandbox-approval prompts for those same commands.

Additional information

Important detail: this is not just a desktop-app issue. I reproduced the same behavior in Codex CLI.

So the problem seems broader than one UI surface.

I also tested multiple rule shapes to rule out argv-shape confusion:

  • plain command form: pattern=["git", "add"]
  • wrapped PowerShell form: pattern=["C:\Program Files\PowerShell\7\pwsh.exe", "-Command", "git", "add"]

Both shapes return allow from codex execpolicy check.

Another important detail: if I approve the prompt using "Yes, and don't ask again...", Codex auto-saves this exact rule into default.rules:

prefix_rule(pattern=["C:\Program Files\PowerShell\7\pwsh.exe", "-Command", "git add -A"], decision="allow")

That exact auto-saved rule works.

So the surprising behavior is more specific than "rules never work": user-authored general prefix rules that codex execpolicy check says are allowed still do not suppress the approval prompt, but the exact command rule auto-saved by the prompt does suppress it.

This makes it look like the real execution path is honoring a narrower, different rule shape than the one accepted by codex execpolicy check and documented in default.rules.

View original on GitHub ↗

7 Comments

github-actions[bot] contributor · 4 months ago

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

  • #15292

Powered by Codex Action

mdca · 4 months ago
Potential duplicates detected. Please review them and close your issue if it is a duplicate. * Desktop shell tool still prompts for sandbox approval even when default.rules allows the command #15292 _Powered by Codex Action_

That was the original issue i submitted, but it needed further testing and clarification, so i closed it and opened this one with additional important details. The issues listed as potential duplicates in #15292 are not duplicates.

ignatremizov · 4 months ago

<img width="408" height="277" alt="Image" src="https://github.com/user-attachments/assets/49be7261-b39d-4e23-8553-b654bb46eb8b" />

FYI you can edit issues text instead of closing and opening new ones

mdca · 4 months ago
<img alt="Image" width="408" height="277" src="https://private-user-images.githubusercontent.com/8076691/566949725-49be7261-b39d-4e23-8553-b654bb46eb8b.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzQwMjQxODUsIm5iZiI6MTc3NDAyMzg4NSwicGF0aCI6Ii84MDc2NjkxLzU2Njk0OTcyNS00OWJlNzI2MS1iMzlkLTRlMjMtODU1My1iNjU0YmI0NmViOGIucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDMyMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjAzMjBUMTYyNDQ1WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MzE0M2Q4NTEwNDJhOGRmMmNjYWNiYjcwY2Y4M2M5ZGRkYWUyZTljY2ZhNjM5MDY5MTNmYWZlYmMwMWZlNjkyMCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.r7viJXQHG7LeHnYJqYstXDuW50ch9Js0NqApu3K1HEg"> FYI you can edit issues text instead of closing and opening new ones

Yes, normally, but the reopen button was showing an insufficient permissions hint for some reason.

bobscorporation · 3 months ago

+1 on this, rules being broken makes codex impossible to use for even medium length tasks as i have to stay and babysit.

Bibendus83 · 3 months ago

I have no idea if my codex setup is broken or what but I have to constantly approve ANY git command and there is no way to properly add generic allowance rules that will prevent that.

It's possible the issue has something to do with this https://github.com/openai/codex/issues/15214

codemeow · 2 months ago

Same problem. Linux, VScode with codex. It keeps asking with any level of access or sandbox.