Closed
Description
Background
Surfaced by Codex + Antigravity peer review of #139 and the followup PR (harden/supply-chain-bypass-followups). Both reviewers flagged that shell_tokens() in `src/hooks/supply_chain_gate.rs` is deliberately naïve about quoting:
Tokenise a shell command into (offset, token) pairs, treating the shell operators &&, ||, ;, |, >, >>, <, << as standalone tokens. This is deliberately simple — it does not honour quoting […]
That choice leaves four bypass / false-positive classes wide open today:
- Shell-quote wrapped installs slip past. `sh -c 'npm install pkg'`, `bash -c "pnpm install x"` — the quoted region contains a real install but the regex anchor still fires only on the literal whitespace before the verb inside the quotes, while the outer `sh -c` text bypasses other detection paths.
- Command-substitution wrapped installs slip past. `$(npm install pkg)`, backticks. Same root cause: text is data to the outer command, but a real install to the inner shell.
- Quoted heads slip past. `'npm' install pkg` — the single quotes around the verb break the regex anchor.
- Quoted operators inside flag values cause false negatives. `npm install --description="install & test" lodash` — `shell_tokens()` splits on the literal `&`, so the package-bearing scan terminates early and the install can be misclassified as a bare lockfile install.
Proposal
Replace shell_tokens() with a quote-aware variant that:
- Honours single quotes, double quotes, and ANSI-C `$'…'` form.
- Surfaces `sh -c `, `bash -c `, `$(…)`, and backtick payloads as first-class segments that the gate can recurse into (closes #SEC-C2 lineage).
- Keeps the existing operator-splitting (`&&`, `||`, `;`, `|`) for unquoted regions.
- Round-trips offset / length so claimed-span dedup still works.
Acceptance criteria
Adversarial tests pin every class above; the existing 30+ supply-chain tests still pass; clippy clean.
Out of scope
Plaintext-data false-positive guard (separate issue) — different design.
Metadata
Metadata
Assignees
Labels
No labels
Activity
Merge pull request #146 from thehoff/feat/shell-quote-tokeniser-140
chore(release): v0.1.10
harden(supply-chain): close newline-chain + Windows launcher + bare p…
harden(supply-chain): quote-aware tokeniser closes wrapped-install by…