Compromised PyTorch Lightning Packages on PyPI Steal Developer Credentials
Compromised PyTorch Lightning packages versions 2.6.2 and 2.6.3 on PyPI contain malicious code to steal developer credentials from cloud and developer environments, and republish infected packages.
On April 30, 2026, two malicious versions (2.6.2 and 2.6.3) of the widely used pytorch-lightning package were published to the PyPI registry after the publisher account was compromised. These versions contain embedded malicious code designed to steal developer credentials and republish infected versions of repositories to which the stolen tokens have access. The attack is triggered upon importing the package, initiating a background process that silently harvests credentials from a wide array of services, including AWS, Azure, Google Cloud, and GitHub, as well as local environment variables and credential files. Version 2.6.3 was published just 13 minutes after 2.6.2, and was intended to evade detection.
Attack Chain
- Attacker compromises the publisher account for the
pytorch-lightningpackage on PyPI. - Attacker publishes malicious versions 2.6.2 and 2.6.3 to PyPI.
- A modified
__init__.pyfile within the package initiates a background process upon import. - The background process executes silently, without any visible output or indication of compromise to the user.
- The malicious package downloads a runtime (Bun) from GitHub.
- The package executes a large, obfuscated JavaScript file, targeting AWS, Azure, Google Cloud, GitHub, and local credential stores.
- Stolen credentials, including cloud provider keys, API tokens, and secrets, are exfiltrated to attacker-controlled infrastructure.
- The malware attempts to download and execute a second-stage payload from attacker-controlled infrastructure, expanding the scope of the attack.
Impact
Organizations that downloaded and used versions 2.6.2 or 2.6.3 of the pytorch-lightning package are at high risk of compromise. The malicious package is designed to steal a wide range of credentials, including cloud provider keys, API tokens, and secrets stored in environment variables. This can lead to unauthorized access to sensitive data and systems, potentially resulting in data breaches, financial losses, and reputational damage. The malware’s ability to download and execute secondary payloads further increases the potential impact.
Recommendation
- Immediately remove versions 2.6.2 and 2.6.3 of the
lightningpackage from all systems where they are installed (see overview). - Audit systems for unauthorized processes and review outbound network connections to detect potential compromises (see overview).
- Rotate all cloud provider keys (AWS, Azure, GCP), API tokens (GitHub, CI/CD systems), and secrets stored in environment variables to prevent further unauthorized access (see Attack Chain).
- Implement the
Detect Suspicious PyPI Package InstallationSigma rule to identify potential malicious packages being installed in the future (see rules). - Implement the
Detect Credential Harvesting via BunSigma rule to catch execution of the malicious JavaScript payload (see rules). - Pin dependencies to known-good versions and verify package integrity before use to prevent future supply chain attacks (see references).
Detection coverage 2
Detect Suspicious PyPI Package Installation
highDetects the installation of specific malicious PyPI packages by name.
Detect Credential Harvesting via Bun
mediumDetects execution of Bun, potentially related to credential harvesting, based on process name.
Detection queries are kept inside the platform. Get full rules →