CVE-2026-97035: Go cgo arbitrary code execution via compiler flags

CVE-2026-97035 · Severity: info · Published 2026-11-11

Go's build system allows developers to specify custom C compiler flags in cgo directives, which are used when compiling packages that integrate C code. A malicious package could exploit improper validation of compiler flags (specifically "-gen-*" or "-gnat*" options) to execute arbitrary code at build time or write files to any directory on the system, affecting any project that builds untrusted Go packages.

Technologies: toolchain (Go), Google Go. Vendors: Go, Google.

Quick answers

Is CVE-2026-97035 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2026-97035 being exploited in the wild.
How severe is CVE-2026-97035?
Informational severity, published 11 November 2026.
Which products and versions are affected?
toolchain (Go) SEMVER:introduced=0,fixed=1.26.11,introduced=1.27.0-0,fixed=1.27.4.
Is there a fix for CVE-2026-97035?
Yes. toolchain (Go): upgrade to 1.27.4 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2026-97035 attacked?
It is attacked with local access.
Am I affected by CVE-2026-97035?
Check whether you run toolchain (Go) or Google Go at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

How to fix

  • toolchain (Go): upgrade to 1.27.4 or later
    go get toolchain@v1.27.4

Technical details

The Go command's flag allowlist used a "-g*" wildcard that unintentionally matched Clang's two-argument "-gen-cdb-fragment-path" and GCC's "-gnatO" flags, allowing malicious cgo directives to write files to arbitrary locations and desynchronize flag parsing, passing unvalidated arguments to the linker. The vulnerability is triggered when building a package with malicious "#cgo" compiler or linker flags. Go has patched this by explicitly disallowing "-gen-*" and "-gnat*" flags in cgo directives.

Affected products

  • Google Go

Identifiers

  • CVE-2026-97035
  • GO-2026-6856

Timeline

  • 2026-11-11: disclosed

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.