2084AI Security Observatory

Black BoxSupply Chain2084-A-0002

Opening the repo can be enough: npm worms now hide in AI coding-agent configs

Through 2026 the Shai-Hulud worm family added a second trigger. Besides npm install, it now plants code in the files your editor and coding agent run when you open a project, so turning off install scripts closes only half the door.

In 2026 a family of self-propagating npm worms learned a second way in: besides running when a package is installed, it plants triggers in the configuration files that AI coding agents and editors run automatically, so a poisoned project can execute the moment a developer opens it 1. The rule of thumb was that a malicious package runs at install time, and that blocking install scripts kept you mostly safe 26. That rule no longer covers the whole risk. npm shipped a major version in July that turns dependency install scripts off by default 7. That helps, but it closes only half the door: this route never needed an install script.

What happened

Across 2026, security vendors tracked several waves of an npm worm family variously called Shai-Hulud, Mini Shai-Hulud, Miasma and ChainDrop 128. The name goes back to the original Shai-Hulud worm, which the U.S. Cybersecurity and Infrastructure Security Agency flagged in September 2025 after it compromised more than 500 packages and harvested developer and cloud credentials 11. StepSecurity describes the August 2026 payload as a heavily evolved descendant of the worm's November 2025 wave, now with persistence aimed at AI developer tools.

The earliest case among the sources cited here came in late April, when SAP's MTA build tool and three database packages for its CAP framework were poisoned on npm 910. SafeDep found that in GitHub Actions environments the malware committed a VS Code task to victims' repositories that re-ran its dropper, stored in the Claude directory, whenever the project was opened; SAP warned that uninstalling the packages may leave IDE configuration changes behind, possibly committed to other repositories 9.

On 1 June, Red Hat disclosed that malicious versions of 32 packages in its @redhat-cloud-services npm namespace had been published 8. These are front-end libraries for its Hybrid Cloud Console 8. Red Hat later confirmed that a GitHub account compromised through a malicious VS Code extension had been used to inject the code and alter configuration files "to infect other developers opening those directories"; it says no product builds contained the compromised versions and no customer action is required 8. SafeDep found that every malicious version carried valid provenance and that the persistence code referenced a Claude Code session-start hook alongside the VS Code task. Within days a parallel arm of the worm skipped the npm registry entirely, pushing straight to GitHub source repositories; a security notice from the mantine-datatable project's maintainers describes such commits and lists planted triggers for Claude Code, Gemini CLI, Cursor and VS Code.

Then came scale. On 4 August a wave the researchers named ChainDrop tore through npm. It started from a compromised maintainer account behind the popular keyv key-value library, spread first to packages that maintainer could publish and then, using harvested credentials, to packages from other, unrelated publishers 12. Singapore's Cyber Security Agency issued a public advisory two days later 3. In late October researchers documented a fresh derivative, tracked as "testmetest" 5.

How it works

The shift is conceptual. Classic npm malware fires from an install hook: preinstall, postinstall, or the native build npm runs implicitly during install 26. The 2026 worms still use that path where they can — ChainDrop's main trigger was a preinstall script 12 — but their durable foothold is somewhere else.

Modern coding tools each have a legitimate feature that runs a command automatically when you start work. An editor can run a task the moment a folder is opened 15. A coding agent can run a hook the moment a session starts 18. A project "rules" file can tell an assistant to run a setup step when the workspace opens, as the mantine-datatable notice describes for Cursor. These exist for convenience; Claude Code's documentation, for instance, suggests session-start hooks for loading context or setting environment variables 18. The worm writes its own entries into those files — a Claude Code session-start hook, a Gemini CLI session-start hook, a Cursor project rule, a Visual Studio Code open-on-folder task — each pointed at a dropper it also plants in the repository 1. Elastic's analysis of ChainDrop describes exactly this: a session-start hook in the Claude directory and an open-on-folder task for VS Code, each launching the dropper, so that "a developer can still be infected by just opening the repository" 1. Microsoft's write-up of the same campaign says the injected Claude and Visual Studio Code configuration creates "a secondary infection route", through which later editor or agent activity can restart the payload even after the original npm install has finished 2.

Two consequences follow. First, that notice says the clone of a poisoned repository is itself harmless; the risk arrives the first time a developer opens the folder in an editor or starts an agent session in it. Second, the worm can spread without touching the registry. With suitable stolen GitHub credentials it commits the same configuration files across the branches of repositories it can reach — up to 50 branches per repository, according to Elastic 1 — under an AI-assistant-style author name and a routine-looking configuration-update message 1, which StepSecurity says disguises the commits as AI-assistant output. The credential harvest is broad: developer and CI secrets, source-control and registry tokens, SSH keys, and credentials for several major cloud providers and for AI coding tools themselves 12.

On the registry side, the worms kept finding ways around install-script defences. In June, and again in October, the trigger was hidden in a native-build configuration file, so a package with no declared install script still ran code at install time through the build step npm runs implicitly 56. A July compromise of four AsyncAPI packages carried no malicious install script at all: code inserted into ordinary source files ran whenever a poisoned module was loaded, which JFrog suggests may have been a fallback against npm 12's script blocking 4. The newest "testmetest" build, documented on 27 October, moved the trigger into a compiled native add-on that starts when an application loads the package; installing with scripts disabled does not stop it, SafeDep notes 5. Put together, the family now has triggers at install time, at module load and at project open, and only the first is blocked by turning off install scripts.

How far it spread

The counts differ by vendor and by the hour they were measured, so they are worth stating with their sources attached.

For ChainDrop in August, StepSecurity reported the worm "poisoned 444 packages and 2,212 versions in under four hours"; Elastic, at the time of its writing, and Microsoft each put the figure at more than 400 packages 12; and Singapore's CSA counted more than 1,300 package versions, a combined two billion monthly downloads 3. Elastic separately noted that keyv alone drew over 600 million downloads in the previous month, and that the co-owned packages together exceed 1.3 billion monthly downloads 1. Packages the worm pushes through npm's trusted-publishing path can carry valid provenance 2. StepSecurity, which found the headline packages shipped that way, stresses that this is no safety signal: a valid attestation shows which commit was built, but it cannot show that anyone authorised that commit.

The earlier waves were smaller: four SAP-related packages in April 910; 32 Red Hat packages around 1 June 8 (96 versions, by SafeDep's count); more than 120 GitHub repositories in the source-repository arm of early June, a count SafeDep describes as a minimum; and four AsyncAPI packages with five malicious versions in July 4.

October is where the public record splits. SafeDep first documented the npm side on 22 October. By its update of 27 October it had counted 19 packages published from the operator's own accounts between 19 and 27 October, and it said that as of 22 October it had "found no compromised third-party packages or victims" 5. Four days after SafeDep's first report, JFrog's investigation of the campaign's GitHub side reached a different conclusion: 42 armed third-party repositories across 11 legitimate owners, with scripted arming batches run as early as 28 September. JFrog says those repositories "contain execution hooks for AI coding assistants and IDEs" — a Claude settings file with a session-start hook, Gemini and Cursor configurations and a VS Code open-on-folder task — and that the payload hidden in them decodes to a publisher built to push further malicious npm releases. JFrog calls its work complementary and says the gap was not merely a matter of timing: the payload files, at 12.9 to 13.7 MB each, were too large for the GitHub search and API paths normally used to find such compromises.

What is still unclear

Attribution is open. None of the primary sources cited here names a responsible group. JFrog describes the October payload as a Shai-Hulud descendant that shares tooling with earlier waves; SafeDep notes that the Shai-Hulud source has been public since May, so other groups can build on it. Both decline to attribute the October activity to the original Miasma operators 5. Red Hat describes Miasma itself as an open-source malware kit 8, so the family name travels with the code, not with a known actor.

Impact depth is open, too. JFrog's count is of armed repositories — ones that held the payload rather than an empty placeholder — not of machines that ran it. The operator's own data-sink repository had collected 27 encrypted snapshot files between 22 and 24 October, but JFrog says its metadata-only look at them cannot establish downstream victim identities or the number of affected systems. Capability is also not the same as behaviour in a given build: in the July AsyncAPI sample, JFrog found the worm's AI-poisoning and propagation modules present in the code but switched off in that deployment, and warned against attributing those dormant features to it 4. None of the sources cited here establishes how many developers were actually compromised through the open-the-folder route, as opposed to how many repositories were seeded with it.

What defenders can do now

The practical takeaway is that the centre of gravity has shifted from the package manager toward the repository and the developer's own machine. Six measures follow from the primary reporting and from the tools' own documentation.

  • Treat agent and editor config as code that runs. Put the .claude, .gemini, .cursor and .vscode directories, and agent instruction files such as CLAUDE.md and AGENTS.md, under code ownership and mandatory review, and have continuous integration raise an alert whenever one of them is added or changed 514. SafeDep's June analysis calls a session-start hook "a postinstall for your editor", and notes that most review workflows skip these directories. JFrog advises enumerating repository trees directly when hunting for planted files, because GitHub code search missed the oversized October payloads.
  • Lock down every branch, not only the default one. These worms commit across many branches at once 1, and StepSecurity says branch protection requiring pull-request review, even for the repository owner, would have broken the August chain. GitHub rulesets can require pull-request review, including from code owners, and signed commits; push rules, available for private and internal repositories on GitHub's Team plan, can also block changes to specified paths outright 1314. Signature checks catch unsigned commits, like the one behind the July AsyncAPI wave 4, but a verified badge proves little on its own: SafeDep found the June worm committing its injected workflow through GitHub's API so that the commit appeared verified. Elastic also publishes the author and message strings the August worm used, which are worth searching for 1.
  • Open untrusted repositories in isolation, with auto-run off. Open an unfamiliar checkout in a disposable environment first, and check each tool's trust controls, because several are off by default. Visual Studio Code opens unfamiliar folders in Restricted Mode, where automatic tasks never run; even in a trusted folder it asks once before running them unless you have set them to always run, and its documentation advises leaving a folder restricted when in doubt 1516. Cursor supports the same workspace trust but ships with it disabled, recommends a plain text editor for untrusted repositories, and by default asks before an agent runs a terminal command or connects to an MCP server 20. Gemini CLI's trusted-folders feature, which ignores a project's settings file until you trust the folder, is also off until you enable it 19. Claude Code holds back hooks in an interactive session until you accept its workspace-trust dialog, but non-interactive and SDK runs treat the folder as trusted and run a repository's committed hooks 1718. Before such a run over code you did not write, its documentation says to review the project's settings or switch hooks off for that run with a command-line override; a hooks-off setting in your own user file can be overridden by the project's settings, whereas the per-run override takes precedence over them, and administrators can limit hooks to centrally managed ones 18.
  • Move to npm 12 and add a release-age delay. npm 12, released on 8 July, blocks dependency install scripts, including the implicit native build, unless the project's allow-list permits them 67. The minimum-release-age setting, available since npm 11.10, holds back freshly published versions for a period you choose 27. StepSecurity says gating install scripts neutralises ChainDrop's install-time dropper, and that a three-to-seven-day minimum release age would have prevented virtually all automatic adoption of its malicious versions. Neither measure covers the open-the-folder or load-time routes.
  • Revoke two-factor-bypass tokens and tighten trusted publishing. ChainDrop's worm component activated only on npm tokens with write access that could publish without two-factor authentication; revoke such tokens and avoid issuing them 12. Several waves also published through the projects' own release or trusted-publishing pipelines, with valid provenance 24. Once trusted publishing is configured, npm recommends requiring two-factor authentication and disallowing tokens, and suggests deployment environments with approval requirements and tag protection 12. SafeDep traced the June provenance abuse to publishing trust that was tied to a repository and workflow file rather than to a branch or protected environment, so naming a protected environment in the trusted-publisher settings matters 212.
  • On any machine that ran a poisoned version, remove the persistence first, then assume the secrets are gone. Several of these payloads install a watcher that fires a destructive handler when the stolen GitHub token is revoked 25, so StepSecurity, SafeDep and JFrog all advise removing that persistence before revoking or rotating 5. Then treat cloud, AI-tool and CI credentials reachable from the workstation or runner as exposed, and rotate them from a known-clean host 123. CSA advises rebuilding affected systems, and SafeDep warns that planted agent files can re-infect a cleaned host 35.

The uncomfortable part is the symmetry: the conveniences that let a coding agent set itself up the moment you open a project are what let this worm run at that moment too. Defending against it does not mean giving up the tools. It means treating their configuration with the suspicion you already give an install script, because turning off install scripts alone is now only half a defence.

Timeline

  1. CISA flags the original Shai-Hulud worm: more than 500 npm packages compromised, developer and cloud credentials harvested. ↗(opens original source)

  2. SAP open-source npm packages for its CAP framework and MTA build tool are compromised with malware that can exfiltrate credentials; SAP warns that uninstalling them may leave IDE configuration changes behind, possibly committed to other repositories. ↗(opens original source)

  3. Red Hat discloses that 32 of its @redhat-cloud-services npm packages were compromised and published to the registry; it later confirms a GitHub account compromised through a malicious VS Code extension and says no product builds were affected. ↗(opens original source)

  4. The mantine-datatable project's maintainers publish a security notice reporting unauthorized commits to five of their GitHub repositories that wire Claude Code, Gemini CLI, Cursor and VS Code configs to a planted payload; no malicious npm version was published.

  5. npm 12.0.0 ships: dependency install scripts are blocked by default unless the root package's allowScripts policy allows them. ↗(opens original source)

  6. Miasma v3 hits four AsyncAPI packages through the project's own trusted-publishing workflow, with valid provenance; code runs on module load, and the AI-poisoning and propagation modules are present but disabled. ↗(opens original source)

  7. ChainDrop starts from the compromised keyv maintainer and uses stolen npm credentials to backdoor the other packages that maintainer can publish; Elastic counts more than 400 compromised packages. ↗(opens original source)

  8. Singapore's CSA issues a public advisory: more than 1,300 package versions, a combined 2 billion monthly downloads. ↗(opens original source)

  9. SafeDep documents the 'testmetest' packages; as of 22 October it has found no compromised third-party packages or victims (by 27 October it counts 19 operator packages). ↗(opens original source)

  10. JFrog reports 42 armed third-party GitHub repositories across 11 owners carrying AI coding-assistant and IDE execution hooks, with arming batches from 28 September.

Mitigation

Upgrade to npm 12 so dependency install scripts stay off unless a project explicitly allows them, and set a minimum release-age delay before new versions reach your builds. Put coding-agent and IDE configuration directories under mandatory code-owner review on every branch, and alert on any change to them. Require pull-request review and signed commits on all branches, but do not treat a verified signature on its own as proof that a commit is legitimate. Open unfamiliar repositories in a disposable environment with each tool's workspace-trust controls switched on, and turn hooks off for any non-interactive agent run over code you did not write. Revoke npm tokens that can publish without two-factor authentication, and tie trusted publishing to a protected environment with approvals. On any machine that ran a poisoned version, remove the persistence first, then rotate cloud, AI-tool and continuous-integration credentials from a clean host.

References

  1. Elastic Security Labs · Shai-Hulud strikes again: CHAINDROP worm hits 400+ npm packages Threat intelligence · Accessed 2026-11-09
  2. Microsoft Security · ChainDrop supply chain compromise: Anatomy of a self-propagating worm Threat intelligence · Accessed 2026-11-09
  3. SingaporeCyber Security Agency of Singapore · Ongoing npm Supply Chain Attack Affecting Keyv and Related Packages (AD-2026-009) Official & standards · Accessed 2026-11-09
  4. JFrog Security Research · Miasma Worm Returns to npm Threat intelligence · Accessed 2026-11-09
  5. SafeDep · testmetest npm Packages Carry a Miasma-Family Worm Threat intelligence · Accessed 2026-11-09
  6. GitHub Changelog · Upcoming breaking changes for npm v12 Official & standards · Accessed 2026-11-09
  7. npm Docs · npm CLI v12 changelog Official & standards · Accessed 2026-11-11
  8. Red Hat · RHSB-2026-006 Supply chain compromise of @redhat-cloud-services npm packages Vendor PSIRT · Accessed 2026-11-09
  9. SAP (SAP Global Security & Cloud Compliance) · Frequently Asked Questions: Mini Shai Hulud npm Developer Package Supply Chain Attack Vendor PSIRT · Accessed 2026-11-09
  10. CVE.org (CNA: GitHub) · CVE-2026-46421: Supply chain compromise via malicious package versions (@cap-js/sqlite, @cap-js/postgres, @cap-js/db-service) Official & standards · Accessed 2026-11-09
  11. United StatesCISA · Widespread Supply Chain Compromise Impacting npm Ecosystem Official & standards · Accessed 2026-11-09
  12. npm Docs · Trusted publishing for npm packages Official & standards · Accessed 2026-11-11
  13. GitHub Docs · Available rules for rulesets Official & standards · Accessed 2026-11-11
  14. GitHub Docs · About code owners Official & standards · Accessed 2026-11-11
  15. Visual Studio Code Docs · Integrate with External Tools via Tasks Official & standards · Accessed 2026-11-11
  16. Visual Studio Code Docs · Workspace Trust Official & standards · Accessed 2026-11-11
  17. Anthropic · Claude Code — Security Official & standards · Accessed 2026-11-11
  18. Anthropic · Claude Code — Hooks reference Official & standards · Accessed 2026-11-11
  19. Google · Gemini CLI — Trusted Folders Official & standards · Accessed 2026-11-11
  20. Anysphere · Cursor — Agent Security Official & standards · Accessed 2026-11-11

Disclosure

Written by Anthropic's Claude. This article names Claude Code, a product of Anthropic — the maker of the model that wrote it — among the AI coding tools whose configuration files these worms abuse, notes that worm commits were disguised under an AI-assistant author name, and cites Anthropic's own documentation for Claude Code's trust and hook controls. We disclose this because the subject overlaps with the tool that wrote the piece. The facts come from primary sources, listed in the references or named in the text, and the other tools named are covered on the same basis.