Skip to content

x/vuln/cmd/govulncheck: unexpected trace with uncalled methods for GO-2024-3106 #69446

Closed
@knqyf263

Description

@knqyf263

govulncheck version

Go: go1.23.0
Scanner: [email protected]
DB: https://vuln.go.dev
DB updated: 2024-09-06 20:44:22 +0000 UTC

No vulnerabilities found.

Does this issue reproduce at the latest version of golang.org/x/vuln?

It reproduces at v1.1.3, which is the latest as of today.

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/teppei/Library/Caches/go-build'
GOENV='/Users/teppei/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/teppei/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/teppei'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.23.0/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.23.0/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.23.0'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/teppei/Library/Application Support/go/telemetry'
GCCGO='gccgo'
GOARM64='v8.0'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/Users/teppei/src/github.com/aquasecurity/trivy/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/9_/3y18vrrs5bz6gbkq0kc_4fv80000gn/T/go-build1122797270=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

Run govulncheck on the root directory of this repository with this commit

$ git rev-parse HEAD
04a854c3373952cc555bb4c2877d7cb0c4eb8335

What did you see happen?

$ govulncheck -show trace ./...

=== Symbol Results ===

Vulnerability #1: GO-2024-3106
    Stack exhaustion in Decoder.Decode in encoding/gob
  More info: https://pkg.go.dev/vuln/GO-2024-3106
  Standard library
    Found in: encoding/[email protected]
    Fixed in: encoding/[email protected]
    Example traces found:
      #1: for function encoding/gob.Decoder.Decode
        pkg/fanal/secret/scanner.go:430:19: github.com/aquasecurity/trivy/pkg/fanal/secret.Scanner.Scan
        src/sync/once.go:67:11: sync.Once.Do
        src/sync/once.go:76:4: sync.Once.doSlow
        internal/cert/default_cert.go:49:76: google.golang.org/api/internal/cert.DefaultSource
        internal/cert/enterprise_cert.go:36:25: google.golang.org/api/internal/cert.NewEnterpriseCertificateProxySource
        client/client.go:182:26: github.com/googleapis/enterprise-certificate-proxy/client.Cred
        src/net/rpc/client.go:196:27: net/rpc.NewClient
        src/net/rpc/client.go:206:2: net/rpc.NewClientWithCodec
        src/net/rpc/client.go:109:40: net/rpc.Client.input
        src/net/rpc/client.go:228:21: net/rpc.gobClientCodec.ReadResponseHeader
        src/encoding/gob/decoder.go:193:21: encoding/gob.Decoder.Decode

Your code is affected by 1 vulnerability from the Go standard library.
This scan also found 2 vulnerabilities in packages you import and 1
vulnerability in modules you require, but your code doesn't appear to call these
vulnerabilities.
Use '-show verbose' for more details.

I've encountered an unexpected detection by govulncheck in our project. The tool reports a vulnerability (GO-2024-3106) in encoding/gob, but the reported trace doesn't align with our source code.

This is the relevant source code.
https://github.com/aquasecurity/trivy/blob/04a854c3373952cc555bb4c2877d7cb0c4eb8335/pkg/fanal/secret/scanner.go#L430-L433

Upon closer inspection, the actual code at this location is simply using sync.Once to copy a byte array:

copyCensored.Do(func() {
	censored = make([]byte, len(args.Content))
	copy(censored, args.Content)
})

This code doesn't appear to be directly calling google.golang.org/api/internal/cert.DefaultSource as reported in the trace. To verify this, I used debugger (delve) to step through the code line by line, but I couldn't confirm any call to DefaultSource.
Given this discrepancy, I'm puzzled about why govulncheck is detecting this vulnerability in our code. I'm wondering if I'm missing something or if this could be a false positive.

I'd greatly appreciate any insights into why this detection is occurring and how I might resolve or mitigate it.

What did you expect to see?

I expected govulncheck to either not report any vulnerabilities or to accurately pinpoint the uses of vulnerable functions. The current output, which seems to detect the vulnerability in code that doesn't appear to be present or in use, has left us uncertain about how to proceed with addressing this reported issue.

Metadata

Metadata

Assignees

Labels

FeatureRequestIssues asking for a new feature that does not need a proposal.NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.UnfortunateWaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.vulncheck or vulndbIssues for the x/vuln or x/vulndb repo

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions