December 5, 2026

What are transitive dependencies and how do you secure them?

Blog
News
What are transitive dependencies and how do you secure them?

A transitive dependency is a package your project depends on indirectly, because one of your direct dependencies needs it. When you add one library, you inherit every package it uses (and every package those packages use). Research on the npm ecosystem found that installing an average npm package implicitly trusts 79 other packages, most of which you didn't choose or review.

Inherited code creates security problems that are harder to fix than flaws in packages you chose. Attackers can use only some transitive flaws, and you can work out which ones before you spend time on the rest.

What is a transitive dependency?

A direct dependency is a package you add yourself. A transitive dependency is anything that package needs to work. If you install axios, npm also pulls in follow-redirects and form-data, along with everything form-data depends on. Your package.json doesn't list any of them, and the tree keeps branching until every package is resolved.

Run npm ls --all on a mid-sized Node service and the output runs to hundreds of lines, with packages four or five levels below anything you installed on purpose. Going by the npm research above, a project with 15 direct dependencies can pull in hundreds of packages, even after npm dedupes the ones they share.

Why are transitive dependencies a security risk?

A flaw or a compromise several layers down still ends up in your build. The code runs with the same permissions as everything else in your application, and your team didn't review it or, in most cases, know it existed. OWASP folded vulnerable and outdated components into a broader software supply chain failures category in its 2025 Top 10, where it now ranks third.

When debug, chalk and 16 other packages were compromised with malware in September 2025, most affected teams hadn't installed any of them directly. The packages came as transitive dependencies of libraries those teams did install, so the malicious code reached environments whose owners didn't know debug or chalk were in their tree.

A 2026 study of over a million npm packages found known vulnerabilities spreading the same way, with 21.6% of packages having at least one somewhere in their dependency network. Of the vulnerabilities involved, 42% are rated high severity. The vulnerable package usually shows up deep in the tree, several hops from any manifest file.

Why are transitive dependency vulnerabilities hard to fix?

You usually can't update the vulnerable package yourself, because you don't depend on it directly. The library in between pins the version. So you wait for that maintainer to ship a release that bumps it, or you force the version yourself with an overrides entry in npm or a resolutions entry in Yarn, and then test that the forced version doesn't break the library that wanted the old one. When something is under active exploitation you need to move fast, and as PHP2Shell showed in October, you can't always wait on an upstream release.

Volume compounds the problem, since one repository can surface dozens of transitive findings in a single week and a team can't chase all of them to resolution. The 2026 study also found that slow adoption downstream is a primary reason packages stay exposed, with many dependents running outdated versions long after a fix ships.

I hit both problems at once on a Node project last year. An advisory came out for a parsing library four levels down the tree, pulled in by a telemetry SDK. The SDK pinned the vulnerable version exactly, and the maintainer's fix was weeks out. I forced the patched version with an override, which broke the SDK because an internal API had changed between the two releases. I ended up dropping the override and pinning an older SDK release that accepted the patched range, then moved back to the latest SDK once the maintainer shipped the fix. The whole detour took two days, for a package I hadn't heard of before the alert.

How do you find the transitive dependencies in your project?

In npm, npm ls --all prints the full tree, and npm ls <package> shows every path that pulls a specific package in. If you're on npm 7 or later, npm explain <package> tells you why a package is there. Take qs, the query string parser behind CVE-2022-24999, a prototype pollution flaw in versions that older Express releases pin.

npm ls qs
└─┬ express@4.17.1
  ├─┬ body-parser@1.19.0
  │ └── qs@6.7.0
  └── qs@6.7.0 (deduped)

Reading it bottom up tells you the fix lives with express, the direct dependency at the top of the chain, even though the finding names qs. Two separate paths pull the vulnerable version in, and both trace back to the same upgrade.

Other ecosystems have their own versions of this command, including mvn dependency:tree for Maven, go mod graph for Go, pipdeptree for Python and cargo tree for Rust. Your lockfile holds the same information in exhaustive form, so give lockfile diffs on dependency updates the same review you'd give a code change. Aikido's guide to software supply chain security best practices covers the wider set of controls around pinning and reviewing those files.

How do you prioritize transitive vulnerabilities?

Two checks tell you whether a vulnerable package in your tree leaves you exploitable, and their results set your priority.

Check whether the vulnerable code is reachable. A CVE affects a specific function or code path, and your application may not call it. A prototype pollution flaw in a utility your build tool uses at compile time doesn't see production traffic.

Check whether it's exploitable in your context. Reachable code still needs attacker-controlled input to be a real problem. A deserialization flaw that only ever receives config files from your own repository is a different situation from one parsing request bodies.

Set priority from both results. Findings that are both reachable and exploitable get fixed now. Everything else can ride along with your normal upgrade cycle, which is most of the list.

Reachability analysis automates the first check. It traces the call paths from your code through the dependency tree to see whether the vulnerable function can ever execute. A version match against a CVE database only tells you the package is present.

How to secure transitive dependencies in Aikido

Aikido Security runs those steps for you. To show the workflow, I connected a demo repository with a small Express app, pinned to express@4.17.1 so it pulls in the vulnerable qs version from the tree above, and let Aikido's dependency analysis run.

1. Find the vulnerable package and the path that pulls it in. The reachability view maps both chains from app.js into qs@6.7.0, one through body-parser and one through Express's own query parser, down to the file and line where each hop happens.

2. See whether it's reachable and exploitable. An agent then reads how the repository uses the package and writes up its verdict. Here it concluded the flaw is exploitable through the Express query parser on the /search endpoint, while the app doesn't use the body-parser path.

3. Triage what's left. The feed surfaces the three findings to look at, with a fix-time estimate for each, and shows the nine it auto-ignored in the past week so you can check its reasoning.

4. Fix it. AutoFix proposes bumping express from 4.17.1 to 4.17.3, the version that resolves the qs finding, and updates the lockfile. Before you let it open the pull request, it explains why the change doesn't break anything in this codebase.

Fix the transitive findings an attacker could actually use and let the rest follow your upgrade cycle. Sorting them first leaves a short list of findings that need work now.

FAQs

What is the difference between a direct and a transitive dependency?

A direct dependency is a package you add to your project yourself, listed in your manifest file. A transitive dependency is pulled in automatically because a direct dependency, or another transitive one, requires it. Your application runs both kinds of code with equal trust.

How do I find transitive dependencies in npm?

Run npm ls --all to print the full dependency tree, or npm ls <package> to see every path that brings in a specific package. On npm 7 and later, npm explain <package> shows why a package is present. Your package-lock.json lists every resolved package and version.

Are vulnerabilities in transitive dependencies exploitable?

Some are, but most aren't in practice. Exploitability depends on whether your application can reach the vulnerable code path and whether an attacker can get input to it. Reachability analysis checks this automatically and filters out findings your code can't reach.

How do I fix a vulnerability in a transitive dependency?

Update the direct dependency that pulls it in, if a fixed version exists. If the fix hasn't reached that dependency yet, force the patched version with npm overrides or Yarn resolutions and test for breakage. Tools like Aikido Security's AutoFix can open the pull request for you with the right change.

Last updated: December 5, 2026
4.7/5
Tired of false positives?

Try Aikido like 100k others.
Start Now
Get a personalized walkthrough

Trusted by 100k+ teams

Book Now
Scan your app for IDORs and real attack paths

Trusted by 100k+ teams

Start Scanning
See how AI pentests your app

Trusted by 100k+ teams

Start Testing
Authors
Keshav Malik
Security Engineer at LinkedIn
Subscribe for news
Share:

Recently Added

December 3, 2026

NSA and Cloudflare's CEO urge post-quantum migration, and what we know

The NSA and Cloudflare's CEO urge a move to post-quantum cryptography. Here's what's confirmed, what isn't, and three steps to take this week.
November 27, 2026

What we learned from benchmarking ARTEX internally

ARTEX is an open-source AI pentesting tool, and some security teams are tempted to run it on their own networks. We tested it against our external network pentest to see how it holds up.
November 25, 2026

Response readiness starts before the next 2shell appears

Attackers now exploit new CVEs within hours. Learn how connecting your cloud, containers and domains ahead of time lets you find affected assets in minutes.