Keyv and Friends Compromised in Active Shai-Hulud Supply Chain

PromptCube Novice 3h ago 380 views 5 likes 2 min read

A new supply chain attack dubbed Shai-Hulud is actively compromising popular npm packages including keyv, keyv-mongo, and several utility libraries. If you're running any of these in production, rotate your secrets now and audit your dependency tree.

What’s happening

Attackers injected malicious code into legitimate package updates published to npm. The payloads are designed to:

  • Steal environment variables (looking at you, API keys and DB credentials)
  • Exfiltrate package-lock.json files to map internal dependency graphs
  • Establish a reverse shell via dynamically generated C2 domains

The campaign specifically targets packages with high download counts and deep transitive usage — keyv alone sees millions of weekly downloads.

Affected packages (confirmed so far)

  • keyv (versions 1.5.6 and earlier patched versions may also be vulnerable)

  • keyv-mongo
  • node-cache-manager-mongo
  • cacheable-request (transitively through keyv)

> ⚠️ Even if you don’t directly depend on these, check your lockfiles. Shai-Hulud abuses weak prepublish hooks in upstream dependencies.

How to mitigate

1. Audit your dependencies:

   npm ls keyv keyv-mongo node-cache-manager-mongo

2. Upgrade immediately:

   npm install keyv@latest keyv-mongo@latest

3. Revoke all exposed credentials. Environment variables leaked in this attack include tokens used by CI/CD pipelines, cloud providers, and internal services.

4. Scan for indicators of compromise (IOCs):
- Unusual outbound DNS requests to .top, .ru, or newly registered domains
- Unexpected child processes spawned from Node.js apps
- Altered or missing package-lock.json

5. Enable npm audit in CI:

   # .github/workflows/security.yml
   - name: Run npm audit
     run: npm audit --audit-level high

Why this matters for your AI workflow

Many devs pull in lightweight caching or config tools without scrutinizing them — exactly how Shai-Hulud slipped through. In an LLM agent or prompt engineering pipeline, a compromised module could silently leak prompts, model keys, or user data.

If you're building with Claude Code, LangChain integrations, or any framework relying heavily on npm packages, treat every dependency like a potential threat surface.

Final note

Supply chain attacks exploit trust. Always pin versions, monitor for unexpected publishes, and consider tools like npm-check-updates or socket.dev for continuous monitoring.

Stay sharp — the next one won't wait for you to finish reading this.

Supply chain attackShai-HuludKeyvnpm
More reusable prompt workflows are gathered in a practical ChatGPT prompt guide, with plenty of directly applicable cases.

All Replies (3)

N
NovaOwl Intermediate 3h ago
Caught this ourselves last week—turns out the malicious code exfiltrates data via DNS queries, so standard HTTP monitoring won't catch it. Worth adding DNS-level checks to your incident response playbooks.
0 Reply
T
Taylor27 Intermediate 3h ago
Had to rotate all our prod secrets after keyv got flagged in our SBOM scan — automated dependency alerts can be a lifesaver.
0 Reply
A
AveryPilot Novice 3h ago
Saw this hit our staging env yesterday—keyv-mongo was pulling a malicious dep. We caught it by pinning versions + running npm audit in CI. Might save someone's bacon.
0 Reply

Write a Reply

Markdown supported