Skip to content

ci: pin govulncheck by commit SHA to avoid x/tools generics panic#558

Open
Benehiko wants to merge 2 commits into
mainfrom
fix/pin-govulncheck
Open

ci: pin govulncheck by commit SHA to avoid x/tools generics panic#558
Benehiko wants to merge 2 commits into
mainfrom
fix/pin-govulncheck

Conversation

@Benehiko

@Benehiko Benehiko commented Jun 19, 2026

Copy link
Copy Markdown
Member

What

The "Check for known vulnerabilities that affect Go code" CI job fails because govulncheck panics:

panic: ForEachElement called on type containing *types.TypeParam

Why (root cause)

It is not a real vulnerability and not a govulncheck-code bug — it is a transitive golang.org/x/tools regression exposed by the unpinned @latest:

  1. @latest now resolves to govulncheck v1.4.0, which bumped golang.org/x/tools v0.44.0 → v0.46.0.
  2. v0.46.0 added generic-method support to go/ssa, but its RuntimeTypes guard is incomplete. In go/ssa/emit.go, hasTypeParams() = recvtypeparams + typeparams > 0. A closure defined inside a method of a generic type inherits the parent's typeparams but not its recvtypeparams (where the method's type parameter lives), so hasTypeParams() returns false.
  3. That closure boxing a parameterized type into an interface (e.g. func() any { return &box[N]{} }) records the still-uninstantiated *box[N] in makeInterfaceTypes.
  4. cha.CallGraph → ssautil.AllFunctions → Program.RuntimeTypes → typesinternal.ForEachElement then reaches the bare *types.TypeParam and panics — that function's contract forbids parameterized types.

This repo uses generics heavily, so the scan hits the path. v1.3.0 uses x/tools v0.44.0 (pre-generic-methods) and never reaches it.

Tracking: golang/go#80055 (x/tools root cause, open, Go1.27 milestone, fix CL go.dev/cl/792260) and golang/go#80059 (govulncheck-facing report).

The advisories govulncheck does report (e.g. GO-2026-4503 in filippo.io/edwards25519) are all package/module-level with 0 call-reachable symbols, so they do not fail the gate — no dependency bump is needed.

Fix

Pin govulncheck to the golang/vuln v1.3.0 commit SHA (0782b76014f15f24e22a438f30f308df42899ba1) — the last release before the regression — via a GOVULNCHECK_VERSION build arg, mirroring the existing GOMODGUARD_VERSION pattern.

Pinned by commit SHA rather than the mutable tag for immutability; Go resolves @<sha> back to v1.3.0. No fix exists to pin forward to: golang/vuln master == the broken v1.4.0 tag, and x/tools master element.go is unchanged from v0.46.0. Bump once x/tools ships the fix and golang/vuln picks it up.

Verification

Ran the do-govulncheck target locally (linux/arm64) with the pin:

  • go install @<sha> resolves to govulncheck@v1.3.0.
  • No panic; exit 0.
  • All modules scan cleanly — every advisory reports "Your code is affected by 0 vulnerabilities."

🤖 Generated with Claude Code

govulncheck v1.4.0 (pulled by @latest) panics with "ForEachElement called on
type containing *types.TypeParam" when scanning the repo's generic code, which
fails the "known vulnerabilities" check. v1.3.0 is the last release before the
regression and scans the modules cleanly (the remaining advisories are all
package/module-level with 0 call-reachable symbols, so the gate passes).

Pin via a GOVULNCHECK_VERSION build arg, mirroring the GOMODGUARD_VERSION
pattern, so it is easy to bump once a fix ships upstream.

See golang/go#80059

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@docker-agent docker-agent Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

No bugs found in the changed code. The GOVULNCHECK_VERSION build arg is correctly scoped to the govulncheck stage, the default value v1.3.0 is properly referenced in the go install command, and the approach mirrors the existing GOMODGUARD_VERSION pattern. The comment clearly documents the reason for the pin and links to the upstream issue.

…cause

Switch the govulncheck pin from the v1.3.0 tag to its immutable commit SHA
(golang/vuln 0782b76014f15f24e22a438f30f308df42899ba1; Go resolves it back to
v1.3.0).

Root cause of the v1.4.0 failure: v1.4.0 bumped golang.org/x/tools v0.44.0 ->
v0.46.0. v0.46.0 added generic-method support to go/ssa, but its RuntimeTypes
guard is incomplete. A closure defined inside a method of a generic type
inherits the parent's typeparams but NOT its recvtypeparams, so
go/ssa/emit.go's hasTypeParams() guard returns false and a still-parameterized
MakeInterface operand (e.g. *box[N]) is recorded in makeInterfaceTypes.
cha.CallGraph -> ssautil.AllFunctions -> Program.RuntimeTypes ->
typesinternal.ForEachElement then panics on the bare *types.TypeParam. v1.3.0
uses x/tools v0.44.0 (pre-generic-methods) and never reaches that path.

No fix has shipped yet: golang/vuln master == the broken v1.4.0 tag, and
x/tools master element.go is unchanged from v0.46.0. Tracking: golang/go#80055
(x/tools root cause, Go1.27 milestone, fix CL go.dev/cl/792260) and
golang/go#80059 (govulncheck report). Bump once the fix lands and golang/vuln
picks it up.

Verified locally: do-govulncheck (linux/arm64) resolves the SHA to
govulncheck@v1.3.0, scans all modules with no panic, exit 0.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Benehiko Benehiko requested a review from joe0BAB June 19, 2026 13:51
@Benehiko Benehiko changed the title ci: pin govulncheck to v1.3.0 to avoid generics panic ci: pin govulncheck by commit SHA to avoid x/tools generics panic Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant