PyTorch Lightning PyPI compromise
Two releases of lightning on PyPI ran injected code on import that started an infostealer aimed at credentials, CI secrets and cloud secret stores. It tried to spread with stolen tokens and left hooks in Claude Code and VS Code settings to run again. The maintainers have not published a root cause.
- First seen
- 2026-04-30
- Disclosed
- 2026-04-30
- Affected packages
- 1
- Attributed to
- No public attribution
What to do
Delete 2.6.2 and 2.6.3, assume the environment is compromised, rotate API keys, tokens, SSH keys and service-account credentials, and rebuild from a clean state. Check Claude Code and VS Code settings for hooks you did not add. Pin 2.6.1, or 2.6.4 and later.
Check a lockfile for these releases →| Package | Registry | Versions |
|---|---|---|
| lightning | PyPI | 2.6.2, 2.6.3 |
- https://github.com/Lightning-AI/pytorch-lightning/security/advisories/GHSA-w37p-236h-pfx3 · Lightning AI (maintainers), 2026-04-30
- https://github.com/Lightning-AI/pytorch-lightning/issues/21691 · Lightning-AI/pytorch-lightning (GitHub), 2026-04-30
- https://semgrep.dev/blog/2026/malicious-dependency-in-pytorch-lightning-used-for-ai-training/ · Semgrep, 2026-04-30
- https://osv.dev/vulnerability/MAL-2026-3201 · OpenSSF Malicious Packages (via OSV), 2026-04-30
Written up from the sources above and last checked on 2026-11-18. ShieldMap describes what was affected and what to do; it does not publish the malicious code or how it worked. Report a correction to [email protected].