Skip to content
← Back to blog
Security·November 27, 2026·10 min read

An npm worm on a subcontractor's laptop steals your client's secrets, not theirs: the install rules to set before a sub clones a client repo

The Shai-Hulud npm worms stole tokens from developer machines during npm install. What they read, and the install rules an agency sets for its subcontractors.

The npm worms of 2025 did not need to break into anyone's company. They ran inside npm install on an ordinary developer machine, read whatever tokens and keys were lying around, and published them. For an agency, the uncomfortable part is whose keys those are. A subcontracted engineer's laptop holds your client's staging keys, a GitHub token that reaches your organization, and often a cloud profile for the client's account. When that laptop installs a poisoned package, the secrets that leak are the client's, and the client hears about it from you, or worse, before you.

This post reads what the two Shai-Hulud waves actually took, from the publishers who documented them, and turns it into the install rules an agency should write into a subcontractor's onboarding before the first clone. It is an engineering reading, not an incident-response contract.

What did the Shai-Hulud worm do?

Shai-Hulud is a self-replicating worm that spread through the npm registry in two waves in 2025. GitHub, which runs npm, said on 22 September 2025 that it was notified of the attack on 14 September and removed more than 500 compromised packages. The US Cybersecurity and Infrastructure Security Agency (CISA) issued an alert on 23 September 2025 describing a worm that had compromised over 500 packages, scanned the machine it ran on for GitHub personal access tokens and API keys for AWS, Google Cloud and Azure, sent them to an attacker-controlled endpoint, and uploaded them to a public GitHub repository named "Shai-Hulud." It spread by logging into npm as the developer it had just robbed and publishing infected versions of that developer's own packages.

The second wave was larger. Datadog Security Labs reported on 25 November 2025 (updated 4 December) that it had backdoored 796 unique npm packages across 1,092 versions, with more than 20 million weekly downloads between them. Datadog counted over 14,000 exfiltration repositories and estimated, as a lower bound, that data from more than 500 GitHub users across more than 150 GitHub organizations had been taken. This wave ran from a new preinstall script, so it fired before the install had even finished.

Why is this an agency problem and not just a developer problem?

Because the worm reads the machine, not the project. Datadog's write-up lists what the second wave went after: environment variables, local cloud credential files, GitHub tokens, npm tokens in .npmrc files, cloud instance metadata, and anything else Trufflehog could find on disk. None of that is scoped to the package being installed. A subcontractor who runs npm install on a side project at 11pm exposes the .env they copied for your client's checkout rebuild that afternoon.

Two more details from Datadog change the response. If the worm could not find a valid GitHub or npm token, it tried to destroy every file in the user's home folder, which on a subcontractor's machine includes your client's working copy. And it installed a self-hosted GitHub Actions runner on compromised machines, paired with a workflow the attacker could trigger by opening a GitHub discussion. Datadog said it had not yet seen that channel used. A runner left behind is a way back in that survives a password change.

My view, and one I would defend on a first call: if a subcontractor needs a client's long-lived production cloud keys on their laptop to do the job, the project is set up wrong, and no install rule makes it safe.

What sits on a subcontractor's laptop, and what removes it?

This is the table to run down with any engineer before they clone a client repository. The left column lists what can end up on a laptop over the course of a project; the right column is what makes that line harmless if the worm runs.

On the laptopWhat the worm does with itThe control
Client .env with staging and third-party API keysReads environment variables and files, publishes themPull secrets at run time from a vault or the cloud CLI's short session; nothing long-lived in a file
A classic GitHub personal access token with org-wide scopeUses it to publish the stolen data and reach every repo it can seeFine-grained token, single organization, named repositories, an expiry date
AWS, Google Cloud or Azure credential files for the client accountReads them and queries instance metadataSSO with short sessions; no static access keys on a subcontractor machine
An npm token in .npmrcLogs in as the developer and republishes their packagesNo publish rights for subcontractors; publishing through CI with trusted publishing
A registered self-hosted runnerGives the attacker a command channelOrg-level runner list reviewed at onboarding and offboarding

What did npm change, and what is still your job?

npm closed one door. GitHub's changelog of 9 December 2025 says all existing npm classic tokens were permanently revoked, that npm login now issues a session that expires after two hours with 2FA enforced for publishing, and that granular tokens with write access are limited to 90 days. GitHub recommends OIDC trusted publishing for CI, which removes the publishing token entirely.

That fixes the spreading step. It does nothing about the reading step, because the payload still runs with your engineer's permissions the moment a lifecycle script executes. The settings that address that already exist:

  • ignore-scripts. npm's configuration reference says that when this is true, npm does not run scripts specified in package.json files, including the pre- and post- scripts around install. The default is false. Most front-end projects install cleanly with it on; the handful of packages that need a build step can be rebuilt explicitly.
  • pnpm 10. Its January 2025 release made dependency lifecycle scripts opt-in: they are not run during installation by default, and a project allows specific packages through onlyBuiltDependencies in package.json. If a client project is on pnpm 10, check that nobody has turned this back off.
  • A release-age delay. npm's current configuration reference documents min-release-age, which only installs versions that have been available for more than a given number of days. Both Shai-Hulud waves were caught and pulled within days, so a one-week delay would have kept most installs on clean versions. Check that the npm version your engineers run supports it before writing it into a policy.
  • npm ci against a committed lockfile, so an install cannot quietly pick up a newer version than the one reviewed.

A worked example: one Thursday, two engineers

Picture a 14-person agency running a storefront rebuild for a retail client, with two subcontracted engineers in the client's GitHub organization. One has a classic personal access token that reaches every repository in the agency's org, a .env with the client's payment-provider test keys and its email provider's live key, and an AWS profile with an access key the client's previous agency created two years ago. The other works in a container, pulls secrets through the client's SSO each morning, and has a fine-grained token limited to the two repositories on the project.

Both run npm install on a personal project that pulls in a compromised package. The second engineer loses a token that expires in weeks and reaches two repositories. The first hands over a live email key that can send as the client's brand, a cloud key nobody remembers creating, and read access to the agency's other client work. Same worm, same evening. The difference is entirely the onboarding.

The first engineer's mess is also the agency's to report. Whatever your master services agreement says about notice to the client, the clock starts when you find out, so the subcontract should require the engineer to tell you within hours, not at the next standup. Our subcontractor offboarding checklist is the rotation list to run next, and what to do in the first hour after opening a malicious repo covers the machine itself.

What to put in the onboarding doc

CISA's September 2025 alert is a good spine for this, and most of it costs nothing: rotate developer credentials after any exposure, require phishing-resistant multifactor authentication on GitHub and npm, remove GitHub Apps and OAuth apps nobody uses, audit repository webhooks and secrets, and turn on branch protection, secret scanning alerts and Dependabot security updates. On top of that, for every subcontractor:

  1. 1.Fine-grained GitHub token or SSH key per engineer, scoped to the named repositories, with an expiry that matches the engagement.
  2. 2.No long-lived client cloud keys on the laptop. Short sessions through the client's SSO, or a dev environment the client controls.
  3. 3.ignore-scripts on, or pnpm 10's default left alone, with an allowlist for the packages that genuinely need a build step.
  4. 4.npm ci against the committed lockfile; no unreviewed lockfile changes in a pull request.
  5. 5.A notification clause: the engineer tells you within a set number of hours of any suspected compromise on a machine that has touched client code.
  6. 6.At onboarding and offboarding, review the organization's self-hosted runners, deploy keys and OAuth grants, not just its member list.

Where this is the wrong answer: if a client's contract says no third party may hold its code or data on a machine the client does not manage, no install rule gets you there. That client needs work done on its own managed devices or virtual desktops, and the honest move is to say so before quoting. And for a two-day fix on a static site with no secrets in it, a full policy is overhead; a scoped token and a lockfile are enough. Our guide to checking a git repo for malicious hooks covers the related risk of code that arrives with a lure attached.

When we put a named senior engineer or a two-person pod into an agency's repositories, the rules above are how the engagement starts: your repos, your cloud, scoped access that ends when the work does. The agency partner page describes the pilot, and the team-building page covers longer engagements. If you are deciding what your own subcontractor onboarding should require, tell us about the project and we will walk through the access list with you.

Sources

Written by Zain Ali

Frequently asked questions.

Shai-Hulud was a self-replicating worm spread through npm packages in 2025. CISA's alert of 23 September 2025 said it had compromised over 500 packages, stole GitHub tokens and AWS, Google Cloud and Azure keys from the machine it ran on, and posted them to a public GitHub repository. Datadog Security Labs reported on 25 November 2025 that a second wave had backdoored 796 packages.

Yes. Datadog Security Labs' November 2025 analysis of the second Shai-Hulud wave says it read environment variables, local cloud credential files, GitHub tokens and npm tokens from the whole machine, not just the project being installed. Any client keys stored on the subcontractor's laptop were in reach, whichever project triggered the install.

It stops the route both Shai-Hulud waves used. npm's configuration reference says that with ignore-scripts set to true, npm does not run scripts in package.json files, including pre- and post-install scripts, and Datadog's November 2025 analysis shows the second wave ran from a preinstall script. Malicious code that runs when your app imports the package is not covered, so it is one control rather than the whole answer.

GitHub's npm changelog of 9 December 2025 says all classic npm tokens were permanently revoked, npm login now creates a session that expires after two hours with 2FA enforced for publishing, and granular write tokens are limited to 90 days. GitHub recommends OIDC trusted publishing for CI so no publishing token needs to exist.

CISA's September 2025 alert says to rotate all developer credentials immediately and audit GitHub apps, webhooks and secrets. Datadog's November 2025 analysis adds that the second wave installed self-hosted GitHub runners and could delete the home folder, so check the organization's runner list and treat every client secret that was on that machine as exposed.