Building Secure Software Pipelines from Commit to Deploy

Hayden Smith 7 min read

Push code for a Node.js service and a routine CI/CD run will pass through eight or more automated steps before the commit reaches production. In most of the pipelines we examine, package installation lands around step two or three. The first security check, where it exists, sits at step seven or eight. Attacks built around dependencies work inside that stretch, between the moment untrusted code enters the environment and the moment anything inspects it.

The cause is architectural more than organizational. What a scanner can verify depends on where its gate sits relative to the install step.

The points where dependencies arrive

Mapped out, the stages where dependencies move look like this.

Manifest resolution

A CI agent picking up a job usually begins with a manifest: package.json, pyproject.toml, go.mod, or something similar. No download has happened yet. The manifest names the required packages and version constraints; nothing has entered the workspace.

One useful early check confirms the manifest has not been edited in a way that quietly grows the dependency set. A pull request moving lodash from 4.17.20 to 4.17.21 calls for less attention than one adding fifteen new direct dependencies. Such a check costs under a second and is wasted effort only when the manifest is untouched.

The install step

npm install, pip install -r requirements.txt, go mod download: this is where outside code lands in the workspace. It is also where most supply-chain attacks deliver their payload.

Any post-install script a package defines can run the moment its files land. A malicious package does not wait for the application to start. Credential theft or a backdoor installation can complete during install, before a line of application code executes.

Build and test

Build commands (tsc, webpack, gradle build) and tests come next. Every downloaded dependency is present by then, and possibly already executed. A scanner placed after the build sees the full resolved tree, but install-time code has had its opening.

Scan placement decides what gets caught

Nothing shapes pipeline security more than the choice between scanning before and after installation.

Pre-install scanning works from the manifest and lock file. Names and version pins get checked against threat intelligence, and a suspicious result blocks the install. Contents stay unexamined; only registry metadata and history are in view.

Post-install scanning reaches the whole resolved tree. File hashes can be compared against registry manifests and package contents examined for suspicious patterns. By then, though, install scripts have run.

Teams that care tend to do both. HuntedIabs runs a manifest-level check that takes two to four seconds, followed by deeper verification of hashes and behavioral signals across the resolved tree. A hit in the first check stops the install before it begins. The stages cover different threats, so dropping one does not compensate for the other.

Lock files are a checkpoint few teams use

Not many teams treat lock files as controls. Commit the lock file, enforce it with npm ci or pip install --require-hashes, and CI installs exactly those packages at exactly those versions. No range resolution at install time, no "latest compatible" surprise.

That matters because a range such as ^4.17.0 resolves to whatever is newest. Publish a malicious 4.17.21 and every project using the range without a pinned lock file picks it up automatically.

The check teams skip is comparing lock file changes to manifest changes in the same commit. One edited line in package.json paired with twenty rewritten entries in package-lock.json deserves a look. Our CI integration surfaces it because the pattern reliably means something happened during resolution that nobody intended.

Clean is not the same as verified

People conflate a clean CVE result with a verified clean supply chain. The two assert different things.

A CVE scan matches installed packages against a known-vulnerability database. Worth doing, yet two whole threat classes fall outside it. Novel attacks appear in no database: too new, too targeted, or built to slip past signatures. Post-publish tampering changes a legitimate package after registry publication and before download.

CVE scanning is not redundant. It answers a different question from supply-chain integrity verification, and coverage built only on it leaves an opening that targeted attacks use over time.

The pipeline config is attack surface too

A third layer sits outside what dependency scanners usually watch: the pipeline configuration.

Workflows and job definitions are code. A GitHub Actions step written as uses: some-org/some-action@main rather than pinned to a commit SHA trusts that the action's main branch never turns hostile. Nothing structural supports that trust.

We have seen security teams with strong dependency scanning run third-party Actions holding write permission to their repositories, unpinned. The scanner's perimeter did not include the pipeline config. The article on hardening GitHub Actions against supply chain threats covers that layer in detail.

Limits no pipeline control can fix

CI-level controls have a ceiling worth stating plainly.

A scan at merge time verifies the dependency state at that moment. Tampering that happens to an installed package in production later goes unseen, as do threats that enter through direct access to a production host rather than the deployment pipeline. Runtime integrity verification addresses a separate threat model and belongs to its own layer.

Pipeline and runtime security work together. The pipeline makes the right starting point because most threats stop there. Fixing gate placement, with at least a manifest-level check ahead of the install step, is the highest-leverage change most teams can make in half a day.

Back to Security Insights