Your Package May Be Compromised: Who to Call, and in What Order
A maintainer account takeover, or a malicious version published with a leaked token, is one of the worst days in a package author's life. Users install releases automatically, so speed matters, but so does not making it worse. This page is about the outside help available and when to bring each one in. It is general guidance; follow your registry's current documentation where it differs.
Signs that something is wrong
- A version appears on the registry that you did not publish, or with contents that do not match your tagged source.
- You receive a login, token-creation or password-reset notice you did not trigger.
- A user or a security scanner reports unexpected install scripts, network calls or obfuscated code in your package.
- Your CI logs show a publish step running from a branch or fork you do not recognise.
First hour: contain it yourself
- Revoke every publishing token you can reach, on the registry and in your CI secret store. On npm,
npm token listandnpm token revokehandle this; PyPI API tokens are revoked from account settings. - Change the account password and confirm two-factor authentication is still yours. PyPI requires two-factor authentication on all accounts, and npm strongly encourages it.
- Remove unknown collaborators or owners from the package and the source repository.
- Mark the bad release so new installs avoid it:
npm deprecate pkg@1.4.2 "Compromised release, do not use"on npm, or yank the release on PyPI. Removing it completely depends on registry policy, which is why the next step matters.
Bring in the registry
Registries have support and security teams that can do things you cannot: remove a malicious version outside the normal unpublish rules, lock an account, and investigate how access was gained. Contact them through the channel their documentation lists for security issues, and give them the package name, affected versions, timestamps and anything you know about how the attacker got in. If you have lost control of the account entirely, this is the only route back.
Tell your users through an advisory
Publishing a security advisory, for example through GitHub's repository security advisories, puts the incident into the databases that power npm audit, pip-audit and similar tools, so people who installed the bad version get warned. State plainly which versions are affected, what the malicious code did as far as you know, and what users should do, such as rotating credentials present on machines that installed it.
People worth involving
| Who | When they help |
|---|---|
| Registry security or support | Always, and early |
| Your employer's security team | If the package or account is work-related, or work machines installed it |
| Co-maintainers | Immediately, so nobody republishes from a stale token |
| Foundation or ecosystem security group | If the project belongs to one, as they may have an incident process |
| Independent incident responders | For large or commercial packages where forensic work is needed |
Afterwards
Once things are stable, move publishing to short-lived credentials. PyPI Trusted Publishing and npm trusted publishing (generally available since July 2025) both remove long-lived tokens from the picture, and the OpenSSF has published guidance on securing maintainer accounts that is worth working through.