Repository navigation
Description
The #50 exemption only applies when -c comes straight after the interpreter. Any flag in between, such as -I or -u, turns a data pipeline back into a download cradle, and encoded-command-download fires at critical.
Reproduction
Checked against PIPE_TO_SHELL on master, fingerprint 15846a0915769d4a, without changing anything:
| Command | PIPE_TO_SHELL matches |
Correct? |
|---|---|---|
curl -s https://example.org/a.json | python -c "import json" |
No | Yes |
curl -s https://example.org/a.json | python -I -c "import json" |
Yes | No |
curl -s https://example.org/a.json | python3 -u -c "import json" |
Yes | No |
curl -s https://example.org/a.sh | python |
Yes | Yes, the download is the program |
Cause
_INLINE_SCRIPT in core/audit/detection/traits.py is a lookahead placed directly after the interpreter name:
_INLINE_SCRIPT = r"(?!\s*-\w*[ce]\b)"It only sees the first token after the interpreter. In python -I -c, that token is -I, so the lookahead passes and the pattern matches. The shell branch of PIPE_TO_SHELL uses the same lookahead, so sh -e -c probably behaves the same way. That case is not tested.
How it was found
Dogfood week 10, 2026-11-06. An agent fetched tests/logsource.json from SigmaHQ/sigma and piped it into python -I -c with its own inline script, reading the download as JSON. Nothing downloaded was executed. The detection was dispositioned as a false positive, and the week stays green.
python -I is what isolated Python should look like when it reads downloaded data, so the rule currently penalises the safer way of writing this command.
Fix, when it can land
traits.pyis frozen and hashed into the ruleset fingerprint. Do not fix this alone. It belongs with the other changes that move the fingerprint, in one pass (Observable techniques collapse into T1059 because the mapper only upgrades on credentials and egress #55).- Skip flags that take no value before looking for
-cor-e. curl x | python -Iandcurl x | python -have no script of their own and must stay cradles.- Add both shapes to the benchmark corpus: the flagged inline script as benign and the flag with no script as an attack.
- The residual stated in the existing comment does not change:
python -I -c "exec(sys.stdin.read())"would slip the trait, andINLINE_EVALis what sees that shape.
Parked with the detection-noise work until the feature stop lifts.
Activity
blitzcrieg1 commentedon Nov 25, 2026
Fixed by #469 (from #463): preceding flags before -c/-e no longer defeat the inline-script exemption; "python -I" without -c still flags as pipe-to-shell.