REDHAT-BUG-2571443: Medium severity go Go vulnerability

Published Nov 11, 2026
·
Updated

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:cgoldflag" directives. When "cmd/cgo" generates "cgogotypes.go", it quotes each "#cgo LDFLAGS" argument with strconv.Quote in a "//go:cgoldflag" 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 Software

1 affected component
go Go

Event History

Nov 11, 2026
Data Sourced
via Red Hat·03:21 AM
DescriptionSeverityAffected Software

Frequently Asked Questions

1

Who is realistically exposed to this issue?

Systems that build Go packages using cgo are exposed when they build a malicious or otherwise untrusted package containing crafted cgo linker-flag directives. The issue occurs during the build process rather than requiring the resulting program to be run.

2

What does an attacker need to exploit it?

An attacker needs to get a crafted Go package built with cgo. The package can use specially quoted "//go:cgo_ldflag" directives to smuggle disallowed linker flags or unvalidated linker search paths past the go command's checks.

3

What are the possible effects during a vulnerable build?

A successful bypass can pass attacker-controlled linker options to the external linker and cause unexpected code execution at build time. Crafted flag lists can also cause the go command to panic due to an out-of-bounds slice index during LDFLAGS deduplication.

4

How can this be mitigated if patching is not immediately possible?

Avoid building untrusted Go packages that use cgo, especially packages whose source contains cgo linker-flag directives. Restrict build inputs to reviewed and trusted source until the corrected Go tooling is available.

5

How can I tell whether a package is attempting to trigger this issue?

Review cgo-related source and generated build inputs for crafted quoting in "//go:cgo_ldflag" directives and for unusual "#cgo LDFLAGS" values. A vulnerable build may also fail with a go command panic while processing cgo LDFLAGS.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203