Skip to content

fix(supply-chain): honour inline-prefix CONTEXTCRAWLER_SUPPLY_CHAIN=off bypass #181

Closed

Description

@thehoff

Summary

CONTEXTCRAWLER_SUPPLY_CHAIN=off is honoured only when set in the
gate's own process environment. Users naturally invoke it as a leading
inline assignment on the bash command they want to run:

CONTEXTCRAWLER_SUPPLY_CHAIN=off pip install starlette==0.49.1

That assignment scopes to the pip install subprocess, not the
contextcrawler hook (which has already parsed the cmd and now reads its
own env). Result: the gate still blocks on KnownVulnerability /
RecentRelease findings and the user thinks the bypass is broken.

Evidence (from this user's logs, last 24h)

2026-05-25T12:38:58 verdict=block
  cmd:    CONTEXTCRAWLER_SUPPLY_CHAIN=off .bench-tools/docling-env/bin/python -m pip install --quiet 'starlette==0.49.1' …
  reason: KnownVulnerability PYSEC-2026-161

The user tried the documented bypass twice (starlette==0.49.1, 0.50.0) —
both still blocked.

Why this matters

src/hooks/supply_chain_gate.rs:2165, 2179 actively suggest the
inline-prefix invocation in error messages:

"  Overrides: rerun with CONTEXTCRAWLER_SUPPLY_CHAIN=off, or add the package …"

So the docs/UX promise inline-prefix bypass; the code only honours
shell-env bypass. They disagree.

Proposed fix

In check() at src/hooks/supply_chain_gate.rs:1878, before the
existing std::env::var check, also scan the input cmd for a leading
inline assignment of the bypass var:

if cmd_has_leading_assignment(cmd, "CONTEXTCRAWLER_SUPPLY_CHAIN", &["off", "0", "false", "no"]) {
    return Verdict::Skip;
}

Where cmd_has_leading_assignment parses the prefix of the cmd in the
spirit of POSIX env-var-assignment style: any number of NAME=VALUE
pairs separated by whitespace before the first non-assignment token.

Bonus: same treatment for CONTEXTCRAWLER_TIRITH_DISABLED=1 (mirror
issue) — but that's out of scope for this issue.

Tests

  • inline prefix, single env: CONTEXTCRAWLER_SUPPLY_CHAIN=off pip install x → Skip
  • inline prefix with siblings: FOO=bar CONTEXTCRAWLER_SUPPLY_CHAIN=off pip install x → Skip
  • value variants: =0, =false, =no → Skip
  • middle of cmd (not prefix): pip install x && CONTEXTCRAWLER_SUPPLY_CHAIN=off something → does NOT bypass
  • env-var bypass (existing path) still works → Skip

Out of scope

  • The unavailable verdict retry-on-network-OK behaviour (separate issue).
  • Whole-config enabled: false toggle precedence (already correct via load_config).

Originally filed on the gitea lab mirror. Filing on github for release-notes cross-reference. Already fixed in the inbound PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions