Safeguard
Supply Chain•

Can you overwrite a published package version on a registry?

No. npm, PyPI, Maven Central and crates.io treat a published version as permanent. What each one lets you do instead, and why that protects your builds.

Safeguard Security Team
4 min read

No. The large public registries treat a published version as fixed. npm, PyPI and Maven Central do not let you replace the contents of a version once it is out, and crates.io only lets you yank one, which hides it from new resolution without deleting data. The fix is always a new version.

What each registry says

RegistryCan you replace the files?What you can do instead
npmNo. A name and version can never be reused, even after unpublishDeprecate, or publish a new version
PyPINo. A filename cannot be reused, even after the project is deleted and recreatedPublish a new release
Maven CentralNo. Components are not removed or modified once publicPublish a patch release
crates.ioYank only. Data stays downloadableYank, then publish a fixed version

The wording comes from each registry's own documentation. npm describes registry data as immutable and says a published name and version can never be used again. PyPI states that a distribution filename, made of project name, version and distribution type, always resolves to the same file. Maven Central says it does not remove or modify components once available, and ties that to the expectation that builds are repeatable. Cargo's yank command removes a version from the index but, in its own words, does not delete any data.

Why registries are built this way

Your lockfile records a version, and often a hash. If a maintainer could swap the files behind a version, the hash would stop matching or, worse, nobody would notice. Immutability is what makes "the same version" mean "the same bytes".

It also limits what an attacker can do after taking over a maintainer account. They cannot quietly rewrite 1.4.2 in place. They have to publish a new version, which shows up in release feeds, diffs and scanners. That is not full protection, since a new malicious version is still a problem, but it removes a stealthy class of attack.

What to do when you shipped a bad release

  1. Stop the bleeding. Deprecate or yank the bad version so new installs avoid it where the registry supports that.
  2. Publish a fixed version with a higher number. Patch increments signal compatibility if you follow semantic versioning.
  3. Tell users which version to move to, with the reason.
  4. If the release contained a secret, rotate the secret. Removal from the registry does not recall copies already downloaded or mirrored.

What this means for consumers

Pin versions in a lockfile, keep the hashes, and treat "same version, different content" as an alarm. Your private mirror or cache may hold the old bytes even after the registry changes, so know which source your builds really read. See what happens to your mirror when upstream removes a package and unpublish, yank and deprecate compared.

Safeguard's SBOM and dependency scanning records the exact versions in each build, so a yanked or replaced release can be found across your projects. You can try it with the free scan.

Quick check

Can I unpublish an npm version and reuse the number?

No. npm's policy says once a package at a given version has been used you can never use that name and version again, even if you unpublished it.

Does yanking a crate delete it?

No. Cargo documents that yank does not delete any data, and the crate stays downloadable through the registry link. Existing lockfiles can still resolve it.

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.