Skip to content
VITI Security

Software Supply Chain Security: Defending Against Malicious npm Packages, Crates and Third-Party Scripts

by VITI Security TeamAug 22, 2026

Malicious packages on npm and other registries, hijacked maintainer accounts and compromised third-party scripts are now routine. How they reach your servers and customers, and the practical controls for developers, servers and websites.

Beyond npm install: Guarding Your Linux Servers from Supply Chain Backdoors - VITI Security

Every npm install trusts thousands of strangers. Most of them are trustworthy, but attackers now publish malicious packages every day, take over maintainer accounts to push poisoned versions of popular ones, and in 2025 even released a self-spreading npm worm that stole publishing tokens and used them to infect more packages. The same pattern appears in Rust crates, Python packages and the third-party scripts on your website. A malicious package that runs on a build server or a production Linux host can drop a backdoor that lasts long after the package is removed. This guide covers how these attacks work and the controls that stop them.

How malicious packages get in

There are a handful of routes, and each needs a different control.

  • Typosquatting: a package with a name close to a popular one, waiting for a typing mistake.
  • Account takeover: an attacker phishes a maintainer or steals their token and publishes a poisoned version of a trusted package. Popular npm packages were compromised this way in 2025.
  • Expired maintainer domains: if a maintainer's email domain lapses, an attacker can register it, reset the account password and publish.
  • Install scripts: npm packages can run code at install time, before anyone has used them.
  • Dependency confusion: a public package with the same name as one of your private ones gets installed instead.
  • Compromised upstream projects: a long-term contributor slips a backdoor into a core library, as with the xz utils backdoor found in 2024.

Controls for developers and CI pipelines

Most of these settings take minutes and close the largest gaps.

  • Commit lockfiles and install with npm ci or the pnpm and yarn equivalents, so builds use the exact versions you reviewed.
  • Disable install scripts by default and allow them only for packages that need them.
  • Wait a few days before adopting a new release. pnpm and some other tools can enforce a minimum release age, which avoids most poisoned versions, since they are usually caught within days.
  • Run software composition analysis in CI to flag known vulnerable and known malicious packages.
  • Use scoped registries or a private proxy for internal package names, to prevent dependency confusion.
  • Protect your own publishing: MFA on registry accounts, short-lived tokens or trusted publishing from CI, and no long-lived tokens on developer laptops.

Protect the servers that run the code

Assume one bad package will get through and make sure it cannot do much. Build in isolated, short-lived CI runners that hold only the secrets that job needs. Run applications as non-root users in containers with read-only file systems where possible. Restrict outbound network access from build and production hosts, because a backdoor that cannot reach its command server is far less useful. Watch for the signs of a dropped implant on Linux: new systemd services or cron entries, unexpected binaries in temporary directories, and long-running processes started by node or a package manager.

Third-party scripts on your website

The browser has its own supply chain. Analytics tags, chat widgets and payment scripts load from other companies' servers, and if one is compromised, every visitor runs the attacker's code. In 2024 a widely used polyfill service changed hands and began serving malicious code to the sites that loaded it.

Keep an inventory of every script your site loads and remove what you do not use. Host critical scripts yourself where licences allow, use Subresource Integrity for scripts that do not change, and set a Content Security Policy that lists the domains allowed to run code. For card payments, PCI DSS 4.0 now requires an inventory and authorisation of payment page scripts and a way to detect unauthorised changes. Ecommerce stores should apply the same scrutiny to third-party apps and plugins, which often get wide access to orders and customer data.

When a package you use is reported malicious

Act on the assumption that it ran. Find every project, build and server that installed the affected version, using lockfiles and build logs. Rotate every secret that was available to those builds and hosts, including cloud keys, registry tokens and SSH keys. Rebuild affected servers from a clean image rather than trying to clean them, and check your own published packages if your tokens were exposed.

Getting an outside check

Supply chain risk is easy to underestimate because nothing looks wrong until it is. A penetration test of your build pipeline and web application shows what an attacker could reach from one poisoned dependency, and our attack surface management service tracks the scripts and services your public sites depend on. If a compromise has already happened, our incident response team can help scope it and clean up.

Frequently asked questions

What is an npm supply chain attack?

Malicious code slipped into packages you install - via look-alike packages, hijacked maintainer accounts or poisoned updates. It runs on developer machines, build servers or in production.

How do we protect ourselves?

Use lockfiles and npm ci, turn off install scripts by default, wait a few days before adopting brand-new versions, scan dependencies in CI, and limit the secrets and network access builds get.

Is Subresource Integrity enough for third-party scripts?

It works for scripts that never change, but many third-party scripts update often, which breaks the hash. Add a Content Security Policy, an inventory of scripts and monitoring for changes.

We installed a malicious package. Now what?

Assume it ran. Find everywhere it was installed, rotate every secret those systems could reach, rebuild affected machines from clean images, and check any packages you publish yourselves.

Find out what one bad package could reach

We test build pipelines, servers and web applications for supply chain exposure and show you which secrets and systems a poisoned dependency could reach.