The execpolicy ~ Bypass: How Tilde Shorthand Silently Voids Your Prefix Rules in Codex CLI v0.171–v0.172
The execpolicy ~ Bypass: How Tilde Shorthand Silently Voids Your Prefix Rules in Codex CLI v0.171–v0.172

A prefix_rule with mode = "forbidden" on ~/.ssh looks airtight. It is not. If the tool call that reaches your execpolicy engine contains a tilde or the string $HOME, the engine silently fails to parse the command and skips every prefix rule check. The rule is never evaluated. The command runs.
This is issue #63384, filed on 23 November 2026 and still unresolved in v0.172.0 stable — the current release as of 30 November 2026.1 If you are relying on prefix rules to protect sensitive directories under ~, your protection is not working in v0.171.0 or v0.172.0.
What the Bug Does
Codex CLI’s execpolicy engine is responsible for evaluating command-level rules before the agent executes anything in full-access mode. Rules are expressed as prefix_rule entries in a Starlark .rules file inside ~/.codex/rules/, and they can carry decisions of allow, prompt, or forbidden.2
The title of issue #63384 is precise: “a ~ or $HOME anywhere in a command skips every prefix_rule (e.g. ls ~ && git push runs despite a forbidden rule)”. The bug sits in the parser. When the execpolicy engine encounters ~ or the literal string $HOME in the token stream, it hits a parse error. Rather than fail closed — blocking the command and reporting the error — it fails open: it abandons rule evaluation and proceeds as if no rules exist.
The practical consequence is two-fold:
- Any command chained with a tilde-expanded path bypasses all rules.
ls ~ && git pushwill push even ifgit pushcarries aforbiddendecision. The&&chain works because the entire command string trips the parser. - Any rule written to protect home-directory paths using
~or$HOMEshorthand never fires. A rule likepath = "~/.ssh"orpath = "$HOME/.aws"is never matched, because the input containing those strings never reaches the matching stage.
The bug only affects the execpolicy engine. If you are running in sandbox mode with the OS-level file system restrictions active, those restrictions still hold — they operate below the execpolicy layer.3 The bypass matters when you are relying on execpolicy rules as a second layer of protection in full-access mode, or as the primary governance tool in an enterprise setup.
What Is at Risk
The directories that developers most commonly protect with prefix rules are exactly the directories that use ~ shorthand by convention:
~/.ssh— SSH private keys~/.aws— AWS credentials and config~/.config/gcloud— Google Cloud credentials~/.npmrc,~/.pypirc— package registry tokens~/.gnupg— GPG key material
A rule written as path = "~/.ssh" with mode = "forbidden" will not fire when a Codex agent issues cat ~/.ssh/id_rsa. The agent sees full-access mode, the rule is never evaluated, and the read succeeds.
The same applies to rules intended to block lateral movement via $HOME. Both ~ and $HOME trip the parser; ${HOME} behaviour has not been independently confirmed.
Immediate Mitigation
Rewrite every prefix rule using full absolute paths.
# WRONG — bypass risk in v0.171.0 / v0.172.0:
[[sandbox.prefix_rules]]
path = "~/.ssh"
mode = "forbidden"
[[sandbox.prefix_rules]]
path = "$HOME/.aws"
mode = "forbidden"
# CORRECT — use full absolute paths until #63384 is resolved:
[[sandbox.prefix_rules]]
path = "/home/yourusername/.ssh"
mode = "forbidden"
[[sandbox.prefix_rules]]
path = "/home/yourusername/.aws"
mode = "forbidden"
On macOS, replace /home/yourusername with /Users/yourusername.
For teams with shared Codex configurations distributed via managed policy, update every requirements.toml prefix rule to use the absolute path pattern before the next session. If you use a templated path like ${USER_HOME}, those expansions happen before rule loading, so they may already be safe — but verify by running codex execpolicy check with an explicit absolute path test case.4
Verifying Your Rules With codex execpolicy check
The codex execpolicy check subcommand lets you test rules offline against sample commands without starting an agent session.4 To verify your rules are working after switching to absolute paths:
# Should return: forbidden
codex execpolicy check "cat /home/yourusername/.ssh/id_rsa"
# Should return: forbidden — tilde-expanded variant
# Note: the bypass affects the engine, not this CLI test; the shell may expand ~ before the string reaches execpolicy
codex execpolicy check "cat ~/.ssh/id_rsa"
There is a subtlety here. When you pass a tilde-prefixed string to codex execpolicy check from the shell, the shell may expand ~ to the absolute path before the string reaches the execpolicy engine — which means the check passes correctly even though an agent-generated tool call containing the literal ~ would not. Use absolute paths in your test cases to verify the fix, but do not use codex execpolicy check to verify that the tilde bypass is or is not present. Test the bypass by watching agent behaviour in a controlled session.
Defence in Depth While the Bug Is Unpatched
Switching to absolute paths in prefix rules removes the bypass path for the most common attack surface. Three additional controls are worth applying while issue #63384 remains open:
1. Add an OS-level deny entry for the most sensitive paths.
If your security model genuinely requires that ~/.ssh never be readable by the agent, add a sandbox-level deny rule rather than relying on execpolicy alone. Sandbox mode restrictions are enforced by the OS and are not subject to the execpolicy parse bug.
2. Run codex execpolicy check as part of your session startup checklist.
After every Codex CLI upgrade, run a spot-check against your highest-sensitivity rules using absolute paths. A rule that passes the check with absolute paths is evaluating correctly.
3. Treat prefix rules as advisory until a fix is confirmed.
The report on issue #63384 notes that the workaround is to write absolute paths and treat prefix rules as advisory until patched. Even with the absolute-path fix in place, the underlying parser fragility exists. A fix in a future release should be confirmed before you rely on prefix rules as your sole defence for sensitive paths.
Affected Versions
| Version | Status |
|---|---|
| v0.171.0 | Affected — first confirmed version |
| v0.172.0 | Affected — current stable as of 30 November 2026 |
| v0.174.0-alpha.9 | No maintainer-confirmed fix |
| v0.174.0-alpha.10 | No maintainer-confirmed fix (TUI preferences persistence sprint; no execpolicy changes) |
| v0.174.0-alpha.11 | No maintainer-confirmed fix (build/CI fix on alpha.10; no execpolicy changes) |
Watch the v0.174.0 releases and issue #63384 for a resolution. When a fix lands, reverify your rules with both tilde and absolute forms to confirm the parser is handling both correctly.
Related Coverage
- Codex CLI Security Testing Tools:
codex sandbox,codex execpolicy, and Offline Policy Validation — general guide to the security testing subcommands - Codex CLI Security Model: Approval, Sandbox, and the Two-Axis Framework — the full Codex CLI security model
-
GitHub issue #63384, “a
~or$HOMEanywhere in a command skips every prefix_rule,” openai/codex repository, filed 23 November 2026. https://github.com/openai/codex/issues/63384 ↩ -
Codex CLI Rules System reference, developers.openai.com/codex/rules (November 2026). https://developers.openai.com/codex/rules ↩
-
Codex CLI v0.172.0 release notes, released 24 November 2026. https://github.com/openai/codex/releases/tag/rust-v0.172.0 ↩
-
Codex CLI
execpolicy checksubcommand, described in Codex CLI Security Testing Tools:codex sandbox,codex execpolicy, and Offline Policy Validation, 21 May 2026. ↩ ↩2