Safeguard
Security Guides•

What should you rotate after each type of supply chain attack?

Which credentials and keys to rotate after dependency confusion, a hijacked package, a build compromise or a bad update, and how to scope the list.

Safeguard Security Team
3 min read

Rotate every secret that was readable from any environment where the bad code could have run. For a malicious package that means the build machine or laptop that installed it. For a vendor build compromise it can mean the vendor product's stored credentials and, in severe cases, identity systems.

The scoping rule

Malicious code runs with the permissions of whoever ran it. So list the environments first, then the secrets reachable from each. Ask: what environment variables, files, tokens and cloud roles could this process read?

By attack class

ClassWhere code ranRotate first
Dependency confusionWherever the package was installed, often CICI secrets, registry tokens, cloud keys in that job
Compromised maintainerInstall or import time in build and productionSame, plus anything the app held at runtime
Build system compromiseInside the vendor product on your networkCredentials the product stored, service accounts it used
Malicious updateMachines that applied the updateSecrets on those machines

CISA's SolarWinds guidance lists reset of all credentials stored in the affected platform, and says that if administrative credentials or SAML token abuse is involved, the identity trust store may need to be treated as compromised. That is the upper end, and it depends on evidence.

A rotation sequence

  1. Contain first. Rotating while the bad code still runs just leaks the new secret.
  2. Rotate the highest value secrets first. Cloud admin, signing keys, registry publish tokens, production database credentials.
  3. Revoke, do not just replace. Make sure old tokens stop working.
  4. Rotate in dependency order. A key that protects other keys goes early.
  5. Check logs for use. Look for the old credentials being used from unexpected places.
  6. Record it. What was rotated, when, by whom.

Lower the cost next time

Short lived credentials expire on their own. PyPI documents tokens that last about 15 minutes in its trusted publishing flow, against long lived API tokens that stay valid until revoked. Scope secrets per job, and keep them out of developer shells where you can.

Common mistakes

Teams often rotate only the secret named in a report and miss the neighbors. A package that ran in CI could read every variable in that job, plus files on the runner. A package that ran on a developer laptop could read shell history, cloud credential files and SSH keys. Write the list from the environment outward, not from the headline inward, and have a second person review it. Also remember third party tokens, such as registry, chat and ticketing tokens, which are easy to forget because they sit outside the cloud account.

Quick check

Do I rotate if the package was only in a dev dependency?

Yes if it was installed where secrets were reachable. Dev tooling often runs on machines that hold them.

What if I cannot tell whether code executed?

Assume it did for environments that installed the version, and rotate on that basis.

Where Safeguard fits

Safeguard offers SBOM and dependency scanning, policies and gates, and compliance and evidence automation for recording what you did. Try the free 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.