Skip to content

security: lockfile audit must block non-registry sources and missing integrity by default - #8541

Merged
danielhanchen merged 5 commits into
mainfrom
lockfile-audit-block-provenance
Aug 12, 2026
Merged

danielhanchen merged 5 commits into
mainfrom
lockfile-audit-block-provenance

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Problem

scripts/lockfile_supply_chain_audit.py is the pre-install gate: it runs immediately before npm ci in five workflows, and those npm ci steps deliberately keep lifecycle scripts enabled because vite build needs them (esbuild native binary postinstall).

The script correctly detects the four structural conditions it exists to stop:

  • non-registry-resolved-url (npm tarball fetched from somewhere other than the registry)
  • missing-integrity-hash
  • non-registry-cargo-source
  • missing-cargo-checksum

but #5604 left all four out of BLOCKING_KINDS, so in default mode they print a ::warning:: and the script exits 0. No workflow passes --strict. The gate has been open since that commit.

Reproduced on main with a lockfile pointing at a local tarball plus a plausible looking integrity value:

::warning::  [non-registry-resolved-url] .../package-lock.json%0A
    package: node_modules/evil-pkg%0A
    detail:  resolved='file:evil-pkg-1.0.0.tgz'; only https://registry.npmjs.org/ is permitted.
[lockfile-audit] OK: 1 advisory finding(s), 0 blocking.
DEFAULT_RC=0
STRICT_RC=1

Exit 0 means a green check and the next step runs npm ci, which executes the package's postinstall on the runner.

The reasoning behind the advisory classification does not hold up. An integrity hash written by whoever also wrote the resolved URL proves nothing; it is a fingerprint of bytes the attacker chose. Registry origin is the only thing that makes the hash meaningful, so origin and integrity both belong on the blocking side. The known-malicious version table and IOC strings that did stay blocking only catch attacks somebody already published indicators for; the structural check is the layer that catches a novel one.

Fix

Move those four kinds into BLOCKING_KINDS. Kinds that describe an incomplete entry rather than a fetchable source (missing-resolved-url, unsupported-lockfile-version) stay advisory, which keeps the noise floor low. --strict still escalates everything.

No existing job changes colour

Check Result
All 4 checked-in lockfiles, default mode exit 0, 0 findings
Same, --strict exit 0, clean even under the strictest setting
tests/security/ 292 passed, 6 skipped
PoC lockfile after the fix exit 1, blocks before npm ci

studio-tauri-smoke.yml runs npm install --prefix studio @tauri-apps/[email protected] before the audit, so it mutates studio/package-lock.json on the runner. Simulated with npm 11.9.0: the only change is the root dependency range "2.10.1" to "^2.10.1", no package entries change, and the mutated lockfile still audits clean.

This is CI only. Nothing in Studio, Desktop, the installers or the notebooks imports this script, so there is no user facing behaviour change.

The one intended behaviour change: a future PR that deliberately adds a git or file: dependency now fails instead of warning. Cargo already has CARGO_SOURCE_ALLOWLIST for that case (it is how fix-path-env is pinned), and npm has NPM_REGISTRY_PREFIXES_ALLOWED.

Tests

  • test_malicious_cargo_lockfile_default_mode_advisory asserted the old exit 0 behaviour. Replaced with test_malicious_cargo_lockfile_default_mode_blocks.
  • Added test_provenance_kinds_block_by_default and test_non_registry_npm_tarball_blocks_by_default (the PoC, as a test).
  • The GitHub Actions annotation escaping test now targets the ::error:: path, and a new advisory case using missing-resolved-url keeps the ::warning:: path covered.

danielhanchen and others added 2 commits August 12, 2026 11:52
…integrity by default

The pre-install lockfile gate detects non-registry npm resolved URLs,
missing npm integrity hashes, non-registry Cargo sources and missing
Cargo checksums, but #5604 left all four out of BLOCKING_KINDS, so they
only printed a ::warning:: and the script exited 0. Every workflow calls
the auditor without --strict immediately before `npm ci`, which runs
package lifecycle scripts, so a lockfile pointing at an attacker
controlled tarball with a matching integrity value passed the gate and
its postinstall ran on the runner.

Move those four kinds into BLOCKING_KINDS. An integrity hash written by
whoever also wrote the resolved URL proves nothing; the registry origin
is what makes it meaningful, so both belong on the blocking side of a
pre-install fetch gate.

Kinds that describe an incomplete entry rather than a fetchable source
(missing-resolved-url, unsupported-lockfile-version) stay advisory, and
--strict still escalates everything.

All four checked-in lockfiles pass in default mode and under --strict,
so no existing job changes colour.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d33e6aa3d3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +631 to +634
"non-registry-resolved-url",
"missing-integrity-hash",
"non-registry-cargo-source",
"missing-cargo-checksum",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Update --strict help for the new default blockers

When operators inspect --help to choose between default and strict mode, it still states that default mode blocks only known-malicious versions, IOC strings, and broken lockfiles and that everything else exits 0. These newly added provenance/integrity kinds now also exit 1 by default, so the CLI advertises behavior that directly contradicts BLOCKING_KINDS; update the argument help to list the new default blockers.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, fixed in f38de75. The help said default mode blocks only known-malicious versions, IOC strings and broken lockfiles and that everything else exits 0, which contradicted BLOCKING_KINDS after this change. It now lists the provenance/integrity blockers and describes --strict as escalating the remaining advisory kinds (an entry with no resolved URL, an unaudited lockfileVersion).

…ockers

The --strict help still told operators that default mode blocks only
known-malicious versions, IOC strings and broken lockfiles and that
everything else exits 0. Provenance and integrity findings now block by
default, so --help contradicted BLOCKING_KINDS for anyone deciding
whether they needed --strict.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: f06f92acd6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@danielhanchen
danielhanchen merged commit f5c64f4 into main Aug 12, 2026
23 of 24 checks passed
@danielhanchen
danielhanchen deleted the lockfile-audit-block-provenance branch August 12, 2026 12:36
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: d66088220b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant