Supply Chain Security
Every application is an assembly of code written by people you have never met, built on infrastructure you do not operate, delivered through channels you hope are honest. That is the supply chain problem: trust is inherited rather than verified, and an attacker who compromises one widely used library reaches thousands of organizations without touching their perimeters. The defensive shift is from asking whether your code is secure to asking whether you can prove where each artifact came from, what it contains, and that it has not changed since you last reviewed it. Inventory, verification and containment are the three levers, and all of them must work at build time.
Five places an attack enters your build
Threat modeling the pipeline makes the abstract concrete. Each vector has a different control, so a single "we scan dependencies" answer covers only one of the five.
| Vector | Example | What it targets | Primary control |
|---|---|---|---|
| Dependency confusion | Internal name shadowed by a public package | Package resolution | Scoped registries, pinned resolutions |
| Typosquatting | Lookalike package one character away | Developer typing | Allow lists, review of new dependencies |
| Compromised maintainer or token | Malicious release of a legitimate package | Release pipeline | Signing, provenance, short-lived publish tokens |
| Build system compromise | Poisoned CI runner injecting code | Artifact production | Isolated builders, hermetic builds, attestation |
| Repository or branch tampering | Force-push rewriting history | Source of truth | Protected branches, signed commits, review rules |
Notably, three of the five are about identity and provenance rather than vulnerabilities. Scanners do not help against a maintainer who publishes a legitimate-looking update that exfiltrates environment variables at install time; only verification of who built the artifact does.
The SBOM: inventory before defense
A software bill of materials is a machine-readable inventory of components, versions, licenses and relationships. Its practical value appears during an incident: when a new vulnerability breaks, the question is not whether you are affected but which services contain the component, which versions, and who owns them. Producing the SBOM at build time makes that answer a query instead of a two-day investigation across teams.
{
"bomFormat": "CycloneDX",
"specVersion": "1.6",
"serialNumber": "urn:uuid:3f7a1c92-4e11-4c65-a0c7-8f2b5d6e1a44",
"version": 1,
"metadata": {
"timestamp": "2026-03-04T09:12:55Z",
"component": { "type": "application", "name": "billing-api", "version": "2.14.3" },
"tools": [{ "vendor": "anchore", "name": "syft", "version": "0.104.0" }]
},
"components": [
{
"type": "library",
"name": "fastjson",
"group": "com.alibaba",
"version": "1.2.83",
"purl": "pkg:maven/com.alibaba/fastjson@1.2.83",
"licenses": [{ "license": { "id": "Apache-2.0" } }],
"properties": [
{ "name": "scope", "value": "runtime" },
{ "name": "introduced_by", "value": "billing-api -> order-service -> fastjson" }
]
},
{
"type": "operating-system",
"name": "debian",
"version": "12.5",
"purl": "pkg:deb/debian@12.5"
}
],
"dependencies": [
{ "ref": "pkg:generic/billing-api@2.14.3",
"dependsOn": ["pkg:maven/com.alibaba/fastjson@1.2.83"] }
]
}
Store the SBOM next to the artifact it describes and sign it, so the inventory cannot be swapped out later. Then wire the query that answers the incident question into your on-call tooling; an SBOM nobody can query is an archive, not a control.
Pinning, verifying, and scanning dependencies
Dependency hygiene is cheap and disproportionately effective. Pin exact versions with lockfiles committed to the repository, resolve only from approved registries, review any newly introduced dependency the way you would review new code â maintainer history, release cadence, download counts, and whether it does far more than its name suggests. Then scan on a schedule, because a clean build today says nothing about a disclosure published tomorrow.
#!/usr/bin/env bash
# ci-deps.sh - dependency gate for pull requests and nightly rebuilds
set -euo pipefail
echo "== 1. lockfile integrity: no floating ranges, no unexpected registry =="
grep -qE '^\s*"resolved": "https://registry.example.internal' package-lock.json \
|| { echo "FAIL: dependency resolved from a non-approved registry"; exit 1; }
npm ci --ignore-scripts # install-time scripts are a common payload
echo "== 2. known vulnerabilities, blocking on exploitable and high+ =="
npm audit --json > audit.json || true
node -e '
const a = require("./audit.json");
const bad = Object.entries(a.vulnerabilities || {})
.filter(([, v]) => ["high", "critical"].includes(v.severity))
.map(([name]) => name);
if (bad.length) { console.error("blocking:", bad.join(", ")); process.exit(1); }
'
echo "== 3. licenses: fail on copyleft in distributed artifacts =="
npx licensee --quiet --allow MIT --allow Apache-2.0 --allow BSD-3-Clause --allow ISC \
|| { echo "FAIL: disallowed license in dependency tree"; exit 1; }
echo "== 4. produce and sign the SBOM for this exact artifact =="
syft "dir:." -o cyclonedx-json > sbom.json
cosign sign-blob --yes --key env://COSIGN_KEY sbom.json -o sbom.json.sig
echo "PASS: deps verified, SBOM signed"
--ignore-scripts is the line that stops most install-time payloads. Package install hooks run with your credentials during every build, and disabling them by default â with an explicit, reviewed allow list for the two packages that genuinely need them â removes the cheapest execution path an attacker has.
Provenance: signed commits are not signed builds
A signature on a commit proves an author; it says nothing about what the build system produced. Provenance closes that gap by attesting to the process: which source revision, which builder, which parameters, which inputs produced this artifact. Verification then becomes a build-time check rather than a matter of trust.
# build-and-attest.yml - produce a verifiable artifact
name: build
on:
push:
branches: [main]
permissions:
id-token: write # short-lived identity for the builder
contents: read
attestations: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build in an isolated, pinned environment
run: |
docker build --provenance=true --sbom=true \
-t registry.example.com/app:${{ github.sha }} .
- name: Generate SLSA provenance
uses: slsa-framework/slsa-github-generator/.github/actions/generator-generic@v1.10.0
with:
subject-name: registry.example.com/app
subject-digest: sha256:${{ steps.digest.outputs.sha256 }}
- name: Sign the image and its attestation
run: |
cosign sign --yes registry.example.com/app@${{ steps.digest.outputs.digest }}
cosign attest --yes --predicate provenance.intoto.jsonl \
--type slsaprovenance registry.example.com/app@${{ steps.digest.outputs.digest }}
verify-gate:
needs: build
runs-on: ubuntu-latest
steps:
- name: Admission refuses anything unsigned
run: |
cosign verify registry.example.com/app:${{ github.sha }} \
--certificate-identity-regexp "https://github.com/org/" \
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
|| { echo "artifact failed provenance verification"; exit 1; }
Enforce verification at admission, not in a wiki page: a cluster or deployment system that refuses unsigned images makes provenance a property of the pipeline rather than a policy everyone is asked to remember.
Vendor risk without a hundred-question spreadsheet
Third-party risk is the supply chain with a contract attached. Weight the questions so the assessment measures what actually predicts incidents, and keep the review periodic rather than ceremonial.
| Criterion | Weight | Evidence to request |
|---|---|---|
| Certification and independent audit | 25% | Current SOC 2 Type II or ISO 27001 with scope and date |
| Incident and breach history | 20% | Disclosures in the last three years, with remediation summary |
| Data handling and residency | 20% | Sub-processor list, retention, encryption and key custody |
| Dependency and build hygiene | 15% | SBOM availability, signing practice, vulnerability SLAs |
| Continuity and exit | 10% | Data export format, escrow, recovery objectives |
| Financial and ownership stability | 10% | Ownership changes, funding, material contracts |
The weightings are a starting point; change them for your data classes and record why. What matters is that a vendor handling regulated data cannot score well on certifications alone while quietly listing a sub-processor in an untested region.
Dependency decisions are architecture decisions
Adding a library is a multi-year commitment, yet it is usually made in under a minute. Before a new dependency lands, ask four questions: how many maintainers can publish releases, how often does it release, what does it do at install time, and what would replacing it cost if it became abandoned. A package with a single maintainer who pushes without review, a history of surprise minor releases, and native binaries downloaded during install is a liability regardless of how popular it looks on the download chart.
Prefer the boring option when the difference is small. Standard-library functionality, a dependency your platform team already operates, or a vendor-supported client with a published security policy will all outlive the clever library that was archived last spring. Record the decision in the pull request so the next person updating it understands the constraints it was chosen under, and set a periodic review that checks whether heavily used packages are still maintained. Abandonment is not an event; it is a slow drift you can observe months before you need the package to change.
When your supplier is the breach
Detection still matters even with perfect hygiene. Watch for indicators you can actually observe: a dependency whose new version appears the same day a maintainer account changes, build logs that differ from your local reproduction, unexpected outbound connections during install, and integrity failures on artifacts that were clean yesterday. On a confirmed compromise, the sequence is freeze, identify, contain, verify: stop releases, determine which artifacts and images are affected, revoke any credentials exposed to the build, and rebuild from a known-good source before resuming. Keep the last known-good artifacts available precisely so that recovery does not depend on the compromised channel.
đĄReproducibility beats detection
Common Mistakes
Treating a signed commit as proof the shipped artifact is trustworthy
Fix: Attest build provenance and verify signature and provenance at deployment admission.
Running package install scripts by default in CI
Fix: Install with scripts disabled and allow list only the packages that demonstrably require them.
Generating an SBOM that nobody can query during an incident
Fix: Store and sign the SBOM with the artifact, and give on-call a search that returns owning teams.
Scanning dependencies only at build time
Fix: Rescan on a schedule so newly disclosed CVEs in shipped artifacts raise tickets automatically.
Assessing vendors with equal weight across every questionnaire row
Fix: Weight criteria by your data classes and demand evidence, not self-attestation, for the top rows.
Best Practices
- Pin dependencies with committed lockfiles and resolve only from approved registries
- Produce and sign an SBOM for every release, then index it by owning team
- Verify provenance at admission so unsigned or unattested artifacts cannot reach production
- Treat new dependency additions like code changes: review maintainer history and scope
- Rehearse supplier compromise recovery so the rebuild path does not depend on the affected channel
Key Takeaways
- Most supply chain attacks target identity and build integrity, which scanners cannot detect
- An SBOM converts the incident question 'are we affected' from a two-day investigation into a query
- Install scripts, floating versions and unapproved registries are the cheapest entry points into your build
- Provenance attestations bind artifact to source, builder and parameters, and must be verified at admission
- Vendor assessments should be weighted and evidence-based, with a rehearsed exit and rebuild plan