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 laptop | What the worm does with it | The control |
|---|---|---|
Client .env with staging and third-party API keys | Reads environment variables and files, publishes them | Pull 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 scope | Uses it to publish the stolen data and reach every repo it can see | Fine-grained token, single organization, named repositories, an expiry date |
| AWS, Google Cloud or Azure credential files for the client account | Reads them and queries instance metadata | SSO with short sessions; no static access keys on a subcontractor machine |
An npm token in .npmrc | Logs in as the developer and republishes their packages | No publish rights for subcontractors; publishing through CI with trusted publishing |
| A registered self-hosted runner | Gives the attacker a command channel | Org-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
onlyBuiltDependenciesin 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 ciagainst 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.Fine-grained GitHub token or SSH key per engineer, scoped to the named repositories, with an expiry that matches the engagement.
- 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.
ignore-scriptson, or pnpm 10's default left alone, with an allowlist for the packages that genuinely need a build step. - 4.
npm ciagainst the committed lockfile; no unreviewed lockfile changes in a pull request. - 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.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
- GitHub: Our plan for a more secure npm supply chain (22 September 2025)
- CISA: Widespread supply chain compromise impacting npm ecosystem (23 September 2025)
- Datadog Security Labs: The Shai-Hulud 2.0 npm worm (25 November 2025, updated 4 December 2025)
- GitHub changelog: npm classic tokens revoked, session-based auth and CLI token management now available (9 December 2025)
- npm Docs: config reference, ignore-scripts and min-release-age
- pnpm: v10.0.0 release notes