Skip to content
LiveNext 10:12:39

Definition

What is Dependency pinning?

Dependency pinning is Dependency pinning is locking a software project to exact versions of the libraries it uses, so an update, accidental or malicious, cannot change what you install without your say-so.

Almost every modern software project, including most AI tools, is built from other people's libraries. Dependency pinning is the habit of telling your project exactly which version of each library to use, instead of "whatever is newest."

How it works

Without pinning, a project might say "use any version of this library from 1.2 up." Every fresh install then fetches the latest allowed version, which can differ from the one you tested last week.

With pinning, the project says "use exactly 1.2.4." Package managers usually record this in a lockfile, which lists the exact version of every dependency, and often a cryptographic hash of its contents. When you install, the tool checks that what arrives matches what was recorded.

The analogy: unpinned is "bring me a loaf of bread from the bakery." Pinned is "bring me the sourdough baked Tuesday, sealed in this bag."

Why it matters

Pinning gives you two things:

  • Repeatability. The same code installs the same way on your laptop, in testing and in production, so surprises are easier to explain.
  • Protection from surprise updates. If a library maintainer's account is hijacked and a bad version is published, an unpinned project may pull it automatically the next time it builds. A pinned project keeps using the version it already trusts until someone chooses to update.

That second point makes pinning a basic defense against a supply chain attack, where attackers tamper with a trusted package to reach everyone who installs it. Malicious releases often run credential-stealing code, such as an infostealer, during installation.

Its limits

Pinning is not a full fix.

  • If the version you pinned is itself malicious, pinning keeps you on it.
  • Pinning to a trusted publisher's name protects you only as long as that publisher's account is safe.
  • Pinned old versions miss security fixes, which widens your patch gap.

So pinning works best as a routine: pin, then update deliberately on a schedule, reading what changed first. Semantic versioning numbers help you judge how big an update is, but they are a promise from the maintainer, not a guarantee.

What to do

  • Commit your lockfile to your repository and install from it in automated builds.
  • Use hash checking where your tools support it.
  • Review dependency updates before merging them, and be wary of a new version appearing with no matching change in the project's history.
  • Keep secrets scoped narrowly in your build system, so a bad package can steal less. See secrets management.

Questions people ask

Does dependency pinning stop supply chain attacks?

It reduces the risk of silently pulling a bad new version, but it does not help if the version you pinned is itself compromised or if you update to a bad release. Pair it with checks such as hashes and review.

What is a lockfile?

A lockfile is a file generated by your package manager that records the exact version, and often a hash, of every dependency, so every install matches.

Dependency pinning in the news