Repository navigation
Description
PreToolUse for exec_command exposes command text but omits the effective shell. On Windows this prevents a policy hook from selecting the matching shell grammar safely.
The inspected release source is rust-v0.153.4, exec_command.rs: pre_tool_use_payload constructs the canonical Bash tool name and a command-only input. The shell argument used by execution is absent.
A real downstream consequence is recorded in Universal Ontology #48: a read-only PowerShell query compares pending approval records with literal Git command strings. DCG 0.14.1 rejects the protected dispatch as core.git:branch-force-delete; no Git operation is executed by the query. On 2026-09-11, repeating that exact read-only query with shell: "C:/Program Files/PowerShell/7/pwsh.exe" still produced the same native denial before execution.
The retained inert native classifier comparison uses the unchanged DCG binary: the full original text is denied with unknown dialect and allowed with explicit PowerShell. Actual deletion/invocation/removal syntax remains denied in those diagnostics. These comparisons do not execute any specimen.
DCG's pinned hook source explicitly documents the missing Codex shell metadata. Its Windows handling cannot assume that canonical Bash means POSIX or that every Windows request is PowerShell, so ambiguous requests retain conservative multi-dialect handling.
Please expose the shell resolved for the actual pending execution through a supported hook contract. Preserve existing matching semantics and command rewrite behavior; use the same shell resolution as execution. Requested shell text alone is insufficient if resolution can fall back or select another environment. Regression coverage should show that PowerShell and POSIX execution of shell-sensitive text produce distinguishable, accurate hook metadata, while hook denials still prevent execution.
Limits: the producer omission is directly visible in the tagged source. The live observation is a native host denial, not a captured raw hook envelope or proof that this Desktop binary exactly matches that tag. No wrapper, forced DCG dialect, allowlist, hook change or guard patch was used. This report does not claim a security bypass or an installed fix.
Related metadata reports #32360 and #37251 concern effective cwd, not effective shell. Searches for PreToolUse/shell/Windows, hook/dialect and hooks/selected shell found no matching shell-metadata report. Written by Codex during the owner's authorized SDLC integration work.
Activity
jimy-r commentedon Sep 12, 2026
Same gap on the Claude Code side, and the way I live with it may be useful until the field exists. My PreToolUse guard sees only the command string, so it matches raw text across both dialects at once. The blocklist carries the PowerShell and the POSIX spellings of each destructive shape, plus the exec-hijacking prefixes (GIT_SSH_COMMAND=..., core.hooksPath=...). It fails open on its own bugs, because a broken guard must never wedge the session, and fails closed on a match. The cost is exactly what your third-party tool hit, false positives on read-only commands whose text resembles a write. I accept those, name around them, and re-issue a blocked compound command as separate steps, since a blocked compound ran nothing.
What the resolved-shell field would buy is parsing instead of pattern-matching. A guard that knows the grammar can tell Get-Content from rm without a dialect union, and the false-positive rate drops to the parser's error rate. So +1 to exposing it, and I'd add one item to the ask. Also expose the working directory the command will resolve relative paths against, since path-substring guards have the same ambiguity.
I maintain a reference architecture that documents the hook at https://github.com/jimy-r/agent-workspace-architecture/blob/main/PATTERNS.md#7-a-cheap-hook-beats-a-careful-agent
NOTgithub commentedon Oct 5, 2026
I reproduced the missing shell metadata on Windows with Codex CLI 0.160.0.
In a separate test workspace, I trusted a minimal informational PreToolUse hook through the normal Codex interface. The prompt explicitly requested
exec_commandwithshell: "pwsh.exe"and this harmless command:Write-Output TOOLBOX_SHELL_PROBE_302The command succeeded. The hook reported:
{ "tool": "Bash", "input_fields_present": ["command"], "other_input_field_count": 0, "input_shell": {}, "event_shell": {}, "cwd_present": true }This is minimized diagnostic output, not the raw hook payload. The hook found no shell identity in the inspected fields. Consequently, our policy hook cannot reliably select the correct shell parser.
No production guard was disabled or bypassed. The test session has ended and the temporary workspace has been removed.
thereisno-tomorrow commentedon Oct 22, 2026
Independent downstream reproduction on native Windows with the unchanged DCG v0.15.3 release binary (3eec165ae64a56bfbb2cecaa2510d82076010851).
This small, harmless PowerShell command is enough to expose the cost of missing shell metadata:
Submitting that text to DCG as data, without executing it:
dcg test --stdin --dialect unknown --format jsonheredoc.posix:pipeline-consumer--dialect psPreToolUseenvelope withtool_name: "Bash"and a nonemptyturn_idtool_name: "PowerShell"Minimal downstream reproducer (Python; executes only DCG):
The current Codex producer, inspected on 2026-10-22, still constructs
HookToolName::bash()withtool_input: {"command": args.cmd}. The DCG v0.15.3 handling explains why a Windows guard cannot safely infer the executor from this label.Please expose the resolved execution shell, including fallback resolution, while retaining existing hook matching and deny semantics. Globally relabeling Windows calls as PowerShell would miss cases that actually execute under Bash or CMD.
Scope: this is a classifier reproduction plus source inspection, not a new capture of a raw Codex hook event. The PowerShell pipeline was never executed. No private command history, user paths, credentials, or raw session payloads are included.
barad1tos commentedon Nov 19, 2026
Confirmed on macOS with Codex CLI 0.169.0. In one isolated
codex exec --ephemeralsession, I used a local model replay to send twoexec_commandcalls with identical command text. The only argument that changed wasshell.{"cmd":"printf 'Bash=%s zsh=%s\\n' \"$BASH_VERSION\" \"$ZSH_VERSION\"","shell":"/bin/bash","login":false} {"cmd":"printf 'Bash=%s zsh=%s\\n' \"$BASH_VERSION\" \"$ZSH_VERSION\"","shell":"/bin/zsh","login":false}Both calls exited 0. Their output confirmed which shell ran.
The
PreToolUsehook logged the sametool_nameandtool_inputfor both calls.{"tool_name":"Bash","tool_input":{"command":"printf 'Bash=%s zsh=%s\\n' \"$BASH_VERSION\" \"$ZSH_VERSION\""}}Exposing the effective shell in
PreToolUsewould let hooks select the correct parser whenexec_command.shellchanges within a session.