Lesson 8 of 14 · 13m
Hashes, Vendoring, and Not Trusting the Network
pip --require-hashes, go.sum's transparency log, and vendoring move trust from the channel to the bytes.
When the hash is the whole policy
pip install --require-hashes -r requirements.txt changes pip's contract: every artifact in the file must carry a sha256, and pip refuses to install anything whose bytes don't match. Generate the file with pip-compile --generate-hashes (pip-tools) or uv pip compile --generate-hashes and you get a pinned, hashed tree:
requests==2.32.3 --hash=sha256:70761cfe03c773ceb22aa2f671b4757976145175cdfca038c02654d061d6dcc1Now a swapped artifact on PyPI — same name, same version, different bytes — fails the install instead of silently shipping. This is the strongest client-side integrity check pip has, and it costs you one flag and a generated file.
Go solved this differently — and publicly
go.sum holds hashes of the module and its go.mod, but the real trick is sum.golang.org: since Go 1.13 (August 2019), the toolchain records every fetched module's hash in a public, append-only transparency log. Your go.sum hash isn't just checked against the bytes downloaded — it's checked against what the whole world saw when anyone first fetched that module version. An attacker can't serve you a modified github.com/x/y@v1.2.3 without the sum database noticing the discrepancy. go mod verify re-checks the local cache; GOPRIVATE marks path globs that skip both proxy and sum db (correct for genuinely private modules, wrong to abuse); GOFLAGS=-mod=vendor takes the network out of the build entirely.
This is the pattern sigstore's Rekor later generalized: don't just verify content, pin content into a witnessed public log so silent substitution is impossible.
Vendoring: delete the network from the build
The strongest version of integrity is not fetching at all:
go mod vendorwrites the module tree intovendor/;go build -mod=vendorcompiles without touching the proxy. The dependencies become your code — reviewed, committed, immune to registry disappearance and upstream rewrites.cargo vendorplus.cargo/config.tomlsource replacement does the same for crates.- For npm, committing
node_modulesis theoretically equivalent and practically miserable — the saner version is building the deployable artifact once (a Docker image, a tarball) and shipping that pinned by digest:image@sha256:....
The wrong mental model
"Signed registries make hashes redundant." Registry TLS protects the channel; a compromise of the registry, the account, or the artifact before it hit the CDN defeats the channel while the bytes flow over healthy TLS the whole way. Hashes and transparency logs verify the artifact itself — which is why they survive attacks transport security can't see.
Debian has run the vendoring endgame for thirty years: distro packages are vendored dependencies — reviewed, rebuilt, signed (InRelease/Release over Release.gpg, then per-deb checksums in Packages), and shipped over a channel your apt already trusts. The supply-chain lesson runs both ways: apt's model is exactly "don't trust the upstream network at install time," and its weak point is exactly the one xz exploited — the tarball the distro repackaged.
The flip side deserves honesty too: vendoring trades fetch-time risk for maintenance burden. Vendored code doesn't get npm audited or pip-audited automatically — you're now the distributor. For most teams the right split is hashed lockfiles everywhere, vendoring for deployable artifacts and security-critical paths.
Practice
- Python production requirements:
--generate-hashes+--require-hashes. Non-negotiable for deploy images. - Go: commit
go.sum,go mod verifyin CI, vendor when the deploy artifact allows it. - Everything else: lockfile +
npm ci/--frozen-lockfile+lockfile-lint, and pin deploy artifacts by digest —docker pull app@sha256:..., notapp:latest. A mutable tag is a git branch wearing a version's clothes.
The question hashes answer is narrow and total: are these the bytes I approved? Everything else — registry, CDN, account, channel — is someone else's problem. The residual risk is the moment of approval itself: verify the first fetch, then let the hash keep it honest forever after.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
Buying Time: Package Managers Are Adding Delay as a Security Control
Composer 2.11 shipped a cooldown that refuses to install a version until it has aged. vlt now holds npm publishes until their dependencies actually exist, because 22% of new npm versions land broken. And Ruby Central's reviewers threw out 90% of what an AI scanner flagged.
Your npm Install Just Ran Someone Else's Code: Why Dependency Security Has to Start Before CI
A pull request checkout, a poisoned GitHub Actions cache, and an OIDC token pulled straight out of runner memory. That's how 84 malicious versions of TanStack's packages hit npm in six minutes.
CVE-2025-62718: Critical Axios SSRF Vulnerability Explained
A critical SSRF flaw in Axios was used in a North Korean supply chain attack. Here's what it does and how to patch it today.
What is Supply Chain Security? Dependencies, SBOMs, and the Attack That Hit 2.6 Billion npm Downloads
Your application is only as secure as every package it depends on. In September 2025, attackers compromised 27 npm packages with 2.6 billion weekly downloads by phishing one maintainer.