CVE-2023-29405: Improper sanitization of LDFLAGS with embedded spaces in go command with cgo in cmd/go

Published Jun 8, 2023
·
Updated

Golang Go could allow a remote attacker to execute arbitrary code on the system, caused by a flaw when running "go get" on a malicious module. By sending a specially crafted request using linker flags, an attacker could exploit this vulnerability to execute arbitrary code on the system.

Other sources

Improper sanitization of LDFLAGS with embedded spaces in go command with cgo in cmd/go

Microsoft

The go command may execute arbitrary code at build time when using cgo. This may occur when running "go get" on a malicious module, or when running any other command which builds untrusted code. This can by triggered by linker flags, specified via a "#cgo LDFLAGS" directive. Flags containing embedded spaces are mishandled, allowing disallowed flags to be smuggled through the LDFLAGS sanitization by including them in the argument of another flag. This only affects usage of the gccgo compiler.

https://go.dev/issue/60306 https://pkg.go.dev/vuln/GO-2023-1842 https://groups.google.com/g/golang-announce/c/q5135a9d924/m/j0ZoAJOHAwAJ https://go.dev/cl/501224

Red Hat

The go command may execute arbitrary code at build time when using cgo. This may occur when running "go get" on a malicious module, or when running any other command which builds untrusted code. This is can by triggered by linker flags, specified via a "#cgo LDFLAGS" directive. Flags containing embedded spaces are mishandled, allowing disallowed flags to be smuggled through the LDFLAGS sanitization by including them in the argument of another flag. This only affects usage of the gccgo compiler.

Launchpad

Affected Software

16 affected componentsFixes available
redhat/go<1.20.5
1.20.5
redhat/go<1.19.10
1.19.10
debian/golang-1.15<=1.15.15-1~deb11u4
debian/golang-1.19<=1.19.8-2
IBM Cloud Pak for Business Automation<=V23.0.1 - V23.0.1-IF002
IBM Cloud Pak for Business Automation<=V21.0.3 - V21.0.3-IF024
IBM Cloud Pak for Business Automation<=V22.0.2 - V22.0.2-IF006 and later fixesV22.0.1 - V22.0.1-IF006 and later fixesV21.0.2 - V21.0.2-IF012 and later fixesV21.0.1 - V21.0.1-IF007 and later fixesV20.0.1 - V20.0.3 and later fixesV19.0.1 - V19.0.3 and later fixesV18.0.0 - V18.0.2 and later fixes
Golang Go<1.19.10
Golang Go>=1.20.0<1.20.5
Fedoraproject Fedora=38
Microsoft cbl2 golang 1.21.6-1
Microsoft cbl2 golang 1.18.8-7
Microsoft cbl2 golang 1.17.13-2
Microsoft cbl2 golang 1.20.7-1
Microsoft azl3 golang 1.20.7-1
Microsoft cbl2 msft-golang 1.20.7-1

Remediation

Event History

Jun 8, 2023
CVE Published
via MITRE·08:19 PM
Data Sourced
via MITRE·08:19 PM
DescriptionWeakness
Oct 10, 2024
Data Sourced
via Launchpad·01:15 PM
Description
Nov 15, 2024
Data Sourced
via Ubuntu·01:20 PM
RemedyDescriptionSeverityAffected Software
Sep 4, 2025
Data Sourced
via Microsoft·12:08 PM
DescriptionSeverityWeakness
Data Sourced
via Microsoft·12:08 PM
Affected Software
Updated
via Microsoft·12:08 PM
Affected Software
Updated
via Microsoft·12:08 PM
DescriptionSeverity

Parent advisories

This vulnerability appears in the following advisories.

Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is CVE-2023-29405?

CVE-2023-29405 is a vulnerability in the go command that allows for the execution of arbitrary code at build time when using cgo.

2

How does CVE-2023-29405 occur?

CVE-2023-29405 can occur when running "go get" on a malicious module or any other command that builds untrusted code, triggered by linker flags specified via a "#cgo LDFLAGS" directive.

3

Which software versions are affected by CVE-2023-29405?

Versions of the go command up to version 1.19.10, versions 1.20.0 to 1.20.5, and Fedora version 38 are affected by CVE-2023-29405.

4

What is the severity of CVE-2023-29405?

CVE-2023-29405 has a severity rating of 9.8, which is considered critical.

5

How can I fix CVE-2023-29405?

To fix CVE-2023-29405, it is recommended to update to a version of the go command that is not affected by the vulnerability.

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