What govulncheck checks that a version scanner does not#
Most dependency scanners compare a module version with an advisory's affected range and stop there. govulncheck goes one step further. Its command documentation at v1.10.0 says it "uses static analysis of source code or a binary's symbol table to narrow down reports to only those that could affect the application." It can do that because Go advisories name the functions that hold the defect.
The report used here is GO-2022-1059 (CVE-2022-32149), a denial of service in golang.org/x/text. Its OSV record in golang/vulndb gives the version range and the symbols:
"ranges": [{ "type": "SEMVER", "events": [{ "introduced": "0" }, { "fixed": "0.3.8" }] }],
"ecosystem_specific": {
"imports": [{
"path": "golang.org/x/text/language",
"symbols": ["MatchStrings", "ParseAcceptLanguage"]
}]
}
Every program that requires golang.org/x/text below v0.3.8 is in the range. Only a program that reaches language.ParseAcceptLanguage or language.MatchStrings runs the slow parser that the details field describes: "An attacker may cause a denial of service by crafting an Accept-Language header which ParseAcceptLanguage will take significant time to parse."
Two programs, one module version, two results#
The default database at vuln.go.dev was not reachable from the machine used for this guide, so the scan ran against a local copy. The database specification allows that: the API has no query parameters, so "even a site serving from a fixed file system (including a file:// URL) can implement this API." The local database holds index/db.json, index/modules.json, index/vulns.json and ID/GO-2022-1059.json, with the OSV file copied unchanged from golang/vulndb.
Both constructed programs require golang.org/x/text v0.3.7. The first imports golang.org/x/text/language and calls only language.Make. The second reads the request header in an HTTP handler:
func preferred(r *http.Request) string {
tags, _, err := language.ParseAcceptLanguage(r.Header.Get("Accept-Language"))
if err != nil || len(tags) == 0 {
return "en"
}
return tags[0].String()
}
With govulncheck v1.10.0 and Go 1.24.7, the first program gets no symbol result and exits 0:
$ govulncheck -db file:///.../vulndb -show verbose ./...
...
=== Symbol Results ===
No vulnerabilities found.
=== Package Results ===
Vulnerability #1: GO-2022-1059
Denial of service via crafted Accept-Language header in
golang.org/x/text/language
More info: https://pkg.go.dev/vuln/GO-2022-1059
Module: golang.org/x/text
Found in: golang.org/x/text@v0.3.7
Fixed in: golang.org/x/text@v0.3.8
=== Module Results ===
No other vulnerabilities found.
Your code is affected by 0 vulnerabilities.
This scan also found 1 vulnerability in packages you import and 0
vulnerabilities in modules you require, but your code doesn't appear to call
these vulnerabilities.
The second program gets a symbol result with a trace and exits 3:
$ govulncheck -db file:///.../vulndb -show traces ./...
=== Symbol Results ===
Vulnerability #1: GO-2022-1059
...
Example traces found:
#1: for function golang.org/x/text/language.ParseAcceptLanguage
main @ example.com/calls/main.go:22:21
ListenAndServe @ stdlib/src/net/http/server.go:3665:30
...
HandlerFunc.ServeHTTP @ stdlib/src/net/http/server.go:2294:3
main @ example.com/calls/main.go:20:28
preferred @ example.com/calls/main.go:11:46
ParseAcceptLanguage @ golang.org/x/text/language/parse.go:158:6
Your code is affected by 1 vulnerability from 1 module.
The trace answers the question the advisory leaves open. It runs from ListenAndServe through the handler to the parser, so the input is a request header that any client controls. That matches the attack in the advisory's details, and the decision is to upgrade. After go get golang.org/x/text@v0.3.8, the same scan prints No vulnerabilities found. and exits 0.
For the first program the same upgrade is still the right change, but it can ride along with the next dependency update. The Go project's own govulncheck tutorial reaches the same conclusion for this advisory: "GO-2022-1059 likely does not affect our code, because our code does not call any vulnerable functions from that report."
The scan only sees the build you asked for#
The documentation states the limit: "Govulncheck looks for vulnerabilities in Go programs using a specific build configuration." For source scans that configuration is the go command on the PATH plus the -tags you pass. A file excluded by a build constraint is not in the call graph.
This constructed variant puts the call in a file that only the production build compiles:
//go:build prod
package main
import "golang.org/x/text/language"
func init() {
pick = func(header string) string {
tags, _, err := language.ParseAcceptLanguage(header)
...
}
}
The default scan reports what the first program got, and a reviewer reading it would dismiss the finding. Scanning with the tag the release uses flips it:
$ govulncheck -db file:///.../vulndb ./...
Your code is affected by 0 vulnerabilities.
This scan also found 1 vulnerability in packages you import and 0
vulnerabilities in modules you require, but your code doesn't appear to call
these vulnerabilities.
$ govulncheck -db file:///.../vulndb -tags prod ./...
Example traces found:
#1: accept_prod.go:9:47: tagged.init#1 calls language.ParseAcceptLanguage
Your code is affected by 1 vulnerability from 1 module.
Scanning the shipped binary gives the same split without needing to know the tags. go build and go build -tags prod produced two binaries; govulncheck -mode binary found nothing callable in the first and reported Vulnerable symbols found: #1: language.ParseAcceptLanguage in the second. Binary mode has its own trade: the documentation says its output "omits call stacks, which require source code analysis", and that it "may also report false positives for code that is in the binary but unreachable."
Two other gaps can hide a real call. The documentation lists them under limitations: "Calls to functions made using package reflect are not visible to static analysis," and "use of the unsafe package may result in false negatives." Test files are skipped unless you pass -test. If a dismissal rests on "not called," record the exact command, tags and Go version that produced it, and prefer a scan of the artifact you deploy.
Decide from the result section and the build#
| What govulncheck says | Evidence to collect | Decision |
|---|---|---|
| Symbol Results with a trace from an entry point that takes outside input | The trace and the input it carries | Upgrade to the "Fixed in" version now |
| Symbol Results with a trace from tooling or startup code only | Who controls the input on that path | Upgrade on the normal schedule unless the input is untrusted |
| Package or Module Results only, default tags | A rerun with the release's -tags, GOOS and GOARCH, or -mode binary on the shipped artifact | Dismiss as not called only if the shipped build also has no symbol result; upgrade with the next update |
Not called, but the package uses reflect or plugin-style dispatch into the module | A search for the symbol name and any dynamic dispatch into that package | Treat as called until shown otherwise |
| Binary mode reports a symbol | A source scan of the same commit and tags for the trace | Upgrade; use the trace to judge urgency |
When the finding is about the standard library rather than a module, the fix is a toolchain rebuild, which the guide on standard library vulnerabilities in a Go binary covers. When an automated dependency update proposes the upgrade, the dependency bot review guide covers what to check before merging it.