cmd/go: go mod verify should check hashes in go.sum against GOSUMDB. #47752
Labels
FeatureRequest
Issues asking for a new feature that does not need a proposal.
GoCommand
cmd/go
modules
NeedsFix
The path to resolution is known, but the work has not been done.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What did you do?
example.com/m@v0.1.0
.GOPROXY=direct
,GOSUMDB=off
, thengo get example.com/m@v0.1.0
in another module. This downloads the version into the cache without notifyingproxy.golang.org
orsum.golang.org
and adds a sum togo.sum
.GOPROXY
andGOSUMDB
.go mod verify
, observing no security error.go clean -modcache
.go list all
or any other command that would download the modified version, observing a security error.https://github.com/jayconrod/noverify is an example repo.
github.com/jayconrod/noverify@v0.1.0
was modified,github.com/jayconrod/noverify/sum
is the dependent module.What did you expect to see?
The first
go mod verify
command should report a security error. For each module in the build list not matched byGOPRIVATE
orGONOSUMDB
(that is, each publicly available module),go mod verify
should check the hash of the downloaded module and the hash ingo.sum
against the checksum database inGOSUMDB
, assuming it is not disabled.In this scenario, that hash won't be in the checksum database, and the lookup should cause
sum.golang.org
to fetchexample.com/m@v0.1.0
from its origin and return the sum for the modified version.go mod verify
would then report a security error because that sum will not match the original sum in the dependent module'sgo.sum
.go mod verify
should also report a security error ifsum.golang.org
returns any error response (most commonly, 404 or 410) or is not available.This is important for identifying when both
go.sum
and the contents of the module cache don't match a publicly available version. People in this situation will see their builds work fine, but builds for other developers and CI builds will fail.go mod verify
only checks thatgo.sum
matches the contents of the module cache. It will only consult the checksum database if it needs to download something that's not cached.What did you see instead?
go mod verify
reports no security error in step 5.The text was updated successfully, but these errors were encountered: