Hijacked npm Packages Drove 99% of Malicious Downloads

The most dangerous malicious npm packages are not the thousands of obvious fakes. They are the small number of trusted, legitimate packages that attackers hijack. A study by Databricks Threat Research, published on 23 November, examined about 5,400 confirmed malicious npm packages published between December 2025 and October 2026, and the headline finding is stark: compromised legitimate packages made up just 7% of the set but drove more than 99% of recorded downloads.
Attacker-created packages told the opposite story. They were 89% of the dataset but accounted for only 0.2% of downloads. All ten of the most-downloaded packages in the data were hijacks. The lesson is that counting malicious packages misses the point. Exposure comes from a few trusted dependencies that millions of developers install without a second thought.
Hijacked packages did the damage
When attackers compromise an existing package, they inherit its identity, reputation, download history and place in development workflows. Developers keep installing updates without realising a trusted dependency has changed. Databricks found that 78% of compromised versions added or changed a lifecycle script, against 4% of attacker-created packages. Only 23% showed a change of maintainer or publisher, so most hijacks were pushed through the real account, with ownership untouched.
The packages themselves were mostly bare and new. Almost every malicious package came from a throwaway account: 99% came from single-maintainer accounts and 55% of accounts used a free-mail address. Typosquatting was a minority tactic. Only 13% embedded a popular package name, and under 5% sat within two character edits of one.
From stolen tokens to compromised pipelines
The study covers the first year after npm revoked long-lived authentication tokens on 9 December 2025. Rather than relying only on stolen publishing tokens, attackers increasingly targeted the environments used to build and publish legitimate software. Compromised continuous integration and delivery pipelines became the key route in, because they hold publishing credentials, cloud access tokens, source-code access and automated deployment permissions.
The August 2026 wave showed how far this goes. One dependency-confusion campaign made up 78% of confirmed versions that month, and highly exposed packages were republished through OpenID Connect trusted publishing from compromised CI environments, not with stolen tokens. Across the period, 85% of malicious packages published through trusted publishing were compromised legitimate packages, while attacker-created packages used it in only 0.1% of cases. Trusted publishing proves where a package came from. It cannot prove the pipeline that built it was clean.
Blocking install scripts is not enough
Only 54% of the malicious packages declared a lifecycle script, the install-time hook that can run commands during installation. The rest could execute when imported or invoked, so a package can stay dormant during installation and activate when an application actually uses it. Developers who rely only on install-script blocking are still exposed.
Credential theft was the main behaviour across the period. Of the stealers, 45% went after a single class of credentials and 36% after three or more. Cloud credentials, SSH keys and .env files often showed up together. Theft of npm tokens peaked at 22% of packages in March 2026 and dropped below 5% from May, after the classic tokens were revoked. AI-developer credentials were the narrowest target: 80% of packages that went after them took nothing else, though they stayed at 1 to 4% of packages all year. Some packages also targeted Model Context Protocol servers and AI assistant configuration files, a new attack surface that did not exist two years ago.
Attackers also hid behind infrastructure nobody would block. Some 38% of malicious packages communicated with legitimate third-party services, including serverless hosting, code repositories, paste sites and messaging webhooks. Cloudflare Workers served several hundred packages, with Telegram, Discord and Slack webhooks close behind.
Slow takedowns leave a long window
Reporting a package is not the same as removing it. Databricks found 87% of the set had a public security advisory, and from March 2026 onward the median advisory came before the median takedown in every month. But the registry was slower: the median time to a security takedown was about seven days, 10% of packages took more than 59 days to be removed, and 16% were still installable at the time of the analysis. Among North Korea-linked packages, npm removed 64% at a median lag of 19.5 days, and 5% remain live.
The advice is practical. Watch for new lifecycle scripts in updates to trusted packages, act on advisories rather than waiting for registry removal, enforce lockfile integrity, and use short-lived job-scoped credentials in build environments. Treat publishing provenance as evidence of origin, not proof of a clean pipeline, and monitor MCP configurations for unauthorised changes. Above all, the danger is trust, not volume: one hijacked dependency can reach environments that would never install an unfamiliar package.