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

Source: https://junglewise.ai/threats/cve-2026-97035-when-using-clang-or-gcc-building-a-malicious-package-that-uses  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-11-11. Updated: 2026-11-11  
License: CC BY 4.0 with a link back

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)](https://junglewise.ai/threats/technologies/toolchain), [Google Go](https://junglewise.ai/threats/technologies/google-go). Vendors: [Go](https://junglewise.ai/threats/vendors/go), [Google](https://junglewise.ai/threats/vendors/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

  ```sh
  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

- [https://pkg.go.dev/](https://pkg.go.dev/)
- [https://go.dev/cl/862148](https://go.dev/cl/862148)

## Related threats

- [Go HTTP/1 server race condition in MaxBytesReader header handling](https://junglewise.ai/threats/cve-2026-97054-for-http-1-servers-when-maxbytesreader-s-limit-is-exceeded)
- [Go cgo LDFLAGS validation bypass in cmd/cgo](https://junglewise.ai/threats/cve-2026-97043-building-a-malicious-package-that-uses-cgo-could-bypass-cgo)
- [Go compiler unsafe library path validation in Windows linker](https://junglewise.ai/threats/cve-2026-97042-building-a-malicious-package-that-uses-go-cgo-import-dynamic-or)
- [Go compiler cgo linker flag injection via directives](https://junglewise.ai/threats/cve-2026-97041-building-a-malicious-package-containing-go-cgo-compiler)
- [Go linker arbitrary flag injection via crafted .syso files](https://junglewise.ai/threats/cve-2026-97040-building-a-package-containing-a-crafted-syso-file-could-bypass)
