Skip to content

[RFC] fail installs on publish-trust downgrades#891

Open
JamieMagee wants to merge 1 commit into
npm:mainfrom
JamieMagee:rfc/trust-policy-downgrade
Open

[RFC] fail installs on publish-trust downgrades#891
JamieMagee wants to merge 1 commit into
npm:mainfrom
JamieMagee:rfc/trust-policy-downgrade

Conversation

@JamieMagee

Copy link
Copy Markdown
Contributor

Adds an RFC proposing a trust-policy setting for npm install.

It warns or fails when a package's publish-trust level drops, for example when a version that used to ship via trusted publishing (OIDC) or provenance is later published with weaker evidence or none. The check is trust-on-first-use: it only fires when a package that earned trust loses it, and it runs during resolution, before lifecycle scripts, so it gates a malicious postinstall instead of catching it afterward. It relies only on metadata npm already fetches (_npmUser.trustedPublisher,_npmUser.approver, dist.attestations).

Configuration:

  • trust-policy (off, warn, error)
  • trust-policy-exclude
  • a date-valued trust-policy-enforce-since to grandfather the pre-provenance back-catalogue
  • trust-lockfile
  • a one-off --allow-trust-downgrade.

References

#860

Proposes a `trust-policy` setting (off, warn, error) that warns or fails
an install when a package's publish-trust level drops, for example from
trusted publishing (OIDC) to provenance-only or none. The check runs per
package, ordered by publish date, before any lifecycle scripts, so a
malicious postinstall is gated rather than caught afterward by
`npm audit signatures`.

It adds `trust-policy-exclude`, a date-valued
`trust-policy-enforce-since` that grandfathers the pre-provenance
back-catalogue, `trust-lockfile`, and a one-off
`--allow-trust-downgrade` escape hatch. It records the established trust
level in `package-lock.json` and raises `ETRUSTDOWNGRADE` on a downgrade.

The design follows pnpm's `trustPolicy` family, and the RFC surveys
prior art elsewhere (Go's checksum database, NuGet trusted signers,
PyPI, TUF, and more).

Assisted-By: GitHub Copilot (Claude Opus 4.8)
@ljharb

ljharb commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

This is a very bad idea. First of all, OIDC ("trusted" publishing) is one factor, so this is a fundamentally untrustworthy mechanism. Second, provenance provides no actual guarantees, and it is a perfectly legitimate decision for a maintainer to decide to stop publishing from CI or using provenance.

Simply put, provenance is a misfeature that imo should even be removed, and implying it's a "trust signal" is dramatically shredding the security of the npm ecosystem.

The best approach is to forbid any non-2FA publishing - meaning, everything either goes through a staged publish, or uses actual 2FA (iow, local publishing + 2FA, which prior to staged, is the only secure method of publishing to npm that has ever existed).

@piiiico

piiiico commented Jun 10, 2026

Copy link
Copy Markdown

Red Hat Miasma shows the gap in provenance-only TOFU: 32 @redhat-cloud-services packages republished through the existing CI/CD pipeline. Valid SLSA provenance on every malicious version. Trust level never downgraded — a TOFU check sees green.

What actually broke: 32 packages in a 3-hour batch (normal cadence: weekly). Orphan commits with no parent vs. PR-based flow. New preinstall hook where none existed before.

If trust-policy tracked behavioral cadence — publish frequency, hook introduction, commit ancestry — against a package's own baseline, it catches credential-theft attacks where the pipeline stays the same but the behavior doesn't.

@ljharb

ljharb commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

I continue to wait for anyone to point to an actual npm security incident/campaign where provenance would have been a material barrier - in almost a year, the GitHub security team hasn't been able to provide a single one, and nor has anyone else.

Relying on provenance before it would have been useful once ever in the history of npm, let alone in a significant number of incidents, seems like a massive waste of resources on security theater.

@piiiico

piiiico commented Jun 10, 2026

Copy link
Copy Markdown

Miasma is a sharp counterexample. SLSA was correct, and 2FA wouldn't have helped: the credential was the CI/CD's own OIDC token. The attacker pushed orphan commits to a repo with id-token: write and the legitimate pipeline did the rest.

Anomalous in registry metadata alone:

  • 32 packages republished in ~3 hours (normal cadence: weekly)
  • New preinstall hooks where none existed in prior versions
  • Orphan commits in tarball ancestry, vs the usual PR-merged history

None rely on OIDC or any identity signal. Behavior baselines on the package itself, a different axis from a TOFU check.

Wiz: https://www.wiz.io/blog/miasma-supply-chain-attack-targeting-redhat-npm-packages

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.

3 participants