Safeguard
Security Guides•

How do I find which package pulls in a vulnerable dependency?

Trace the path to the vulnerable package with npm explain, cargo tree with invert, or dotnet nuget why, then upgrade the closest direct parent first.

Safeguard Security Team
3 min read

Ask your package manager for the reverse path. In npm use npm explain or npm ls with the package name, in Cargo use cargo tree with the invert option, and in .NET use dotnet nuget why. Each shows which direct dependency brings in the vulnerable package, which tells you what to upgrade.

Definitions

Reverse dependency. A package that depends on a given package.

Dependency path. The chain from your project to the vulnerable package.

Closest parent. The direct dependency at the top of that chain.

Commands

EcosystemCommandResult
npmnpm explain nameA bottoms up view of why a package is in the tree
npmnpm ls namePaths leading to that package
Cargocargo tree -i namePackages that depend on the named one
.NETdotnet nuget why project nameWhy a transitive package is in the graph
Mavendependency:tree with the includes filterOnly matching artifacts and their parents
npm explain lodash
cargo tree -i syn
mvn dependency:tree -Dincludes=org.apache.*:*

In a Cargo workspace, the invert option shows reverse dependencies within the current member crate unless you add the workspace option.

Steps

  1. Note the vulnerable package, its current version and the fixed version.
  2. Run the reverse path command for your ecosystem.
  3. Identify the direct dependency at the top of each path. There may be several.
  4. Check whether that parent has a newer version that depends on the fixed package.
  5. If it does, upgrade the parent and re-scan.
  6. If it does not, try the next parent along the path.
  7. As a last step, add the fixed version as a direct requirement or override, and write down why.

Microsoft's guidance for .NET follows this order: upgrade the package closest to your direct reference first, and then, as a later step, pin the transitive package. It also warns that a direct pin should be removed once a parent update makes it unnecessary.

Options when no parent update exists

OptionUpsideDownside
Pin or override the fixed versionFast fixCan break the parent, needs testing
Ask the parent project for an updateFixes it for everyoneSlow
Replace the parentClean resultMigration work
Accept the risk with a reasonNo change riskNeeds review dates

Try it yourself

Click through it at your own pace, or open it full screen.

Pick a finding and see which upgrade clears it.

Quick check

What if two parents pull in the same vulnerable package?

Fix both paths, or add one override that covers the build. Re-scan to confirm.

Is an override safe?

It can be, but run your tests. The parent was built against a different version.

Safeguard shows the dependency path for each finding and can open fix pull requests when you turn autonomous remediation on, which is off by default. Try a free scan.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.