Skip to content

Go call analysis marks called vulnerabilities as uncalled when an uncalled finding comes last (last-wins aggregation) #3162

Open

Description

@Subhan1794

Note: this issue is re-filed from the correct account (Subhan1794). It supersedes #3161, which was filed from an older account (VIRUSBABAA) and will be closed.

Summary

matchAnalysisWithPackageVulns aggregates govulncheck findings per (vulnerability, module) with a plain map assignment, so the last finding wins instead of OR-ing. govulncheck emits one finding per vulnerable symbol, and multi-symbol advisories routinely mix called findings (trace frame with a function name) and uncalled findings (single frame, empty function). If the uncalled finding comes last, a vulnerability whose code IS executed is marked Called=false.

Location: internal/sourceanalysis/go.go, in matchAnalysisWithPackageVulns (the idToModuleToCalled assignment loop).

Expected behavior

A vulnerability with ANY called finding must be reported as called, regardless of finding order. This matches the in-repo semantics elsewhere: internal/sourceanalysis/rust.go ("Once one advisory marks this vuln as called, always mark as called", OR-ing), and internal/scalibrenricher/govulncheck/source/govulncheck.go where reachability is ANY finding with a function frame. The Go path is the odd one out.

Actual behavior (order-dependent verdict)

Same finding set, different outcome depending only on order:

  • order [called, uncalled] -> Called=false (wrong: the false negative)
  • order [uncalled, called] -> Called=true

Impact

A misclassified vulnerability goes to the hidden (uncalled) bucket in output (internal/output/output_result.go), and determineReturnErr (pkg/osvscanner/osvscanner.go) returns no error (exit 0) when only uncalled vulnerabilities are found with --show-all-vulns off. Go call analysis is ON by default. Net effect: a Go project calling a vulnerable symbol can get a clean scan purely because of finding order. (Exit 0 for genuinely uncalled vulnerabilities is by design; the defect is the misclassification feeding it.)

Minimal reproduction

Call matchAnalysisWithPackageVulns with package github.com/gogo/protobuf v1.3.1, vulnerability GO-2021-0053 (with an imports field), and two findings for the same OSV and module: one with Trace[0].Function set (called) and one with Trace[0].Function empty (uncalled). In order [called, uncalled] the resulting ExperimentalAnalysis["GO-2021-0053"].Called is false; in the reversed order it is true. Verified against the real function with a unit test in both orders.

Suggested fix shape (not applied)

OR instead of overwrite in the aggregation loop:
idToModuleToCalled[f.OSV][modulePath] = idToModuleToCalled[f.OSV][modulePath] || called

Dup-screen note

Searched existing issues and the web for this aggregation flaw and found no existing issue describing it. No repo TODO or comment acknowledges last-wins behavior here.

Activity

  1. choksi2212 commented on Oct 24, 2026

    @choksi2212

    Confirmed on current main (0c8f9eb) with a regression test on matchAnalysisWithPackageVulns: two GO-2021-0053 findings for the same module, in order [called, uncalled], leave ExperimentalAnalysis["GO-2021-0053"] at Called=false, while the reversed order gives Called=true - the plain map assignment in the aggregation loop keeps whichever finding lands last. The uncalled-only case stays false either way, so OR-ing the aggregation does not turn a genuinely uncalled vuln into a called one. That also lines up with what rust.go already does ("Once one advisory marks this vuln as called, always mark as called").

    I traced the downstream consumers while verifying: both the exit-code check (determineReturnErr via GroupInfo.IsCalled() at pkg/osvscanner/osvscanner.go:387) and the output bucketing (internal/output/output_result.go:531/537) key off AnalysisInfo.Called, so fixing the aggregation at the source covers the exit-0 path and the hidden-bucket path together.

    I have the one-line OR fix plus the order-independence table test ready (the full internal/sourceanalysis suite passes with it). Happy to open the PR if this gets assigned to me.

  2. another-rex commented on Oct 25, 2026

    @another-rex
    Collaborator

    Happy to receive a quick fix for general code hardening. However I don't think this currently actually impacts any results, because govulncheck simply never emits any uncalled symbol findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions