Go toolchain: Arbitrary command execution via cgo and GCC spec files (CVE-2026-97034)
The Go toolchain's 'cmd/go' utility is vulnerable to arbitrary command execution at link time during cgo builds when processing untrusted GCC spec files.
CVE search metadata
CVE search record: CVE-2026-97034. Severity: high. CVSS: 8.8. EPSS: 0.28%. KEV: no. Product: cmd/go. Brief: Go toolchain: Arbitrary command execution via cgo and GCC spec files (CVE-2026-97034). Brief link: https://feed.craftedsignal.io/briefs/2026-11-cgo-gcc-command-execution-cve-2026-97034/
Triage facts
Revision 1- Applicability
- cmd/go
- Evidence
- Unknown
- Severity
- High
- Sources
- 2 public sources
- Freshness
- Revision 1Nov 16, 18:42 UTC
- Vulnerabilities
- 1 CVE
- Source quality
- A2Roughly even chance
Overview
When using GCC, building a malicious package that uses cgo could cause arbitrary command execution at link time via untrusted GCC spec files ('specs' or '.spec'). When linking with '-fopenmp', '-fopenacc', or '-fsanitize=' in '#cgo LDFLAGS', GCC's built-in link spec evaluates '%:include(libgomp.spec)' or '%:include(libsanitizer.spec)' and searches for spec files in '-L' and sysroot directories (including subdirectories and multilib sibling directories such as '../lib64'), as well as the working directory when '-fopenmp' or '-fopenacc' is used or when '-fsanitize=' is combined with '-static' or '-static-lib'.
Attack Chain
The vulnerability occurs during the link-time phase of a cgo-enabled Go build when specific GCC flags trigger the search for and evaluation of untrusted spec files located in directories reachable by the compiler.
Impact
Successful exploitation results in arbitrary command execution at link time during the build of a Go package that utilizes cgo.
Recommendation
The Go toolchain includes remediations in versions 1.26.11 and 1.27.4, which reject potentially malicious directory paths and restrict '-fsanitize=' flag values.
Threat Hunt
Identify builds involving 'go' compilation that trigger GCC via 'cgo' where '#cgo LDFLAGS' include '-fopenmp', '-fopenacc', or '-fsanitize='. Monitor for GCC processes that access or reference unusual 'specs' files within the build directory or sysroot paths.
Data: Process command line arguments, File system access logs for GCC processes, Build source code manifests