Repository navigation
Description
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 -AResult:
{
"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 -AResult:
{
"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.
Activity
github-actions commentedon Mar 20, 2026
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
arteagacz commentedon Mar 20, 2026
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 commentedon Mar 20, 2026
FYI you can edit issues text instead of closing and opening new ones
arteagacz commentedon Mar 20, 2026
Yes, normally, but the reopen button was showing an insufficient permissions hint for some reason.
bobscorporation commentedon Mar 23, 2026
+1 on this, rules being broken makes codex impossible to use for even medium length tasks as i have to stay and babysit.
Bibendus83 commentedon Apr 21, 2026
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 #15214
codemeow commentedon May 7, 2026
Same problem. Linux, VScode with codex. It keeps asking with any level of access or sandbox.
ashmcmn commentedon Sep 24, 2026
Adding a related macOS reproduction: Codex Desktop showed an ‘Allow once’ prompt for a read-only
gcloud builds listinvocation (project, limit, sort, and format flags), despite~/.codex/rules/default.rulesallowing the exactgcloud builds listprefix. The command shown in the prompt starts with that prefix, and the rule has been present for months. I rancodex execpolicy checkagainst the exact invocation using~/.codex/rules/default.rules; it returneddecision: allowand matched thegcloud builds listprefix. I did not execute thegcloudcommand itself. This points to the desktop approval/execution path rather than a prefix-matching problem.EdwardMillen commentedon Oct 18, 2026
I've found a workaround for this on Windows at least (or rather, ChatGPT and Codex did it for me). This is what ChatGPT suggested I should post here explaining it:
I've reproduced a related problem with Codex on native Windows, and found a workaround that may help narrow down the cause.
Environment:
26.1007.214340.162.0-alpha.17.2prefix_rule(pattern=["git", "add"], decision="allow")The interesting finding is that equivalent PowerShell command spellings produce different approval behaviour, even though they pass identical arguments to the native executable.
git add --dry-run README.mdgit add --dry-run -- README.mdgit add --dry-run '--' README.mdgit commit --dry-run -m 'Approval dry-run'--author="Name <email>"'--author=Name <email>'All commands used the same
exec_commandbackend and were executed throughpowershell.exe -Command.A separate argument-printing test confirmed that the quoted and unquoted variants pass identical arguments to native programs.
PowerShell's parser represents bare
--as aCommandParameterAst, whereas'--'is aStringConstantExpressionAst. This suggests the difference arises during command analysis before execution, rather than in Git itself.I haven't established which internal Codex parser branch is responsible, so this is an observation rather than a confirmed root cause.
Practical workaround: Quoting
--as'--', and quoting the entire--author=...argument, allows my existing Git prefix rules to work without additional approval prompts.Although demonstrated using Git, the underlying issue may apply to other external commands whose PowerShell syntax prevents Codex from recognising the executable and arguments correctly.
This may also be relevant to #15294, which describes the broader PowerShell command-wrapping problem.
And here's what I've currently added to
AGENTS.md, which hopefully covers it, although I haven't actually tested it with a separate agent/conversation: