Join our Newsletter — 33% off our NHI Course
Home› Guides› Package Maintainer Account Compromise Playbook: Contain, Yank, Rotate…
Guide Software & AI Supply Chain

Package Maintainer Account Compromise Playbook: Contain, Yank, Rotate and Notify on npm and PyPI

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 18 November 2026 14 min read
On this page

When a package maintainer account or publishing token is stolen, the attacker inherits the trust of every project that installs your package, and the first hour decides how far a malicious release travels. This playbook is for the maintainer side of that incident: the open source or internal team whose npm or PyPI account, publishing token or release pipeline has been taken over. It covers confirming the compromise, cutting off the attacker's publishing access, removing or flagging bad releases with the tools each registry actually provides (unpublish and deprecate on npm, yanking on PyPI), rotating every credential that touched the release path, telling downstream users, and rebuilding publishing so a single stolen token cannot do this again. If you are a consumer who installed a bad package, use the Malicious Open Source Package Response Playbook instead; this page does not repeat it.

Registry facts on this page come from the npm Docs and PyPI documentation as of November 2026. Registries are covered in alphabetical order (npm, then PyPI), with equal depth and no comparison. Confirm commands against each registry's current documentation before an incident, not during one.

Key takeaways

  • Treat a maintainer account takeover as a non-human identity incident. Publishing tokens, CI secrets and OIDC trust settings are the credentials attackers use, and most real cases (for example the Rspack npm compromise and the telnyx PyPI compromise) started with a stolen publishing credential, not a password.
  • Revoke first, investigate second. On npm, token revocation can take up to an hour to take effect, so start it immediately.
  • Know what each registry lets you do. npm allows unpublishing within 72 hours if nothing depends on the package, and otherwise points you to deprecation. PyPI offers yanking, a non-destructive alternative to deletion that installers normally skip.
  • Version numbers are burnt. npm states that once a version has been used you can never use it again, even after unpublishing, so the fixed release needs a new version.
  • Rebuild on trusted publishing. Both registries support OIDC-based trusted publishing; PyPI mints tokens valid for only 15 minutes, and npm recommends disallowing traditional tokens once trusted publishers are configured.
  • Notify early and specifically: affected versions, time window, what the payload did if known, and the safe version to move to.

Triggers and first-hour triage

Start this playbook when any of the following happens: a release appears that no maintainer published; a registry, security researcher or user reports malicious code in a version you own; a publishing token is found in a public repository, log or paste; a maintainer reports a phished account or an unexpected MFA or email change; or your CI system shows a publish job you did not trigger. The technique is MITRE ATT&CK T1195.002, Compromise Software Supply Chain.

In the first hour, answer four questions and write the answers in the incident ticket:

  1. Which packages and versions are affected? List every version published since the earliest suspicious activity, across every package the compromised account or token can publish, not only the one that was reported.
  2. Which identity published them? A personal account, a token (and which one), or a CI pipeline. The answer decides what you revoke.
  3. Is the attacker still active? New releases, new tokens, changed maintainers or changed account email all mean they still have a foothold.
  4. What does the payload do? You do not need full reverse engineering yet, but you need enough to tell users whether to rotate their own secrets. Install-time scripts that harvest credentials are common; see the npm Install-Time Security Guide.

Assign an incident lead, a registry operator (the person who will run revocation, unpublish, deprecate or yank), and a communications owner. On small projects one person may hold all three roles; write that down so nobody waits for a second person.

Contain: cut off publishing access

Containment means the attacker can no longer publish. Do this before cleaning up releases, otherwise they can publish again while you remove the first one.

npm

  • List tokens with npm token list, copy the full token ID from the table (not the truncated token value), and remove each one with npm token delete <ID>. Run npm token list again to confirm. On the website, open your profile picture, select Access Tokens, and delete individual or selected tokens.
  • npm states you can revoke any token you have created, including granular access tokens, and that revocation can take up to an hour to take effect. Assume the attacker keeps access during that window and watch for new releases.
  • Every maintainer on the affected packages should revoke their own tokens, because each person can only see and delete tokens they created.
  • In the package settings, set publishing access to require two-factor authentication and disallow tokens. This is the setting npm recommends once trusted publishing is configured, and during an incident it blocks any token you missed.
  • Reset the maintainer account password, review the account email and recovery options, and re-enrol two-factor authentication from a clean device.

PyPI

  • Revoke every API token for the affected account from the account settings, and remove project-scoped tokens on each affected project.
  • Review the project's trusted publisher configuration. A trusted publisher tells PyPI to trust a specific CI configuration, so an attacker with write access to that repository and workflow can publish without any token. Remove the publisher until the CI side is clean.
  • Reset the account password and review account email, recovery codes and two-factor devices from a clean device.
  • Review the project's collaborators and remove any you do not recognise.

Both registries

  • Disable or pause release workflows in CI until the pipeline has been checked. See the CI/CD Pipeline Compromise Playbook if the release path itself may be compromised.
  • Rotate the CI secrets that held publishing tokens, and any other secret readable by the same jobs.
  • Preserve evidence before deleting anything: registry metadata for the malicious versions, the tarball or wheel, CI run logs, and token lists with creation dates.

Remove or flag malicious releases

Once publishing is locked, deal with the bad versions. Each registry offers different tools, and neither lets you reuse a version number in the way you might expect.

npm: unpublish or deprecate

npm's unpublish policy allows you to unpublish at any time within the first 72 hours after publishing, provided no other packages in the npm Public Registry depend on it. After 72 hours, you can still unpublish only if all of the following are true: no other packages in the public registry depend on it, it had fewer than 300 downloads over the last week, and it has a single owner or maintainer. Popular packages will usually fail these tests.

  • Unpublish a single version with npm unpublish <package_name>@<version>.
  • If unpublishing is not allowed, deprecate the version with npm deprecate <package>@<version> "<message>". Deprecation still allows the version to be downloaded but publishes a clear warning message, so pair it with a clean release and loud communication.
  • If the malicious version cannot be unpublished by you, contact npm support. The unpublish policy points maintainers to the support team for unpublish problems and for suspected policy violations.
  • If you unpublish every version of a package, npm states you may not publish any new versions of that package until 24 hours have passed. Avoid unpublishing everything unless you have to; the gap leaves users with no safe version.
  • Check dist-tags. Make sure latest and any other tags point to a known good version, so a plain install does not pick up the bad one.

PyPI: yank

PyPI documents yanking as a non-destructive alternative to deletion. A yanked release stays on PyPI, but installers ignore it unless it is the only release matching a version specifier that uses == or ===, as set out in PEP 592. Yanking applies to whole releases, not individual files. A security vulnerability is one of the reasons PyPI lists for yanking.

  • Yank the malicious release from the project's release management page and give a reason. PyPI strongly encourages a reason, which is shown on the release page and in the index APIs installers use. Write it for users: "Malicious release published by an attacker; upgrade to X.Y.Z".
  • Remember the exception: users who pin == to the bad version can still install it. Your notice must tell them to change the pin.
  • PyPI also advises that, like deletion, yanking should be used sparingly because it disrupts downstream users. A confirmed malicious release is the case it exists for.

Rotate credentials and clean the release path

A publishing token rarely leaks alone. The same laptop, CI runner or secret store usually holds cloud keys, source control tokens and signing material. The eslint-scope compromise began with a reused password, and the Shai-Hulud first wave showed stolen npm tokens being used to spread to further packages, so assume reach beyond the package you were told about.

  1. Inventory. List every credential that could publish, or that sat next to one: registry tokens, CI secrets, source control personal access tokens and deploy keys, cloud keys on maintainer machines and runners, and signing keys.
  2. Rotate by blast radius. Rotate first anything that can publish or push code, then anything that can reach production or cloud accounts, then the rest.
  3. Check source control. Look for new deploy keys, new collaborators, changed branch protection, new or modified workflow files, and tags that moved. Malicious commits often hide in release workflows.
  4. Check maintainer devices. If a maintainer machine ran the attacker's code or was phished, treat it as compromised and rebuild it before it publishes again.
  5. Verify the clean build. Build the fix from a reviewed commit on a clean runner, and compare the package contents with the source before publishing.

For token design detail, see the npm Tokens Security Guide and the PyPI API Tokens and Trusted Publishing Security Guide.

Publish the clean release

Users need a safe version to move to, and it must be obviously newer than the bad one. Because npm will never let you reuse a version number once it has been used, and a yanked PyPI release still exists, the fix always ships as a new version.

  • Bump the version beyond the highest malicious version, even if that skips numbers. A user running a normal upgrade should land on the clean release.
  • Publish from the rebuilt release path, ideally through trusted publishing (see the next section) so the clean release is the first one with a verifiable origin.
  • On npm, confirm dist-tags point at the clean version after publishing.
  • Diff the published artefact against the reviewed source and record the hash in the incident ticket.

Notify downstream users

Silence costs users time. A short, early notice is better than a complete, late one, and it can be updated. Use your existing channels: a security advisory on the repository, the release notes, the package README, a deprecation or yank message, and any mailing list or chat community. The Incident Communication Plan Template helps with roles and timing.

Every notice should say:

  • Which package names and exact versions were malicious, and when they were available (first and last time, with time zone).
  • What the malicious code did, as far as you know, and what you do not yet know.
  • What users should do: upgrade to the named clean version, remove pins to the bad version, clear caches and lockfile entries, and rotate any secrets present on machines or CI runners that installed it.
  • How the compromise happened, at whatever level of detail you can share, and what you have changed.
  • Where updates will be posted.

If the package is widely used, tell the registry as well. For npm, the support contact in the unpublish policy is the documented route for policy violations. Consider asking for a CVE or advisory identifier so scanners flag the versions.

Recover: rebuild publishing on trusted publishing

The lasting fix is to remove long-lived publishing tokens from the release path.

npm trusted publishing

npm trusted publishing lets you publish directly from CI/CD workflows using OpenID Connect, removing the need for long-lived npm tokens. The npm documentation lists GitHub Actions (GitHub-hosted runners), GitLab CI/CD (GitLab.com shared runners) and CircleCI (cloud) as supported, and notes self-hosted runners are not currently supported. It requires npm CLI 11.5.1 or later and Node 22.14.0 or higher. When you publish a public package from a public repository through GitHub Actions or GitLab CI/CD, npm automatically generates provenance attestations. Once trusted publishers are configured, npm strongly recommends restricting token-based publishing by selecting "Require two-factor authentication and disallow tokens". See the npm Trusted Publishing and Provenance Guide.

PyPI trusted publishing

PyPI describes Trusted Publishing as using OpenID Connect to exchange short-lived identity tokens between a trusted third-party service, such as GitHub Actions, and PyPI. The project is configured to trust a specific CI configuration; when that automation submits its OIDC token, PyPI mints an API token valid for only 15 minutes. PyPI's documentation points out that long-lived API tokens remain usable by an attacker until the owner notices and revokes them, while trusted publishing tokens expire automatically. After moving, remove the old project tokens.

Protect the CI side

Trusted publishing moves the risk to the workflow that is trusted. Protect it: require review for changes to release workflows, restrict who can trigger them, use protected environments for publish jobs, and pin third-party actions to commit SHAs (see How to Pin GitHub Actions to Commit SHAs). The Ultralytics PyPI compromise combined a GitHub Actions injection with a leftover PyPI token, which is exactly the pairing to remove.

Post-incident review

Within two weeks, hold a blameless review and record:

  • A timeline from first malicious action to last affected version removed or flagged, and to first user notice.
  • The root cause: which credential, how it was obtained, and why it could publish.
  • Time to revoke, time to flag releases, time to notify. These are the measures to improve.
  • Which other packages the same maintainers or tokens could publish, and whether they were checked.
  • Changes made: trusted publishing, token disallowed, two-factor on all maintainers, workflow protections.

Common failure patterns

  • Cleaning up before locking out. The team unpublishes or yanks the bad version while the stolen token still works, and the attacker publishes another one.
  • Revoking only the reported token. Other maintainers' tokens, CI secrets and the trusted publisher configuration stay live.
  • Relying on deprecation alone. A deprecated npm version is still downloadable. Without a clean release and a notice, users keep installing it.
  • Forgetting exact pins. A yanked PyPI release can still be installed by anyone pinning it with ==.
  • Unpublishing every version. On npm this blocks new versions for 24 hours, leaving users with nothing safe to install.
  • Trying to reuse the version number. npm will not accept a version that has been used before, so the planned fix fails at publish time.
  • Trusted publishing without workflow protection. The attacker cannot steal a token, so they change the trusted workflow instead.
  • Vague notices. "A security issue was fixed" does not tell users which versions to purge or which secrets to rotate.

Practitioner checklist

  • Keep a written list of every package you maintain on npm and PyPI, its maintainers and its release path.
  • Know who on the team can revoke tokens, unpublish, deprecate and yank, and make sure at least two people can.
  • During an incident, revoke every publishing token for every maintainer before touching releases.
  • On npm, set publishing access to require two-factor authentication and disallow tokens.
  • Unpublish within 72 hours where allowed; otherwise deprecate and contact npm support. On PyPI, yank with a clear reason.
  • Publish a clean release with a higher version number from a rebuilt, reviewed pipeline.
  • Send a notice naming exact versions, time window, payload behaviour and user actions, including rotating secrets.
  • Move publishing to trusted publishing on both registries and remove long-lived tokens.
  • Protect release workflows with review, protected environments and pinned actions.
  • Run a post-incident review and measure time to revoke, time to flag and time to notify.

Standards and references

Related NHI Mgmt Group resources: Malicious Open Source Package Response Playbook · npm Tokens Security Guide · PyPI API Tokens and Trusted Publishing Security Guide · CI/CD Pipeline Compromise Playbook

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.