-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x/vuln/cmd/govulncheck: unexpected trace with uncalled methods for GO-2024-3106 #69446
Comments
This confusing report is due to a false edge in the call graph constructed by vulncheck. In essence, it is unable to deduce that each call to once.Do calls exactly the function f provided to it; instead, it acts as if each call to once.Do calls all functions f provided to any call to once.Do, including this one: The technical term for this limitation is that the call graph lacks "context sensitivity". -- Aside: why is the list of source locations in the trace formatted so strangely? It is quite hard to tell that some of these paths (src/sync/once.go) are in the standard library whereas others (e.g. internal/cert/default_cert.go) are in arbitrary modules:
|
This is a known limitation of govulncheck. https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck#hdr-Limitations
As @adonovan mentioned this specific case is related to "context sensitivity". |
@adonovan @timothy-king Thanks for your response.
Yes, I read the document before, but I didn't understand how it actually produces false positives. From this statement alone, I could not tell whether mine was the case introduced due to conservative analysis.
This explanation helps me understand my case. So, it looks like a false positive in this case. I will be careful with the |
...
It is hard to prescribe a general recipe for places to look in search of potential imprecision or false positives. That being said, functions that are used at several places and that accept other functions or interface values (as inputs or free variables) are a good candidate. |
We could in principle show full paths, but we initially decided to show just the paths relative to module root/GOROOT/GOMODCACHE to avoid potential clutter (admittedly, this also simplifies implementation and tests). The symbols have package information, which should help users. We wanted to see how users would react to it before expanding them to full paths. |
The general rule is: each func-typed variable in the program (e.g. the parameter f of sync.Once.Do) has a single abstraction of the set of specific function values that it can hold, independent of calling context. All values that can flow to that variable will appear to be mingled together, even if in any given call to once.Do the parameter f always refers to exactly one function.
I think it is quite confusing, as the same initial directory segments will likely appear across a variety of modules (cmd, pkg, src, internal). You could at least show the last segment of the module name, for example:
|
Created #69490. |
Thanks for explaining! It will help me review the results next time. Also, if this information is documented somewhere, it may help someone facing suspect results, as I do. Anyway, I'll close this issue. Thanks. |
I agree that we should add more documentation. I've opened an issue to track this: #69519 |
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:What did you do?
Run govulncheck on the root directory of this repository with this commit
What did you see happen?
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:
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 toDefaultSource
.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.
The text was updated successfully, but these errors were encountered: