Lesson 10 of 13 · 15m
go.sum, GOPRIVATE, and Supply-Chain Hygiene
The checksum transparency log, MVS picking lowest-not-latest, GOPRIVATE against dependency confusion, and govulncheck reachability.
go.sum is the file everyone commits and nobody reads — until a maintainer account is taken over and the difference between "the bits you audited" and "the bits you just downloaded" is the only thing between you and a backdoor. In March 2024 the xz backdoor (CVE-2024-3094) proved a trusted maintainer can ship a trojaned release through normal update channels. Go's module system can't stop a hostile maintainer; it can make tampering detectable — if you let it.
What go.sum and the checksum DB do
Every entry in go.sum is a content hash of a specific module version. The first fetch is verified against sum.golang.org, a transparency log — a Merkle tree run by Google since 2019 — where every module hash is publicly recorded, so silently rewriting history is detectable. There are no signatures: Go modules aren't signed. Authenticity comes from TLS to the proxy, the transparency log, and your pinned go.sum. That chain is the whole mechanism — GOSUMDB=off cuts it.
go mod verify re-checks your module cache against go.sum — run it when a build machine smells wrong. go mod tidy reconciles go.mod/go.sum with what the code imports; CI should fail on a dirty git diff after tidy.
Minimum version selection — the wrong mental model
Everyone trained on npm expects "the resolver picks the newest allowed version." Go does the opposite: Minimal Version Selection picks the lowest version satisfying every require. go.mod declares floors, not ceilings — you get the oldest compatible release, not the shiniest. Consequence: go get dep@latest is an explicit act; routine builds never drift. A CVE in a dependency doesn't pull a surprise minor bump onto your machine on Tuesday — it waits for you to run the command and read the diff. Deliberate beats current, in Go's opinion, and it is correct.
Private modules and dependency confusion
In February 2021, Alex Birsan's dependency-confusion research showed he could claim internal package names on public registries and get corporate builds to pull his code instead. The Go control is GOPRIVATE — a glob like *.corp.example.com that is shorthand for GONOPROXY + GONOSUMDB: matching paths bypass the public proxy and checksum log entirely and fetch over your own authenticated VCS. Public names go through proxy plus sumdb; private names never touch them. Mixing them — a private path that leaks to the public proxy — is how you end up importing a stranger's package under your own import path.
Vendoring
go mod vendor copies every dependency into vendor/ and builds switch to -mod=vendor automatically when vendor/modules.txt exists. You audit the dep once, commit it, and your build works offline and forever; the tradeoff is repo bloat and updates that diff like avalanches. For a service you build and deploy it is optional; for reproducible release artifacts it is the strongest option short of running your own proxy.
When you genuinely have two modules in one repo, go.work (Go 1.18) is the tool — not nested go.mod files you mentally merge.
govulncheck: reachability, not noise
govulncheck ./... analyzes your call graph and reports only vulnerabilities your code can actually reach — unlike a deps-versus-CVE-database scan that flags a vuln in a function you never call. Run it in CI. When it fires, the answer is go get dep@fixed plus go mod tidy — and read the diff, because a hostile-update check is exactly what the xz lesson was about.
Field notes
GOFLAGS=-mod=readonlyin CI: the go command refuses to editgo.mod, so a drifted manifest fails the build instead of silently fixing itself.GOPROXY=directfetches from origin VCS and is whatGOPRIVATEimplies for the proxy hop — useful for diagnosing "the proxy sees something I don't."go list -m -u allshows what's outdated without changing anything.
Try this
In a scratch module, go get a small dependency, run go mod tidy && go mod verify, and cat go.sum. Then corrupt one hash character and rebuild — read the checksum-mismatch refusal. That refusal is your supply chain working. Now set GOFLAGS=-mod=readonly in CI and make it structural.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
What is Go? The Language Google Built for Production Engineering
Go is a statically typed, compiled language built at Google in 2009. It compiles to a single binary with no runtime dependency, starts in milliseconds, and handles concurrency through goroutines and channels. Docker, Kubernetes, and Terraform are all written in Go. Here is why.
Go Lang 1.19: Refines Generics and Memory Model
Go 1.19, the latest version of Google’s Go (Golang) programming language, has reached production availability. The update improves recently added generics and debuts an enhanced memory model. With Go Language version 1.19, released August 2, generics development focused on addressing subtle…
One Slow Call, Three Runtimes: How PHP-FPM, Python ASGI and Node Fall Over When a Dependency Takes 200 ms
I put the same 200 ms wait behind PHP-FPM, FastAPI on uvicorn and a plain Node server, then hit each one with 50 concurrent requests. Handled correctly, the async runtimes served 205-211 req/s against FPM's 19.6. One blocking call in the wrong place took both of them down to 4.98, slower than...
Free-Threaded Python, Measured: Threads Finally Scale, and Your Unlocked Counter Finally Breaks
Python 3.14 made the no-GIL build officially supported, and 3.15 kept going. I ran the same CPU-bound job on standard and free-threaded builds of both: threads went from slower-than-serial to 1.9x faster, and a counter that never lost an update under the GIL lost 70% of them without it.