Skip to content
OpenAdvisories

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.

Affected products

VendorProductAffectedFixed
Go toolchain cmd/go 0 <1.26.11 —
Go toolchain cmd/go 1.27.0-0 <1.27.4 —
Go toolchain cmd/compile 0 <1.26.11 —
Go toolchain cmd/compile 1.27.0-0 <1.27.4 —

Fixed in Linux distributions

Distributions backport fixes, so the version that fixes this vulnerability differs per release — upgrade to at least the version shown. From the distributions' security trackers and advisories.

ReleasePackageFixed inAdvisory
Debian 14 golang-1.26 +1 No fix yet —
Debian 13 golang-1.24 No fix yet —
Debian 12 golang-1.19 No fix yet —
ReleasePackageFixed inAdvisory
Ubuntu 26.10 golang-1.26 +1 No fix yet —
Ubuntu 26.04 LTS golang-1.23 +3 No fix yet —
Ubuntu 24.04 LTS golang-1.21 +5 No fix yet —
Ubuntu 22.04 LTS golang-1.17 +8 No fix yet —
Ubuntu 20.04 LTS golang-1.13 +5 No fix yet —
Show 7 more (older releases, extended support, other products)
ReleasePackageFixed inAdvisory
Ubuntu 18.04 LTS golang-1.8 +2 No fix yet —
Ubuntu 16.04 LTS golang-1.6 +1 No fix yet —
Ubuntu 14.04 LTS golang-1.10 No fix yet —
Ubuntu Pro 22.04 LTS golang-1.13 No fix yet —
Ubuntu Pro 20.04 LTS golang-1.16 No fix yet —
Ubuntu Pro 18.04 LTS golang-1.13 +2 No fix yet —
Ubuntu Pro 16.04 LTS golang-1.13 +1 No fix yet —
ReleasePackageFixed inAdvisory
openSUSE Tumbleweed go1.26 1.26.11-1.1 openSUSE-SU-2026:12529-1

Affected packages

EcosystemPackageAffectedFixedRecord
Go toolchain < 1.26.11 · >= 1.27.0-0, < 1.27.4 1.26.11, 1.27.4 GO-2026-6848

Advisories 2

References