
Urgent PyPI Security Update: All User API Tokens Revoked After ‘GhostAction’ Attack
In a significant move to protect the Python ecosystem, the Python Package Index (PyPI) has taken decisive action against a sophisticated supply chain attack. If you are a Python developer or maintain a project that interacts with PyPI, this update requires your immediate attention.
On May 20th, 2024, PyPI administrators announced that they had invalidated all user-scoped API tokens as a precautionary measure following the discovery of a malicious campaign dubbed “GhostAction.” This proactive step was taken to neutralize any potential threat posed by compromised accounts and ensure the integrity of the software supply chain.
What Was the ‘GhostAction’ Attack?
The “GhostAction” campaign involved malicious actors gaining unauthorized access to a number of legitimate PyPI user accounts. The primary method of compromise appears to be credential stuffing, where attackers use username and password combinations leaked from other data breaches to try and log into PyPI.
Once they gained control of an account, the attackers used it for malicious purposes, including publishing harmful packages designed to steal developer credentials or compromise system security. By using legitimate, established accounts, the attackers attempted to bypass suspicion and trick developers into downloading their malware.
To safeguard the entire community from further risk, PyPI’s security team made the critical decision to perform a platform-wide reset of API tokens. This action ensures that even if an attacker had exfiltrated a token from a compromised account, it can no longer be used.
Action Required: What You Must Do Now
This token invalidation means that any automated systems, such as CI/CD pipelines, build scripts, or deployment tools that rely on a PyPI API token, will fail until you take action.
Here are the essential steps every PyPI user should take immediately:
Generate a New API Token: Log in to your PyPI account and navigate to your account settings. Delete any old tokens and generate new, more secure API tokens for your projects. It is crucial to use project-scoped tokens whenever possible, as they limit potential damage if a token is ever compromised.
Update Your Systems and Environments: Replace the old, invalidated tokens in all of your tools and environments. This includes your local development setup, GitHub Actions secrets, GitLab CI/CD variables, and any other automation scripts that publish packages to PyPI.
Secure Your PyPI Account: This incident is a stark reminder of the importance of account security. If you haven’t already, enable Two-Factor Authentication (2FA) on your PyPI account immediately. This is the single most effective step you can take to prevent unauthorized access, even if your password is stolen.
Best Practices for Long-Term Security
While the immediate threat has been contained, developers should adopt stronger security habits to protect their accounts and contributions from future attacks.
- Use a Password Manager: Never reuse passwords across different websites. A password manager helps you generate and store strong, unique passwords for every service you use, drastically reducing your risk from credential stuffing attacks.
- Regularly Audit Your Tokens: Don’t let old or unused API tokens linger. Periodically review the tokens associated with your account and revoke any that are no longer needed. Always use the principle of least privilege by scoping tokens to specific projects.
- Be Vigilant: Scrutinize dependencies before adding them to your project. Check for signs of typosquatting (e.g.,
reqeustsinstead ofrequests) and be cautious of newly published or unfamiliar packages.
PyPI’s swift and comprehensive response to the “GhostAction” campaign was a necessary, albeit disruptive, measure to protect the open-source community. By taking a few moments to regenerate your tokens and strengthen your account security, you can help ensure the continued safety and reliability of the Python ecosystem.
Source: https://www.bleepingcomputer.com/news/security/pypi-invalidates-tokens-stolen-in-ghostaction-supply-chain-attack/


