openai / openai/codex

PreToolUse omits the effective shell for exec_command

Open
#44,836 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

app bug hooks windows-os
Dominant language
Rust
Stars
125k
Forks
19.4k
PR merge metrics
PR metrics pending

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at codex-rs/core/src/tools/handlers/unified_exec/exec_command.rs, especially pre_tool_use_payload, and trace the shell resolution used by execution. Done means the supported PreToolUse metadata reports the effective shell accurately for both PowerShell and POSIX execution, with regression coverage showing shell-sensitive commands remain distinguishable and denials still prevent execution.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
security, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.