# CodeWhale: exec_shell parallel-readonly classifier auto-approves fd/rg/git grep exec flags enabling silent RCE

CodeWhale's exec_shell auto-approves commands classified parallel-readonly; fd/rg/git grep exec flags (-x, --pre, --open-files-in-pager) run arbitrary programs with no approval prompt.

- Payout: Research
- Severity: high
- Program: CodeWhale
- Found by: manus-use
- Disclosed: 2026-11-19
- CVE: CVE-2026-83816
- Write-up quality: 8/10
- Original: https://github.com/advisories/GHSA-3mgh-93r5-r7jf
- Library page: https://bugbountylibrary.com/r/ghsa%3AGHSA-3mgh-93r5-r7jf
- Tags: area:ai domain:ai impact:rce kind:research platform:ghsa sev:high tech:rust technique:chained technique:source-review vuln:auth-bypass vuln:command-injection vuln:prompt-injection

**Target:** Agent exec_shell tool approval classifier in codewhale-tui
**Root cause:** approval_requirement_for downgrades exec_shell to Auto when the command is classified parallel-readonly; the classifier only rejects shell metacharacters and matches the flag-stripped base name against an allowlist containing fd, rg and git grep, whose own exec flags need no metacharacters. Auto returns false before the auto_approve check, so no prompt is shown.
**Steps:**
1. Model emits `exec_shell {"command":"fd -u -tf -x ./pwn.sh"}` (no `; & | > < \` $(` or newlines present)
2. `is_parallel_readonly_command` strips flags, canonicalizes base name to `fd`, which is in `PARALLEL_READONLY_PREFIXES` and absent from `COMMAND_ARITY` → returns true
3. `approval_requirement_for` returns `Auto`; `registered_tool_approval_required` returns false at turn_loop.rs:37-38 before the `auto_approve` check → no prompt
4. `analyze_command` rates `fd` as `Safe` (SAFE_COMMANDS command_safety.rs:530), so the `SafetyLevel::Dangerous` block never fires
5. Child process executes attacker's program; alternatives: `fd -tf -x cp {} /tmp/exfil`, `rg --pre /tmp/evil.sh --pre-glob '*' needle .`, `git grep --open-files-in-pager=/tmp/evil.sh needle`
**How found:** Noted the documented promise that every shell command is gated behind approval, then read approval_requirement_for and the parallel-readonly classifier: it only rejects shell metacharacters and matches flag-stripped base names, so tools with their own exec flags (fd -x, rg --pre, git grep --open-files-in-pager) pass as read-only. Confirmed fd/rg absent from COMMAND_ARITY and present in SAFE_COMMANDS, and that Auto short-circuits before auto_approve.
**Exploitation:** Indirect prompt injection from a repo file, issue or fetched page coerces the model to emit an exec_shell call using fd/rg/git grep exec flags; the classifier auto-approves it and the tool spawns the attacker's binary on the developer host with no approval prompt in the default interactive Agent profile.
**Insight:** When an agent harness allowlists 'read-only' commands by base name, check whether those tools have native exec/spawn flags (-x/--exec, --pre, --open-files-in-pager, --pager) that need no shell metacharacters; also check ordering of the Auto short-circuit versus the user's auto_approve setting.

## Proof of concept (copied exactly from the original report)

**exec_shell JSON payload using fd -x**

```
{"name":"exec_shell","arguments":{"command":"fd -u -tf -x ./pwn.sh"}}
Alternatives (all metachar-free, all auto-approved): `fd -tf -x cp {} /tmp/exfil`; `rg --pre /tmp/evil.sh --pre-glob '*' needle .`; `git grep --open-files-in-pager=/tmp/evil.sh needle`.
```

