Vendored Dependency

Vendored Dependency

What Is a Vendored Dependency?

A vendored dependency is third-party code copied directly into a project's own source tree or compiled into its binary, rather than resolved from a package registry at build time. The copy becomes part of the project's repository or artifact. No package manager records it as an installed component.

Developers vendor code for sound reasons: build reproducibility without network access, protection against a dependency disappearing upstream, the ability to carry a local patch, and simpler distribution of a single self-contained artifact.

The security consequence is that the component becomes invisible to tooling that identifies software by reading package databases or manifests. The code is present and can carry vulnerabilities, but nothing in the image declares that it is there.

How a Vendored Dependency Becomes Invisible

Inventory and scanning tools identify components through a small number of mechanisms, and vendoring defeats most of them.

  • Package database reading lists what the operating system package manager installed, and copied source was never installed that way.
  • Manifest parsing reads declared dependencies from files like go.mod or package.json, which a multi-stage build often leaves behind.
  • File fingerprinting matches known file hashes, which fails as soon as the copied code is modified or recompiled.
  • Binary analysis can read embedded module metadata in some ecosystems, and is the only method with a realistic chance of success.

Static linking produces the same outcome by a different route. The dependency is compiled into one executable with no separate file and no package record.

The result is an inventory that looks complete and is missing precisely the components least likely to be patched.

What Vendoring Does Not Change

Copying code into your repository changes who maintains it. It does not change whether it is vulnerable, and it does not change your obligations.

A vulnerability in a vendored copy is a vulnerability in your artifact. Upstream fixes do not reach you automatically, because there is no dependency relationship left to update. License obligations continue to apply to the copied code, and increasingly, so do inventory obligations: regulations and customer contracts asking for a software bill of materials do not exempt components because they were copied rather than resolved.

Treat each copy as code you now own, which means the following.

  • You own the patch path, and must track upstream advisories yourself.
  • You own the inventory entry, since no tool will generate it for you.
  • You own the license compliance for the copied code.
  • You own the drift, because a locally modified copy diverges further with every upstream release.

That ownership is the real cost, and it is usually paid later than it is incurred.

How to Manage Vendored Code in Production Environments

The goal is not to eliminate the practice, which is often justified, but to make it visible.

  • Record every copy explicitly, with its upstream source, version and the date it was taken.
  • Generate software bills of materials at build time, where the resolved graph is still known, rather than from the finished image.
  • Run a second inventory tool with binary analysis and treat the difference between the two outputs as a coverage gap.
  • Subscribe to upstream advisories for every copied component, since no automation will do it for you.
  • Test your coverage deliberately by building an image containing a known statically linked dependency and checking whether it is reported.

That last test is the fastest way to find out what your pipeline cannot see. Most teams are surprised by the result.

How Hardened Container Images Reduce Invisible Components

Providers that build images from source know what went into every artifact, because they resolved it rather than inferring it afterwards.

That matters for the base layer specifically. A vendor-published bill of materials, addressed by image digest, is a more reliable record of what the base contains than anything you can reconstruct from a stripped filesystem.

It does not cover your application layer, which remains yours to inventory. Echo's guidance on container scanning best practices covers how to combine vendor records with your own.

FAQs

Why do scanners miss vendored code?

Because they identify components by reading package databases, parsing dependency manifests or matching known file hashes. Copied source was never installed by a package manager, a multi-stage build often discards the manifest, and modified or recompiled code no longer matches known hashes. Binary analysis is the only approach with a realistic chance of detection.

Is vendoring a bad practice?

Not inherently. It gives reproducible offline builds, protection against upstream removal, the ability to carry a local patch, and simpler distribution. The problem is that the maintenance and inventory responsibilities transfer to you silently. Vendoring deliberately, with a documented record of each copy, is reasonable engineering. Doing it accidentally is not.

How is this different from a transitive dependency?

A transitive dependency is resolved by your package manager and therefore appears in the dependency graph, even if you never declared it. Copied code is not resolved at all, so it appears in no graph. One is a visibility problem caused by depth; the other is an identity problem caused by the component having no package record.

Does static linking create the same problem?

Effectively yes. A statically linked binary contains its dependencies with no separate files and no package records, so filesystem inspection reports a single executable. Some ecosystems embed module metadata that binary analysis can read, which is why toolchains that support it are worth preferring where you have the choice, and worth testing by name where you do not.

How do I find vendored code already in my estate?

Start by running two inventory tools with different inspection strategies on the same images and diffing the results. Then search repositories for directories conventionally used for copied dependencies, and look for third-party license files inside your own source tree. The combination finds most of it, though rarely all of it.

Ready to eliminate CVEs at the source?