default.rules is not honored for sandbox-escaping commands even when execpolicy returns allow
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.rulescontaining 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?
- On Windows, set
windows.sandbox = "elevated". - Mark the repo as trusted.
- Add an allow rule to
~/.codex/rules/default.rulesforgit add, for example:
prefix_rule(pattern=["git", "add"], decision="allow")
- Restart Codex.
- Confirm the rule matches:
codex execpolicy check --pretty --rules $HOME\.codex\rules\default.rules -- git add -A
- Ask Codex in the desktop app or CLI to run:
git add -A
- Observe that Codex still prompts for manual approval when the command needs sandbox escape to write under
.git, even thoughexecpolicy checkalready 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.
7 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
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.
<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
Yes, normally, but the reopen button was showing an insufficient permissions hint for some reason.
+1 on this, rules being broken makes codex impossible to use for even medium length tasks as i have to stay and babysit.
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
Same problem. Linux, VScode with codex. It keeps asking with any level of access or sandbox.