Safeguard
Supply Chain•

How do you choose a safe version after a package compromise?

Pick the last version released before the incident, confirm it against the maintainer notice, and check its files. A quick decision guide for pinning.

Safeguard Security Team
3 min read

After a package compromise, choose the last version published before the incident window, confirm it against the maintainer or registry advisory, then check its contents before you pin it. Do not jump to the newest version just because it is newest, since an attacker may also publish follow up releases.

Why not simply update

During an incident, new releases arrive fast: the attacker's, the maintainer's emergency fix and sometimes copycats. The highest number is not always the cleanest. A pinned version you have verified is safer than a fresh one nobody has reviewed.

Decision guide

OptionWhen to useRisk
Last version before the windowDefault choiceMay lack unrelated fixes
Maintainer's clean new versionAdvisory names it explicitlyVerify it came from the maintainer
Remove the dependencyPackage is abandoned or trivialNeeds code change
Fork or vendor a copyNo trusted release existsYou own maintenance

Steps

  1. Get the compromised version list and times from the registry advisory or maintainer.
  2. Take the last release before the first bad one, and check its publish date.
  3. Compare its file listing and install scripts against the version before it. Unexpected new files or scripts are a warning sign.
  4. If the package is a transitive dependency, pin it with an override in the root package.json. The npm documentation describes overrides as replacing a package in the tree with another version.
  5. Reinstall from the lockfile with a command that does not change it, such as npm ci. That command exits with an error if the lockfile and package.json disagree.
  6. Wait for a cooling period before accepting new releases of that package. See dependency cooldown periods.
  7. Record the version you chose and why.

Watch for

Fake fix announcements pointing to a new package name, and messages telling you to run a one line install. Take fix instructions from the registry advisory or the maintainer's official repository only.

For rollback steps see how to roll back a bad dependency upgrade.

Record the decision

Write a short note in the incident log: package, versions removed, version chosen, evidence used to choose it, who approved. Add a comment next to any override in the manifest saying why it exists and when it can be removed. Overrides added in a hurry tend to stay for years and hide later fixes. Set a reminder to review each one after the maintainers publish a verified fix.

Try it yourself

Click through it at your own pace, or open it full screen.

Look at how a fixed version is shown next to the vulnerable one, and compare it with the checks above.

Quick check

Is the newest version the safest?

Not necessarily. Prefer a version you have verified over the most recent one.

What if the package has no clean version?

Remove it, vendor a reviewed copy, or replace it with an alternative.

Safeguard's dependency scanning shows fixed versions where known, and its autonomous remediation can open fix pull requests, off by default. A free scan is at gold.safeguard.sh/scan.

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.