php2shell patches (CVE-2026-109618 and CVE-2026-109619) for EOL PHP are out now. With sales replies slower than usual due to high demand, the fastest route to patched packages is to buy ELS for Runtimes online (opens in new tab). Read the patch FAQ

Go straight to an AI summary of this blog post instead

  • Summarize this post with Perplexity
  • Summarize this post with Gemini

In horror movies, the scariest threats aren’t the ones kicking down the front door – they’re the ones already inside, the ghosts hiding in the walls that nobody noticed.

Modern software supply chains work the same way.When we build and ship applications today, we tend to trust our team and the libraries we deliberately install.

But beneath the surface of your package.json lies a sprawling, invisible iceberg of code.This is the world of transitive dependencies, and it’s exactly where many modern supply chain attacks begin.

The Illusion of Control: Your Direct Dependencies

 

When you run npm install, you might be adding five or ten libraries that you know and trust. These are your direct dependencies. You’ve looked at their GitHub stars, you’ve checked their maintenance frequency, and you’re confident in them.

However, each of those five libraries might rely on ten others. And those ten rely on ten more. Before you know it, a “simple” web app can easily balloon into over 1,000 packages sitting in your node_modules directory. These are your transitive dependencies, the “packages of your packages”, and they represent the vast majority of the code you actually ship to production.

If you want to check and see what direct dependencies you have installed without resorting to opening your package.json, you can run npm ls. This command will list in the terminal the direct dependencies you have installed.

Why Transitive Dependencies are the Perfect “Ghost”

 

The danger of transitive dependencies is that they are largely invisible to the average developer workflow. We rarely audit the third or fourth level of our dependency tree. Attackers know this, and they’ve shifted their tactics to exploit three specific “hauntings”.

Typo-Squatting:

Registering a package name that looks nearly identical to a popular one (e.g., lodash vs lodas_h). One small typo in a deep-level dependency, and a malicious script is now running in your build pipeline.

Let’s say you want to install express so you can build out an API or backend service. Muscle memory kicks in and when you navigate to your terminal to install `express`, instead of typing `npm install express`, you type `npm install expres`. The difference is that you missed that second “s” in the word. Chances are you won’t check your node_modules folder – you’ll simply trust the package installed correctly. This is where problems can begin.

Always be cognizant of what packages you are installing. When possible, prefer scoped packages. Scoped packages are often retrieved from private or organization-controlled registries, which adds an additional layer of trust.

Dependency Confusion

Tricking a build system into pulling a malicious “public” version of a package instead of your “private” internal version. Scoped packages help mitigate dependency confusion attacks. A scoped package looks something like this. `@scope/your-awesome-package`. 

When an organization uses both private (internal) and public (npm) registries, an attacker publishes a public package with the same name as a private one, but a higher version number. According to Spectral, “Nearly 49% of organizations are exposed to risks of a dependency confusion attack.”

The “Cursed” Update

An attacker gains access to a legitimate, small utility library that is used as a dependency by a major framework. An example of a small utility would be the `@ctrl/tinycolor` package. A recent example is the Shai-Hulid supply chain attack, where a compromised utility library was used to distribute malicious code. They push a “patch” that includes a backdoor. Suddenly, thousands of apps are “possessed” overnight without a single developer changing their own package.json.

A backdoor (originally called a trapdoor) is a hidden method of bypassing normal authentication and gaining privileged access to a system. Malwarebytes has a great article on backdoors, and this quote sums it up very well.

“A backdoor refers to any method by which authorized and unauthorized users are able to get around normal security measures and gain high level user access (aka root access) on a computer system, network, or software application.”

History of Backdoors

Backdoors, or trapdoors started in the 1960s-1970s. The original creation of the backdoor was for legitimate software developers to have access to maintenance, troubleshooting, and bypass auth during system development and fixes.

Backdoors began to evolve in the 1980s. Backdoors started to be used for malicious activity. One of the most famous incidents of the 1980s was the 1988 Morris Worm, which infected systems across the early internet. Robert Morris created the Morris Worm in 1988. The worm infected multiple systems across the internet including NASA, Harvard, and Stanford. Morris violated the Computer and Fraud Abuse Act of 1986, but even though he was convicted, he didn’t do jail time. 

The 1990s brought with it more involved government use of backdoors. The Clipper Chip was a failed attempt to listen in on communications. One phone was ever released and in 1996 the project was abandoned.

Rounding out the 2000s all the way into the 2020s, hackers are using backdoors for full blown attacks across the web. They have even started to infiltrate Cloud and IoT devices.

Impact of Backdoor Attacks

Backdoors are dangerous because they are hidden. Popular culture has long referenced backdoors – the 1983 film WarGames even features a scene explaining how hidden access mechanisms work. Sometimes they can be so deeply buried, it could take months or years to detect them.

Beyond npm audit

 

While tools like npm audit are a good first step, they often only find the ghosts that have already caused a mess. To truly secure your supply chain, we need to move from reactive to proactive habits. 

Lockfile Integrity

Treat your package-lock.json or yarn.lock as a protected document. Never ignore changes to it, and ensure your CI/CD pipeline is strictly enforcing those versions. One thing to keep in mind is to always commit your lock files. When you commit your lockfile, you are “locking” down the versions of the packages that were installed so everyone on the team is using the same exact ones.

However, integrity goes beyond just matching version numbers. The lockfile contains a resolved URL and an integrity hash (usually SHA-512). This hash is your primary defense against “Registry Poisoning.” If a registry is compromised and an attacker replaces a legitimate package with a malicious one of the same version, the hash will change. By using npm clean-install (or npm ci) in your build pipelines, the installer will fail if the hash of the downloaded package doesn’t match the lockfile. This is the equivalent of a “digital fingerprint” for your code; if the fingerprint doesn’t match, you know the ghost has tampered with the file.

Furthermore, you should be wary of “Lockfile Injection” attacks. This is where a malicious contributor submits a Pull Request that looks like a simple dependency update but includes a modified lockfile pointing to a malicious URL for a transitive dependency. Always peer-review your lockfile changes with as much scrutiny as your source code. If a PR adds 5,000 lines to a lockfile for a “minor patch,” it’s time to start asking questions.

SBOMs (Software Bill of Materials)

 

If you don’t know what’s in your “dependency galaxy,” you can’t protect it. Generating an SBOM gives you a clear inventory of every component in your software supply chain. Think of an SBOM as the “Ingredient List” on the back of a frozen pizza. If you find out later that “Red Dye #40” is toxic, you can check your pantry and immediately know which items to throw away. In software, when a new CVE (Common Vulnerabilities and Exposures) is announced for a deep transitive dependency, an SBOM allows you to search your entire ecosystem in seconds rather than manually auditing every project.

There are two primary industry standards for SBOMs: SPDX (Software Package Data Exchange) and CycloneDX. While SPDX is an ISO standard often favored for licensing and compliance, CycloneDX is a lightweight “security-first” format specifically designed for application security and supply chain analysis.

A truly mature security posture doesn’t just generate an SBOM; it uses it in conjunction with VEX (Vulnerability Exploitability eXchange). VEX is a companion document that tells you whether a vulnerability found in your SBOM is actually “reachable” or “exploitable.” This prevents “vulnerability fatigue”, the overwhelming feeling of seeing 400 “High” alerts and not knowing which one to fix first. By combining an SBOM with VEX, you can prove to your users that while a “ghost” might be in a library you use, it’s locked in a room where it can’t hurt anyone.

Minimalism

The safest code is the code you never install. Before adding a new dependency, ask: “Can I write this utility myself?” or “Does this library bring in 500 transitive dependencies just to format a date?”

The Takeaway: Stop the Haunt Before it Begins

 

The majority of supply chain attacks we see today don’t come from the front door, they come from the transitive dependencies we’ve invited in without a second thought.

As developers, we are the gatekeepers. We need to be as diligent about the code we borrow as we are about the code we write. It’s time to shine a light into the dark corners of node_modules and make sure no ghosts are hiding in the machine.

 

Summary
Tampering with the JavaScript Supply Chain
Article Name
Tampering with the JavaScript Supply Chain
Description
Undertand the world of transitive dependencies, and it’s exactly where many modern Java supply chain attacks begin.
Author
Publisher Name
TuxCare
Publisher Logo

Join 4,500+ Linux & Open Source Professionals!

2x a month. No spam.

Table of Contents
Get the open-source security answers you need

Join 4,500+ Linux & Open Source Professionals!

2x a month. No spam.