AWS Builder Center
The npm Worm That Fooled Every Trust Signal We Had

The npm Worm That Fooled Every Trust Signal We Had

A supply chain worm that passes every trust signal (provenance, SLSA, signed commits) just poisoned 420 npm packages in half an hour. It steals AWS keys, npm tokens, and Kubernetes secrets, then publishes infected versions of your other packages. If your CI/CD uses long-lived credentials, assume compromise. Here's how to detect, remediate, and prevent this with CloudTrail, GuardDuty, CodeArtifact, and DNS Firewall.

This morning a co-worker sent me  this article  about an npm worm that poisoned over 400 packages in half an hour. I read it over coffee and nearly spilled it. Not because supply chain attacks are new. They are not. But because this one carried valid provenance signatures (cryptographic proof that a package was built from a specific repo, through a specific pipeline, by a specific identity), green-check verified commits, and still managed to plant hooks inside Claude Code and VS Code that survive long after the package itself is removed.
Let me break down what happened, why it matters even if you think "we already dealt with Shai Hulud last year," and what you can do about it today using AWS services you probably already pay for.

What Actually Happened on August 4, 2026

Someone compromised the publishing credentials for  keyv , a widely used key-value storage adapter with millions of weekly downloads. They pushed  keyv@6.0.0  with a  preinstall  script that downloads a compiled binary, which proceeds to vacuum up every credential it can find: npm tokens, GitHub PATs, AWS keys, Kubernetes secrets, Vault tokens, database credentials, and private keys. Security researchers at Aikido linked the attack to the Shai Hulud worm family, making this effectively the third major wave.
Then the worm does what worms do. It uses whatever stolen npm tokens it finds to publish infected versions of other packages those tokens have access to. SafeDep tracked 1,684 poisoned versions across 420 package names spanning nine organizations. The entire cross-org publishing burst took roughly 30 minutes. That is around one new infected organization every two to seven minutes.
But here is the part that made me put down my coffee. The malicious release carried valid  OIDC and SLSA provenance attestations  because it passed through the project's legitimate GitHub Actions workflow. The commit that planted the payload had a green "Verified" badge on GitHub. The signatures verified. The build pipeline was real. The source entering it was not safe. Every trust signal we rely on said "this is fine."

The IDE Hooks: A New Execution Path

Unlike previous npm supply chain attacks, this one did not stop at package install scripts. The compromised repository also contained:
  • A  .claude/settings.json  with a  SessionStart  hook that calls a setup script
  • A  .vscode/tasks.json  with a  runOn: folderOpen  task that calls a different setup script
If you cloned the repo and opened it in VS Code or Claude Code, the payload had a second chance to run even if the npm install never fired. VS Code prompts before running automatic tasks in untrusted workspaces. Claude Code applies workspace trust to project settings. But "prompts before running" is not the same as "blocks by default," and not every developer reads every trust dialog with the same suspicion on a Monday morning.
As of reporting, both hook files were still present on the  main  branch.


Shai Hulud vs. The August Worm: Same Family, Bigger Teeth

If you responded to the  Shai Hulud campaigns  in late 2025, you already know the playbook. AWS Security published their lessons learned in December 2025 after responding to the Nx compromise, Shai Hulud waves 1 and 2, and the tea.xyz token farming campaign. The core worm behavior is the same. The response workflow is the same. But the scope and attack surface are not.

Shai Hulud (Sep-Nov 2025)
August 2026 Wave
Credential targets
npm tokens, GitHub PATs, cloud credentials
Same, plus Kubernetes, Vault, database, private keys
Scale
180 packages (first wave)
1,684 versions across 420 packages in 9 orgs
Propagation trigger
 postinstall  script
 preinstall  script in keyv@6.0.0
Persistence
GitHub Actions workflows
Same, plus Claude Code and VS Code hooks
Provenance
Valid signing
Valid OIDC and SLSA attestation, green verified commits
Time to cross-org spread
Days
~30 minutes
npm defense available
 --ignore-scripts  (manual opt-in)
npm 12 blocks lifecycle scripts by default (shipped July 8, 2026)
The takeaway: the worm got faster, wider, and grew a new execution path through developer tools that did not exist as a vector in 2025.

How to Detect If You Are Affected

Think of detection as working outward from the question: "Did stolen credentials do anything in my environment?" Here is the order:

1. CloudTrail First

CloudTrail is your ground truth. Look for your CI/CD role credentials being used from IP addresses that are not your build infrastructure. That pattern means credentials were exfiltrated and used elsewhere.
SELECT eventtime, useridentity.arn, eventname, sourceipaddress
FROM cloudtrail_logs
WHERE useridentity.type = 'AssumedRole'
AND useridentity.sessioncontext.sessionissuer.arn LIKE '%CodeBuild%'
AND sourceipaddress NOT IN (
SELECT DISTINCT sourceipaddress
FROM cloudtrail_logs
WHERE eventsource = 'codebuild.amazonaws.com'
)
AND readOnly = 'false'
ORDER BY eventtime DESC;
Also look for  GetSecretValue  calls outside of normal pipeline windows,  CreateAccessKey  events (persistence attempts), and  DeleteTrail  or  StopLogging  events (evidence destruction).

2. GuardDuty

GuardDuty generates specific findings for this pattern:
  •  UnauthorizedAccess:IAMUser/InstanceCredentialExfiltration.OutsideAWS  means instance credentials were used from outside AWS. That is your smoking gun for stolen keys.
  •  Execution:Runtime/SuspiciousCommand  fires when GuardDuty Runtime Monitoring detects unexpected process execution on a host. This is how you catch the  preinstall  script running credential harvesting commands.
Important: Runtime Monitoring must be explicitly enabled. It is not on by default. If you have not turned it on, you are missing the detection signal for this exact attack pattern.

3. IAM Access Analyzer

Once you know which credentials were compromised, IAM Access Analyzer tells you what those credentials had access to. This defines your blast radius. Every resource those credentials could reach must be assumed compromised until verified otherwise.

4. Amazon Inspector

Inspector scans container images and Lambda functions for vulnerable dependencies. For brand-new attacks without assigned CVEs, the Inspector team has historically detected and registered malicious packages within 30 minutes via their partnership with the OpenSSF. During the tea.xyz campaign, they identified over 150,000 malicious packages. For the August worm, check if your package versions appear in Inspector findings, but also verify your lockfiles independently since CVE coverage for zero-day supply chain attacks has inherent lag.

Remediation: The Order Matters

Here is where people get it wrong. The worm includes a credential-revocation watcher. If you rotate credentials before removing the malware, the watcher fires and runs an attacker-supplied handler.
That means:
Step 1: Remove the malware. Pin to known-good versions in your lockfile. Run  npm ci  with  --ignore-scripts  to reinstall without triggering hooks. Verify no  .claude  or  .vscode  hooks remain in cloned repositories.
Step 2: Rotate credentials AFTER the malware is gone.
For long-term access keys (which you should not have in CI/CD, but let's be realistic):
  1. Generate new key
  1. Store in  Secrets Manager  immediately
  1. Validate the new key works
  1. Deactivate the old key
  1. Delete the old key after a 48-hour validation window
For role session credentials (the  ASIA*  keys from  AssumeRole ), attach an inline deny-all policy conditioned on  aws:TokenIssueTime  before the compromise. This revokes all existing sessions without breaking new ones.
Step 3: Enable automatic rotation going forward. Secrets Manager automates rotation for supported services (RDS, Redshift, DocumentDB). For everything else, write a Lambda rotation function. The goal is short-lived credentials so that even if something gets stolen, it expires before it can be used.
Prevention: The Five Things to Do Right Now

1. Put CodeArtifact in Front of npm

 AWS CodeArtifact  as a private npm registry gives you one place to block compromised packages across your entire organization. Without it, you are chasing down every developer and every pipeline individually.
Once the attack is known, you can block those versions immediately:
aws codeartifact put-package-origin-configuration \
--domain my_domain \
--repository my_repo \
--format npm \
--package keyv \
--restrictions publish=BLOCK,upstream=BLOCK
That is a kill switch. One command, and no one in your org can pull the compromised version.  Package Groups  let you do this at domain scope without configuring each package individually.

2. Block Lifecycle Scripts by Default

npm 12 (shipped July 8, 2026) does this natively. It turns off  preinstall ,  install , and  postinstall  scripts by default and uses a strict-allow-scripts model where you explicitly approve each package that needs to run them.
If you are not on npm 12 yet:
  • Add  --ignore-scripts  to your CI/CD buildspecs
  • Use  allowScripts  in  package.json  to allowlist only reviewed packages
This is what the  AWS-recommended approach  looks like: default deny, explicit allow.

3. Kill Long-Lived Credentials in CI/CD

This is the single highest-leverage control. The  Well-Architected best practices for software supply chain security  blog (May 2026) is explicit: Shai Hulud succeeded by harvesting long-lived IAM access keys from CI/CD environments.
Replace them with:
  • IAM Roles for CodeBuild (temporary credentials that expire after the build)
  • IRSA for EKS (pod-level IAM roles, no keys stored anywhere)
  • GitHub OIDC federation (GitHub Actions assume an IAM role directly, no secrets stored in GitHub)
If there is no  ~/.aws/credentials  file on your build agent, there is nothing for the worm to steal.

4. Deploy Route 53 Resolver DNS Firewall

The worm needs to phone home. Route 53 Resolver DNS Firewall blocks outbound DNS resolution to known C2 and exfiltration domains. Deploy it centrally via AWS Firewall Manager, and it covers every VPC in your organization with no per-application changes required.

5. Generate SBOMs for Every Build

Have your pipeline output a Software Bill of Materials (CycloneDX or SPDX format) for every build and store it in S3. When the next campaign hits, and there will be a next one, you can identify affected workloads in minutes instead of hours.
AWS's own rapid impact assessment during Shai Hulud depended on having a comprehensive inventory of all open-source dependencies and their deployment locations. You need the same thing.

The Bigger Picture

The uncomfortable truth about this attack is that every trust signal we built over the past few years, provenance attestation, SLSA, signed commits, GitHub verified badges, all said "this package is legitimate." And technically they were correct. The build pipeline was real. The signing keys were valid. The provenance was accurate. What was not safe was the source code that entered the pipeline.
Provenance tells you WHERE something came from. It does not tell you WHETHER it is safe. That distinction matters enormously, and it is easy to conflate the two when a green checkmark gives you a feeling of security.
The defenses that actually work against this pattern are boring and structural:
  • Do not let arbitrary packages run code during install (npm 12,  --ignore-scripts )
  • Do not store long-lived credentials where packages can reach them (IAM roles, OIDC)
  • Control what enters your dependency graph at a chokepoint (CodeArtifact)
  • Detect when credentials are used from unexpected locations (CloudTrail, GuardDuty)
  • Block outbound exfiltration at the network layer (DNS Firewall)
None of these depend on trusting the package. They work precisely because they assume you cannot trust it.

Quick Reference: AWS Services and Their Roles

Service
What It Does For This Threat
CloudTrail + Athena
Forensic investigation: detect CI/CD role credentials used from unexpected IPs
GuardDuty
Runtime detection of suspicious commands and credential exfiltration
IAM Access Analyzer
Blast radius assessment: what could the compromised credentials reach?
Secrets Manager
Secure storage and automated rotation of credentials post-compromise
CodeArtifact
Private npm registry with kill-switch package blocking across the org
Inspector
CI/CD gate scanning and continuous container/Lambda vulnerability detection
Route 53 DNS Firewall
Block outbound exfiltration to C2 domains at the network layer
Security Hub
Centralize findings from all detectors for coordinated response

Further Reading




About the authors



 Carlos Calderon
   is a Solutions Architect at AWS, serving as a technical advisor to ISV and SaaS companies on cloud architecture and generative AI. With a background in leading AWS data center operations, he works with customers from architecture through deployment and mentors SAs and engineers across the builder community.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article