The Software Supply Chain: Lock It, Hold It, Pin It, and Know What You Shipped

By Sergey Nosov

28 November 2026

I created a new React app from Vite’s React and TypeScript template. Its package.json names nine packages: two that the app runs on and seven for development. Installing them brought down twenty-nine. Three of those are run-time dependencies: React, React DOM, and the scheduler that React DOM pulls in. The other twenty-six are development dependencies, among them the compiler, the bundler, the linter, their native binaries, and type definitions. The tools among them run on my machine and in every pipeline that builds the app, and the bundle is what they produce.

That is the software supply chain: everything you ship or build with but did not write, and the path it takes to reach you. The OWASP Top 10 for 2025 ranks Software Supply Chain Failures third, and defines them as “breakdowns or other compromises in the process of building, distributing, or updating software.” Black Duck’s 2026 Open Source Security and Risk Analysis found open source in 98 percent of the 947 commercial codebases its auditors examined.

The defense starts with four habits. Lock it: commit a lock file that records exactly what you tested. Hold it: make the pipeline install from that file and nothing else. Pin it: pin the images, actions, and tasks the pipeline pulls. Know what you shipped: keep a software bill of materials for each release. I ran the npm and .NET examples in this article on 28 November 2026, in Git Bash on Windows. npm 11.20 and npm 12.2.3, the latter through npx, used the public npm registry; the .NET SDK 11.0.100 used nuget.org.

How It Goes Wrong

event-stream, 2018. Snyk described event-stream, a popular npm package “getting roughly 2 million downloads a week,” as not actively maintained. Someone reportedly offered to help maintain it, and its author granted that person publishing rights. On 9 September 2018, the new maintainer added a dependency, flatmap-stream. npm’s analysis found that its code targeted one application, the Copay bitcoin wallet: “When a developer at Copay runs one of their release build scripts, the resulting code is modified before being bundled into the application.” The same analysis quotes Copay’s confirmation that “the malicious code was deployed on versions 5.0.2 through 5.1.0.” Snyk says a user reported the dependency on 20 November.

Log4Shell, 2021. This one needed no attacker inside the project. NVD published CVE-2021-44228 on 10 December 2021. It affected log4j-core, part of Log4j 2, a widely used Java logging library, and Apache scores it 10.0, the maximum CVSS score. Apache’s description takes one sentence: “An attacker who can control log messages or log message parameters can execute arbitrary code loaded from LDAP servers.” The first question it raised was simple: are we using it?

xz utils, 2024. Russ Cox’s timeline begins: “Over a period of over two years, an attacker using the name ‘Jia Tan’ worked as a diligent, effective contributor to the xz compression library, eventually being granted commit access and maintainership.” Versions 5.6.0 and 5.6.1 carried a backdoor. Andres Freund’s report of 29 March 2024 traced slow SSH logins on Debian unstable systems to the backdoor. A failed login took 0.807 seconds with the backdoored library and 0.299 seconds before it. By then the bad versions had reached Fedora Rawhide, the Fedora Linux 40 beta, and Debian’s unstable and testing. Red Hat said that no version of Red Hat Enterprise Linux was affected.

npm, September 2025. On 8 September 2025, a maintainer of chalk, debug, and other packages fell for a phishing email that impersonated npm support. Aikido counted eighteen packages with malicious versions; together, those packages “have more than 2 billion downloads per week.” Palo Alto Networks says the versions “were live for roughly two hours before being detected and removed.” A week later came a separate attack: a self-replicating worm called Shai-Hulud, which stole npm tokens and used them to publish infected versions of other packages its victims maintained. On 23 September, CISA warned that it “has compromised over 500 packages.” A second wave followed on 21–23 November 2025.

None of these needed a mistake in the victim’s own code. Every one arrived as a dependency. In event-stream, xz utils, and both npm attacks, a new version was bad, and it reached you only if something installed it. In Log4Shell, a version people already had turned out to be flawed. The first three habits keep any new version, good or bad, out of the build until you choose it; they cannot tell you whether the version you choose is safe. The fourth helps you find out, on the day of an announcement, whether an old one is inside.

CISA’s advice after the worm did both: find what is already inside, and keep new versions out. It said to “check for package-lock.json or yarn.lock files to identify affected packages, including those nested in dependency trees,” and to “pin npm package dependency versions to known safe releases produced prior to Sept. 16, 2025.”

What a Range Lets In

A version range lets a new version in without anyone choosing it. npm reads versions by the rules of semantic versioning: major, minor, and patch. In package.json, a caret in front of 7.5.0 accepts stable 7.x releases from 7.5.0 up, minor and patch releases alike. A tilde accepts only 7.5.x patch releases. Neither says anything about whether a release is safe. The semver package’s own command line prints which versions a range accepts:

$ npx semver -r "^7.5.0" \
    7.5.0 7.6.3 7.7.3 8.0.0
7.5.0
7.6.3
7.7.3
$ npx semver -r "~7.5.0" \
    7.5.0 7.5.4 7.6.3 8.0.0
7.5.0
7.5.4

Below 1.0, the caret is narrower: the node-semver README defines ^0.2.3 as >=0.2.3 <0.3.0-0.

Who chose the range? Usually nobody. npm’s save-prefix setting defaults to a caret, so npm install <package> records a caret range, and templates arrive with ranges already written. The Vite app above has eight carets and a tilde.

On a clean install with no lock file, npm resolves each range afresh. Its package selector, npm-pick-manifest, takes the version tagged latest when that version satisfies the range. Otherwise it prefers versions that are not deprecated and that suit your Node.js version, and among those the highest. Publishing a package moves the latest tag to the new version by default, so a clean install usually takes the newest release that the range accepts.

Aikido lists chalk 5.6.1 among the malicious versions. npm’s registry records its publication at 13:13 UTC on 8 September 2025, and the next release, 5.6.2, at 14:47 UTC. A clean install of a chalk range such as ^5.0.0, made while 5.6.1 was the newest release and still on the registry, would normally have taken it.

The Lock File Holds What You Tested

package-lock.json records every package in the tree, its exact version, where it came from, and an integrity hash of its contents. Here is the entry for semver in a small project whose package.json asks for ^7.5.0 (the URL and hash shortened):

"node_modules/semver": {
  "version": "7.5.4",
  "resolved": "https://…",
  "integrity": "sha512-1bCSESV6…",

Commit it. Then install from it with npm ci, which npm’s documentation describes as “meant to be used in automated environments such as test platforms, continuous integration, and deployment.” Here is the same project twice, with the project path trimmed from the output:

$ npm ci --silent
$ npm ls semver
lock-demo@1.0.0
`-- semver@7.5.4

$ rm -rf node_modules
$ rm package-lock.json
$ npm install --silent
$ npm ls semver
lock-demo@1.0.0
`-- semver@7.8.6

The first run installed what the lock file says. The second started the way a fresh clone does when nobody committed the lock file, and it took 7.8.6, published on 2 November 2026. Deleting only the lock file was not enough to show the change: with node_modules still in place, npm install kept 7.5.4. My machine hid the drift. A clean pipeline would not.

A plain npm install honors the lock file too, as long as it matches package.json: with the lock file present and no node_modules, it also installed 7.5.4. The difference shows when the two files disagree. I changed package.json to ask for exactly 7.5.0 while the lock file still said 7.5.4. npm ci stopped with EUSAGE, because it “can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync.” npm install, in the same state, installed 7.5.0 and rewrote the lock file.

npm’s documentation states the rule for npm ci: “It will never write to package.json or package-lock.json: installs are essentially frozen.” It also removes any existing node_modules before it starts. So in the pipeline’s install step, run npm ci, never npm install. One catch from the same page: npm ci needs any setting that shaped the lock file, such as --legacy-peer-deps. Without it, npm ci is “likely to encounter errors.” npm suggests setting it at the project level and committing the project’s .npmrc file.

A lock file freezes what you have; it does not judge it. When you do update, the new version comes in, and the lock file records it faithfully. That is why a lock-file change in a pull request deserves a review like any other code. A waiting period before you take a new release is a second defense. My article on The Pragmatic Programmer, twenty years on, covers npm’s min-release-age and why security fixes need a way around it.

Install Scripts Run Before You Look

The lock file decides which code arrives. Install scripts decide whether some of it runs during the install itself, before anyone has looked at it. Both waves of the worm worked that way: OWASP says the September worm “used a post-install script,” and Wiz says the November variant “executes only during the preinstall phase.”

npm 12.0.0, released on 8 July 2026, changed the default. Its release notes say: “Dependency lifecycle scripts are now blocked by default unless allowed by the root package’s allowScripts policy.” I tested it with a harmless local package whose postinstall script only writes a file. npm 11.20 printed a warning that the package “has install scripts not yet covered by allowScripts,” and ran the script anyway. npm 12.2.3 printed that the package “had install scripts blocked,” and the file never appeared.

If a package’s script should run, approve the package by name, then run the script. esbuild, for example, declares node install.js as its postinstall script. On npm 12:

$ npm install-scripts approve \
    esbuild
Approved esbuild:
  added esbuild@0.28.2
$ npm rebuild esbuild
rebuilt dependencies successfully

The approval lands in package.json, next to the dependencies it covers:

"allowScripts": {
  "esbuild@0.28.2": true
}

The entry names a version. npm’s documentation says these pinned entries “keep their approval narrowed to the specific version you reviewed.” An approval is trust, not a sandbox: the approved script runs with your permissions. If you are still on npm 11.20, npm install-scripts ls lists the packages whose scripts nobody has reviewed. The cheapest script to review is the one you never install, and my article on the courage to delete code makes the case for pruning dependencies you do not use.

NuGet: Lock It, Then Hold It

NuGet has lock files too, but they are off by default. Turn them on with dotnet restore --use-lock-file or, better, by setting the MSBuild property RestorePackagesWithLockFile to true in the project file, where the choice is visible in review. Microsoft’s documentation says the lock file persists “the full closure of package dependencies,” which means every package your packages pull in, not only the ones you name. Restore writes it as packages.lock.json beside the project. For a project that references Newtonsoft.Json 13.0.1, the entry reads (hash shortened):

"Newtonsoft.Json": {
  "type": "Direct",
  "requested": "[13.0.1, )",
  "resolved": "13.0.1",
  "contentHash": "ppPFpBcv…"
}

Then hold it: restore in locked mode in the pipeline, with dotnet restore --locked-mode or the RestoreLockedMode property. I changed the reference to 13.0.3 without updating the lock file. Locked-mode restore stopped with error NU1004: “The package reference Newtonsoft.Json version has changed from [13.0.1, ) to [13.0.3, ).”

Locked mode has to cover every restore, not only the first. Microsoft’s dotnet build page says restore runs “implicitly by all commands that require a restore to occur,” among them build, test, and publish. In the same mismatched state, dotnet build with -p:RestoreLockedMode=true stopped with NU1004. Without it, the build succeeded and rewrote the lock file to 13.0.3. In a pipeline, that is a successful build against a version that the committed lock file does not record. So set RestoreLockedMode for pipeline builds, or restore once in locked mode and pass --no-restore to every later command.

NuGet resolves from the other end. A plain version such as 13.0.1 is a minimum, written [13.0.1, ) in the lock file. NuGet’s lowest applicable version rule “restores the lowest possible version of a package as defined by its dependencies.” Publishing a higher version does not, by itself, change what restore picks, as it can under an npm caret.

The lock file still matters. In Microsoft’s own example, a project asks for 4.0.0, which is not on the feed, so restore picks 4.1.0. The next day, 4.0.0 is published, and “NuGet will now find the exact match and start resolving to 4.0.0.” A floating version such as 13.* does take the highest match, 13.0.4 in my run, and the lock file holds that choice until you refresh it with --force-evaluate.

Two cautions come from the same documentation. First, lock files belong to applications. Check one in when the project is “at the start of the dependency chain.” For “a library project that you do not ship or a common code project on which other projects depend, you should not check in the lock file,” because the application that uses the library resolves its own graph.

Second, the SDK can move under you. “For some project types, the .NET SDK adds implicit PackageReference items, and using a different SDK version will change the package version, leading to locked mode restore failures.” The suggested fix is a global.json file that names the SDK version, with rollForward set to disable, so every developer and every pipeline uses the same SDK.

Pin What the Pipeline Pulls

Packages are not the only thing a build fetches by name. The pipeline also pulls container images, actions, and tasks, and each of them has a name that can move and a more exact reference that you can pin instead.

Container images. Docker’s best practices say it plainly: “Image tags are mutable, meaning a publisher can update a tag to point to a new image.” A digest cannot move. Docker’s own example pins Alpine by tag and digest (digest shortened here):

FROM alpine:3.21@sha256:a856…

GitHub Actions. GitHub’s security guidance says to “pin actions to a full-length commit SHA,” and warns that “a tag can be moved or deleted if a bad actor gains access to the repository storing the action.” In March 2025, that happened to tj-actions/changed-files, which StepSecurity said was “currently used in over 23,000 repositories.” NVD’s entry for CVE-2025-30066 records that the tags v1 through v45.0.7 “were modified by a threat actor to point at commit 0e58ed8,” and that the result “allows remote attackers to discover secrets by reading actions logs.”

A reference to a full commit SHA does not follow a moved tag. It has a cost the same guidance names: for vulnerable actions, Dependabot “will not create alerts for actions pinned to SHA values.”

GitHub’s workflow lockfiles, generally available since 28 October 2026, go further. The gh actions-lock extension for the GitHub CLI writes .github/workflows/actions.lock “for actions and their transitive dependencies,” so you can “keep readable tag and branch references in your workflows while running the exact commits you locked, even if those references move.” For each workflow you onboard, GitHub runs the locked commit, and one that is no longer reachable from its recorded branch or tag “is rejected when the workflow runs.” Either way, a moved reference does not bring in new code. GitHub’s documentation names a gap: the lockfile “doesn’t pin calls to reusable workflows,” which you pin by full commit SHA instead.

Azure Pipelines. A task reference such as DotNetCoreCLI@2 names only a major version, and Microsoft’s documentation says that “Pipelines automatically update to use new minor task versions, such as 1.2 to 1.3.” To pick the minor version yourself, write the full version after the @, as in Microsoft’s example, GoTool@0.3.1. That holds only while your organization still has that version installed: “You can only use tasks and task versions that exist for your organization.”

A template kept in another repository needs the same care. Microsoft’s templates page notes: “If no ref is specified, the pipeline defaults to using refs/heads/main.” That is a branch, and it moves with every merge. Point the repository resource’s ref at a commit, or at least at a tag. Microsoft’s example does that for an Azure Repos repository (type: git), with ref set to a full 40-character SHA. As the tj-actions attack showed, a tag can move. A commit cannot.

Pinning trades automatic updates for deliberate ones, and Docker names the cost: with a pinned digest, “you’re opting out of automated security fixes, which is likely something you want to get.” So pin, then update on purpose. For images and actions, a bot such as Dependabot can propose each update as a pull request; review it like code. In a locked workflow, GitHub’s changelog says, Dependabot “also regenerates the matching lockfile entry in the same pull request.” Put whatever a bot does not cover on a schedule of your own. OWASP’s advice fits all of this: “Deliberately choose which version of a dependency you use and upgrade only when there is need.”

Know What You Shipped

The last habit answers the Log4Shell question. A software bill of materials, or SBOM, lists the components of a build with their versions in a standard, machine-readable format, usually SPDX or CycloneDX. Executive Order 14028, signed on 12 May 2021, names the use that matters on a bad day: “Those who operate software can use SBOMs to quickly and easily determine whether they are at potential risk of a newly discovered vulnerability.”

npm has the command built in. For the Vite app:

$ npm sbom --omit dev \
    --sbom-format cyclonedx \
    > sbom-prod.json

That wrote a CycloneDX 1.5 document with three components: react, react-dom, and scheduler. Without --omit dev, the list had all twenty-nine. Keep both, in separate files. The short list is what the app depends on at run time. The long one adds the development dependencies installed for the build, which matter when the bad package is a build tool.

Two cautions. If the pipeline sets NODE_ENV to production, npm leaves development dependencies out by default: in my run, the long list shrank to three components until I added --include dev. And neither list covers the SDK, the build image, or tools the pipeline downloads on its own.

.NET has the CycloneDX module for .NET, a .NET tool that “creates a valid CycloneDX bill-of-material document containing an aggregate of all project dependencies.” Its README says it runs on .NET 10.0, 9.0, and 8.0. Microsoft publishes sbom-tool, which creates “SPDX 2.2 and SPDX 3.0 compatible SBOMs for any variety of artifacts.” Generate the SBOMs in the pipeline, from the same install or restore that built the release, and keep them with the release.

An SBOM is only as complete as what the tool can see. Black Duck’s report says that its auditors identified 84 percent of the open source components they found through package-manager and manifest analysis. It warns that “organizations that depend only on dependency-manifest scanning are missing nearly one in six open source components in their codebases.” Code copied into the repository by hand does not appear in a list built from the lock file.

If you sell software to the US federal government, an agency may ask for one. On 23 January 2026, OMB memorandum M-26-05 rescinded memorandum M-22-18 and its companion, M-23-16. The memo adds: “Agencies may also choose to adopt contractual terms that require a software producer to provide a current software bill of materials (SBOM) upon request.”

On 29 July 2026, CISA, the NSA, the FBI, and international partners published the 2026 Minimum Elements for a Software Bill of Materials. It builds on the NTIA list from 2021 and adds required fields, among them a component hash, the license, the name of the SBOM tool, and the context in which the SBOM was generated. The contract, not the guidance, says what a given buyer requires.

A Checklist for Your Build

My book series Software Development Principles has a fuller entry on software supply chain security, including provenance, signing, and build isolation. The four habits here are where I would start.

Further Reading