Safeguard
Supply Chain•

How do you find vulnerabilities in code copied into your repo?

Vendored and copy pasted libraries hide from lockfile scanners. How to find them, record their origin, and keep them patchable with a simple process.

Safeguard Security Team
3 min read

Code copied into your repository does not appear in your lockfile, so dependency scanners often miss it. To find it, search for vendor folders and license headers, record each copy's origin and version in a manifest, and put the manifest in your SBOM so it is checked like any other dependency.

Why copied code is invisible

Most dependency scanning starts with manifests and lockfiles. A library that was pasted in, vendored into a third_party folder, or bundled as a minified file has no entry there. The advisory exists, but nothing connects it to your code.

Teams copy code for good reasons: patching a library locally, avoiding a network fetch at build time, or working around a dead package. The problem is that the origin and version are easily forgotten.

Step 1: Find it

Look in these places:

  1. Folders named vendor, third_party, external, or lib that hold full source trees.
  2. Files with license headers naming another project.
  3. Minified or bundled files in static asset directories.
  4. Copied scripts in build tooling and container images, such as a downloaded installer.
  5. Git submodules, which point at an external repository.

Search code for well known project names and license text. Hash matching tools can also compare your files against known package contents.

Step 2: Record the origin

For each copy, write down the upstream project, the exact version or commit, the date copied, who owns it, and whether it has local changes. A short file in the same folder works. This is the minimum you need to answer "are we affected?" when an advisory appears.

Step 3: Make it visible to scanners

Add the copies to your SBOM as components with their upstream names and versions. A copied component with no entry is a gap in the inventory. Once it appears there, advisory matching can work for it.

Step 4: Decide how it gets updated

SituationApproach
Unmodified copyReplace it with a normal dependency if possible
Modified copyKeep a patch file against upstream, so updates can be re applied
Abandoned upstreamOwn it explicitly, and schedule review
Bundled binaryRebuild from source, or fetch a pinned release at build time

Local modifications are the biggest risk. Without a patch record, nobody dares to update, and the copy ages in place.

What about AI generated snippets?

Pasted code from forums or chat tools has no provenance at all. See the hidden risk of copy pasted code snippets. Treat larger pasted blocks like vendored code: record where they came from.

Try it yourself

Open the demo and look at how a dependency inventory lists components with versions. Notice what would be missing if a vendored copy were not in it.

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

Quick check

Does a lockfile scan catch vendored code?

Usually not, since the code has no lockfile entry. You need to add it to your inventory yourself.

Is vendoring always bad?

No. It can be reasonable, but only with a recorded origin and an update plan.

Safeguard's SBOM and dependency scanning can generate an inventory of the components in a repository, and the free scan at gold.safeguard.sh/scan is a quick way to see what turns up.

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.