SEVERITY NOT PROVIDED EPSS 0.7% · 50th percentile

CVE-2026-97043: Unexpected code execution via escaped quotes in //go:cgo_ldflag in cmd/go and cmd/compile

Published 2026-11-11 · Updated 2026-11-27 · Also known as BIT-golang-2026-97043, GO-2026-6848

Summary

A vulnerability in the Go toolchain allows arbitrary code execution or process crashes during the build process via crafted //go:cgo_ldflag directives. Go developers and build environment administrators should update their toolchains to the corrected versions immediately.

Who is affected

The vulnerability affects projects using cgo where malicious packages can bypass linker flag validation through improper quote handling in pragmas. This can lead to the injection of disallowed linker flags, unauthorized search paths, or an out-of-bounds panic in the go command. The flaw is triggered at build time when compiling malicious or untrusted packages.

Exploitability

The severity and CVSS vector are not documented, though the EPSS score of 0.007 indicates a low predicted probability of exploitation. CISA KEV status is no, confirming there is no evidence of active exploitation in the wild.

Remediation

How to check your project

Automated analysis of the published advisory data, generated 2026-11-27. Not human-reviewed; verify against the official advisory. How this works.

Affected packages

EcosystemPackageAffected versionsFixed inUpgrade
Go toolchain >= 0, < 1.26.11 1.26.11 go get [email protected]
Go toolchain >= 1.27.0-0, < 1.27.4 1.27.4 go get [email protected]

FAQ

What is the primary cause of this vulnerability?

The vulnerability is caused by a mismatch in how cmd/cgo quotes #cgo LDFLAGS arguments and how cmd/compile and cmd/go parse the resulting //go:cgo_ldflag directives, leading to improper handling of backslash escapes.

Does this flaw affect the Go runtime code?

No, the vulnerability is specific to the build-time tools, specifically the cmd/go and cmd/compile components of the Go toolchain.

What happens if the go command encounters the slice bounds error?

If the deduplication of LDFLAGS triggers the out-of-bounds slice index error, the go command will panic, resulting in a build failure.

Original advisory description
Building a malicious package that uses cgo could bypass "#cgo LDFLAGS" validation and cause unexpected code execution at build time, or cause the go command to panic, via crafted quoting in "//go:cgo_ldflag" directives. When "cmd/cgo" generates "_cgo_gotypes.go", it quotes each "#cgo LDFLAGS" argument with strconv.Quote in a "//go:cgo_ldflag" directive, but "cmd/compile" and "cmd/go" parsed those directives by splitting on raw quote characters without handling backslash escapes or unquoting the string. This mismatch allowed disallowed linker flags or unvalidated linker search paths to be smuggled past the go command's flag checks and passed to the external linker. In addition, deduplicating LDFLAGS in the go command could panic with an out-of-bounds slice index when a prefix of the flag list matched near the end of the slice. "cmd/compile" and "cmd/go" now properly handle backslash-escaped quotes and unquote "//go:cgo_*" pragma strings with strconv.Unquote, and the slice bounds check in processCgoOutputs has been fixed.

References

Source records: GO-2026-6848 (OSV.dev) · EPSS by FIRST, 2026-11-27.