Shai-Hulud Themed Malware Found in the PyTorch Lightning AI Training Library
TL;DR Highlight
Lightning 2.6.2 and 2.6.3 on PyPI were compromised with credential-stealing malware that runs on import.
Who Should Read
ML or backend developers who install dependencies with pip and run training or fine-tuning pipelines with PyTorch Lightning.
Core Mechanics
- Two lightning versions are compromised
- PyPI package lightning 2.6.2 and 2.6.3 were hit by a supply chain attack on April 30, 2026.
- After pip install, importing the module auto-runs an obfuscated JavaScript payload in a hidden _runtime directory.
- It steals credentials broadly
- It targets 80+ credential file paths, environment variables, and GitHub Actions secrets.
- It also reads AWS, Azure, and GCP secret stores (Secrets Manager, Key Vault, Secret Manager).
- Exfiltration uses four channels
- HTTPS POST to a C2 server, a GitHub commit-search dead-drop, an attacker's public repo, and pushes to the victim's own repo run in parallel.
- Data still leaves if one path is blocked.
- It spreads from PyPI to npm
- If it finds npm publish tokens, it injects a dropper into every package the token can publish and sets a preinstall script.
- It bumps the patch version and republishes, so downstream developers get infected too.
- It plants persistence in Claude Code and VS Code
- A SessionStart hook in .claude/settings.json and a folderOpen task in .vscode/tasks.json run setup.mjs whenever the repo is opened.
- The article says this may be among the first documented real-world abuses of Claude Code hooks.
- It also drops a malicious GitHub Actions workflow
- With a write-access token, it pushes a workflow named Formatter.
- On every push it dumps all secrets via toJSON(secrets) into an artifact named format-results.
Community Reactions
- Commenters feel supply chain attacks are frequent
- One commenter noted several high-profile package attacks appearing recently.
- They argued accessible, easy defensive tooling is lacking for hobby projects that become widely used dependencies.
- A comment pointed to pip cooldowns
- A commenter noted pip added cooldowns in 26.1.
- Use pip install --uploaded-prior-to=P1D or the PIP_UPLOADED_PRIOR_TO=P1D env var.
- Pinning via lock file worked, per one user
- One user runs a monorepo with a single uv.lock updated only a few times a year, so lightning stayed at 2.6.1.
- The maintainers advised using 2.6.1 until 2.6.4 is published.
- Opinion: blindly running AI-suggested pip installs is risky
- One commenter said most of their pip installs come from Claude Code suggestions accepted with enter.
- They noted the model was trained months ago and cannot know what got compromised this week.
- Commenters questioned the issue handling
- One pointed out four security issues were auto-commented and closed by a bot called pl-ghost.
- Another cited an April 20 reply saying the 2.6.2 release was blocked for internal reasons and wondered if the problem was known earlier.
How to Apply
- Check your lightning version today
- Run pip show lightning and check lock files for 2.6.2 or 2.6.3 in both CI images and local machines.
- If found, pin to 2.6.1 until 2.6.4 is published.
- Search for infection artifacts
- Look in your repos for .claude/settings.json, .claude/setup.mjs, .claude/router_runtime.js, .vscode/tasks.json, and .vscode/setup.mjs with unexpected content.
- Also search GitHub for the commit prefix EveryBoiWeBuildIsAWormyBoi and the description "A Mini Shai-Hulud has Appeared".
- Rotate all credentials in affected environments
- Treat any machine that imported a bad version as fully compromised and rotate GitHub tokens, cloud credentials, API keys, and npm tokens.
- Also check repos for a Formatter workflow and a format-results artifact.
- Enable a pip cooldown
- On pip 26.1 or later, run pip config set global.uploaded-prior-to P1D.
- This delays new releases by a day, giving time for compromises to be found.
Try It
# Paste into your shell: check the current environment and repo for lightning infection
pip show lightning | grep -i '^version'
pip list 2>/dev/null | grep -i '^lightning '
grep -rnE 'lightning[=@ ]*2\.6\.(2|3)' requirements*.txt poetry.lock uv.lock Pipfile.lock 2>/dev/null
for f in .claude/settings.json .claude/setup.mjs .claude/router_runtime.js .vscode/tasks.json .vscode/setup.mjs; do [ -e "$f" ] && echo "Needs review: $f"; done
git log --all --oneline | grep -i 'EveryBoiWeBuildIsAWormyBoi'
python -c "import importlib.util,os;s=importlib.util.find_spec('lightning');print('_runtime exists' if s and os.path.isdir(os.path.join(os.path.dirname(s.origin),'_runtime')) else 'no _runtime')"
pip config set global.uploaded-prior-to P1DTerminology
Related Papers
The Agent SDK
Cursor released Agent SDK, letting you define agents in code and deploy them with one command.
Here be monsters: What do you still need to know when agents do the work?
Owning agent-written code depends on fundamentals, breadth, and diving deep just in time.
AI promised less work. I've never worked more
Running agents in parallel brought my GitHub activity back to full-time engineer levels, and I'm exhausted.
Show HN: Corgi, a helpful {agent, terminal} multiplexer
A tmux-like terminal tool that shows the status of all your AI agents at a glance
Ask HN: If the models are so good, why doesn't OpenAI just start 100 companies?
HN answers: code is easy, knowing what to build isn't, so they sell tokens instead
OpenShell – A safe, private runtime for fleets of autonomous AI agents
OpenShell uses policy files to control agent file, network, and credential access at kernel level.
Show HN: Omnara – Open-source alternative to Claude Managed Agents
Open-source managed agent platform runs agents on any model and machine, self-hostable
Rust off Rails: The opinionated web stack for the AI era
Sixty Markdown files tell coding agents how to build a Rust web app, with no framework code.
Related Resources
- https://semgrep.dev/blog/2026/malicious-dependency-in-pytorch-lightning-used-for-ai-training/
- https://socket.dev/blog/lightning-pypi-package-compromised
- https://news.ycombinator.com/item?id=47964003
- https://discuss.python.org/t/announcement-pip-26-1-release/107108
- https://ichard26.github.io/blog/2026/04/whats-new-in-pip-26.1/
- https://github.com/Lightning-AI/pytorch-lightning/security/a...