Compromise of PyTorch Lightning PyPI Package Versions
Compromised PyTorch Lightning PyPI packages versions 2.6.2 and 2.6.3 contain malicious code related to credential harvesting, requiring immediate credential rotation and system rebuilding.
On April 30, 2026, Lightning AI disclosed a security incident affecting the PyTorch Lightning PyPI package. Versions 2.6.2 and 2.6.3 have been identified as compromised and contain malicious code. The ongoing investigation suggests the injected code functions as a credential harvesting mechanism, potentially exposing sensitive information like API keys, access tokens, SSH keys, and service account credentials. The root cause of the compromise is still under investigation, but Lightning AI has taken steps to quarantine the malicious versions and is working to determine the full scope and impact of the breach. Defenders should immediately rotate credentials and rebuild systems affected by these compromised packages.
Attack Chain
- Attacker gains unauthorized access to the PyTorch Lightning PyPI package release process.
- Malicious code is injected into the
2.6.2and2.6.3versions of thepytorch-lightningpackage. - Developers unknowingly install the compromised packages using
pip. - Upon execution, the malicious code begins harvesting credentials from the compromised environment.
- Stolen credentials, including API keys, access tokens, SSH keys, and service account credentials, are exfiltrated to an attacker-controlled server.
- The attacker uses the stolen credentials to gain unauthorized access to systems and data.
- The attacker may escalate privileges within the compromised environment using the acquired credentials.
Impact
The compromise of PyTorch Lightning versions 2.6.2 and 2.6.3 poses a critical risk to developers and organizations using these packages. Successful credential harvesting can lead to unauthorized access to sensitive data, system compromise, and potential financial loss. The number of affected users is currently unknown, but given the popularity of PyTorch Lightning, the potential impact could be significant across various sectors. Systems running the affected versions should be considered fully compromised until remediated.
Recommendation
- Immediately rotate all credentials and secrets that may have been exposed, including API keys, access tokens, SSH keys, and service account credentials, as mentioned in the advisory.
- Rebuild affected systems from a known clean state to eliminate any residual malicious code as recommended by the advisory.
- Pin PyTorch Lightning to version
2.6.1to prevent further installations of the compromised versions, per the advisory. - Review logs for any suspicious or unauthorized activity to identify potential breaches resulting from the compromised packages.
- Monitor network traffic for outbound connections to unusual or suspicious domains/IP addresses, which may indicate credential exfiltration.
Detection coverage 2
Detect Installation of Compromised PyTorch Lightning Package
criticalDetects the installation of the compromised PyTorch Lightning packages based on package name and version.
Detect Suspicious Network Connection by PyTorch Lightning
highDetects suspicious network connections initiated by Python processes associated with PyTorch Lightning, which may indicate credential exfiltration.
Detection queries are available on the platform. Get full rules →
Indicators of compromise
1
| Type | Value |
|---|---|
| security@lightning.ai |