Safeguard
Supply Chain•

What if the package registry itself is compromised?

If a registry or mirror serves tampered packages, recorded hashes and provenance help you notice. Learn which checks still work when you cannot trust it.

Safeguard Security Team
3 min read

If a registry or mirror is compromised, it can serve a package that differs from what the author published. You can still detect many cases by checking hashes you recorded earlier and provenance signed outside the registry. You cannot detect them if you simply trust whatever the registry returns.

Why this is a distinct entry point

Most advice assumes the registry is honest and the publisher is the weak link. A compromised registry or a rogue mirror reverses that: the author did nothing wrong, but what you download has changed.

The SLSA threats overview lists this as its own link in the chain, compromise of the package registry. Its example is a researcher who ran mirrors for several popular registries, showing that such mirrors could have served malicious packages. The overview says provenance of the artifacts would have shown they were not built as expected or from the expected source repository.

What helps

  1. Recorded hashes. If your lockfile or requirements file stores a hash for each package, a changed file fails the install. Pip's secure installs guide describes hash-checking mode, enabled with the require-hashes option, as protection against remote tampering and network issues. It also notes the mode is all or nothing: specifying a hash for any requirement activates it globally.
  2. Provenance checked against a separate trust root. npm's documentation says provenance is signed through Sigstore and logged in a public transparency ledger, which it describes as a way to detect tampering attempts if a registry were compromised.
  3. Your own mirror with controls. A mirror you operate narrows who can alter content, though you then own its security.
  4. Source only installs for critical packages. Pip's guide also mentions disallowing source distributions with the only-binary option for secure installs, so you control what runs.

What does not help

  1. Trusting the version number. A tampered file can keep the same number.
  2. Trusting the download count or popularity.
  3. A scan of a package that was tampered with before you first fetched it, if you never recorded a hash from a trusted moment.

A realistic position

You probably cannot verify everything. A reasonable stance is layered:

LayerCheck
Everyday packagesLockfiles with hashes
Critical packagesProvenance plus a spot rebuild
Build infrastructureControlled mirror and network rules
ResponseA plan to rebuild from clean sources

When the first download is the problem

Hash locking protects against later changes. If the first copy you locked was already bad, the hash simply preserves the bad copy. That is why provenance and review of new dependencies matter at the moment of adoption.

Where Safeguard fits

Safeguard's SBOM and dependency scanning help you keep a record of exact components, and continuous monitoring flags later changes. Choosing and operating a mirror remains an infrastructure decision for your team.

Quick check

Do lockfile hashes fully solve this?

They stop later swaps of a locked file. They do not help if the file was already tampered with when you first locked it.

Is this a common problem?

The SLSA overview treats it as a real class of threat. How often it occurs is not something this post claims.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.