CVE-2023-29402
📋 TL;DR
This CVE-2023-29402 is a critical code injection vulnerability in Go's cgo build system. It allows attackers to execute arbitrary code during build time when processing untrusted modules with directory names containing newline characters. Users are affected when building Go programs with cgo using GOPATH mode (GO111MODULE=off) with untrusted source code.
💻 Affected Systems
- Go programming language
📦 What is this software?
Fedora by Fedoraproject
Go by Golang
Go by Golang
⚠️ Risk & Real-World Impact
Worst Case
Remote code execution with full system compromise during build process, potentially leading to supply chain attacks and persistent backdoors in compiled binaries.
Likely Case
Build-time code injection leading to malicious code execution in development environments or CI/CD pipelines, potentially compromising build artifacts.
If Mitigated
Limited impact when using module mode (GO111MODULE=on) and only building trusted source code.
🎯 Exploit Status
Exploitation requires the attacker to provide malicious source code with specially crafted directory names. The vulnerability is well-documented with public proof-of-concept available in the Go issue tracker.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: Go 1.20.5 and Go 1.19.10
Vendor Advisory: https://groups.google.com/g/golang-announce/c/q5135a9d924/m/j0ZoAJOHAwAJ
Restart Required: No
Instructions:
1. Update Go to version 1.20.5 or 1.19.10. 2. Run 'go version' to verify update. 3. Rebuild any affected binaries with the updated Go compiler.
🔧 Temporary Workarounds
Use Go Modules Mode
allSwitch from GOPATH mode to module mode which is not vulnerable to this issue
export GO111MODULE=on
Disable cgo
allBuild without cgo support if not required
export CGO_ENABLED=0
🧯 If You Can't Patch
- Only build trusted source code from verified repositories
- Use isolated build environments with minimal privileges for building untrusted code
🔍 How to Verify
Check if Vulnerable:
Check Go version with 'go version'. If version is below 1.20.5 or 1.19.10 and using GOPATH mode with cgo, the system is vulnerable.
Check Version:
go version
Verify Fix Applied:
Run 'go version' to confirm version is 1.20.5 or 1.19.10 or higher. Test building with cgo using GOPATH mode to ensure no unexpected behavior.
📡 Detection & Monitoring
Log Indicators:
- Unexpected build failures
- Suspicious directory names in build logs
- Unexpected cgo behavior during compilation
Network Indicators:
- Unusual network connections from build processes
- Downloads from untrusted repositories during builds
SIEM Query:
process_name:"go" AND (command_line:"GO111MODULE=off" OR command_line:"cgo") AND (parent_process:"make" OR parent_process:"build")
🔗 References
- https://go.dev/cl/501226
- https://go.dev/issue/60167
- https://groups.google.com/g/golang-announce/c/q5135a9d924/m/j0ZoAJOHAwAJ
- https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/NZ2O6YCO2IZMZJELQGZYR2WAUNEDLYV6/
- https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/XBS3IIK6ADV24C5ULQU55QLT2UE762ZX/
- https://pkg.go.dev/vuln/GO-2023-1839
- https://security.gentoo.org/glsa/202311-09
- https://go.dev/cl/501226
- https://go.dev/issue/60167
- https://groups.google.com/g/golang-announce/c/q5135a9d924/m/j0ZoAJOHAwAJ
- https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/NZ2O6YCO2IZMZJELQGZYR2WAUNEDLYV6/
- https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/XBS3IIK6ADV24C5ULQU55QLT2UE762ZX/
- https://pkg.go.dev/vuln/GO-2023-1839
- https://security.gentoo.org/glsa/202311-09
- https://security.netapp.com/advisory/ntap-20241213-0004/