# PyTorch Lightning PyPI Hijacked — Versions 2.6.2 and 2.6.3 Steal SSH Keys and Cloud Credentials

> Lightning 2.6.2 and 2.6.3 on PyPI are malicious. Anyone who pip-installed them in the last day needs to rotate every secret on the box.

- Org: Lightning AI / Semgrep advisory
- Date: 2026-04-30
- Category: security
- Source: https://semgrep.dev/blog/2026/malicious-dependency-in-pytorch-lightning-used-for-ai-training/
- Canonical page: https://ai-tldr.dev/releases/lightning-pypi-shai-hulud-attack/

## In short

Two malicious 'lightning' releases on PyPI ship a Bun-based stealer that pulls SSH keys, .env files, cloud credentials, and crypto wallets the moment the package is imported. Downgrade to 2.6.1 and rotate every secret.

## What it is

On April 30 attackers pushed two compromised builds of the popular 'lightning' Python package (the deep-learning training framework with hundreds of thousands of downloads per day). The builds are part of the Mini Shai-Hulud supply-chain campaign that already hit Bitwarden CLI and SAP-related npm packages this week.

## How it works

The malware lives in a hidden _runtime directory and is triggered from __init__.py the moment Python imports the package. It silently downloads Bun runtime 1.3.13, executes an 11 MB obfuscated payload (router_runtime.js), and exfiltrates SSH keys, shell histories, .env files, cloud creds (AWS/Azure/GCP), Discord/Slack tokens, kube/helm/npm configs, and crypto wallets. Stolen data is RSA-2048 encrypted and pushed to public GitHub repos. It also plants persistence hooks in .claude/ and .vscode/ and creates malicious GitHub Actions workflows to keep stealing repo secrets.

## Why it matters

ML training environments are credential-rich and rarely sandboxed — fine-tuning a model usually means valid AWS, GitHub, and Hugging Face tokens are sitting in env vars. This is the first major Shai-Hulud-pattern attack to reach a marquee AI/ML training package. Anyone running pip installs over the last day needs to assume every long-lived token on that machine is burned.

## Who it's for

ML engineers, infra teams, anyone running pip install lightning in the last 24 hours

## Try it

pip install lightning==2.6.1  # downgrade and rotate

## Links

- [Semgrep Advisory](https://semgrep.dev/blog/2026/malicious-dependency-in-pytorch-lightning-used-for-ai-training/)
- [Aikido Writeup](https://www.aikido.dev/blog/pytorch-lightning-pypi-compromise-mini-shai-hulud)
- [The Hacker News](https://thehackernews.com/2026/04/pytorch-lightning-compromised-in-pypi.html)
- [Socket Analysis](https://socket.dev/blog/lightning-pypi-package-compromised)
- [HN Discussion](https://news.ycombinator.com/item?id=47964617)
