CVE-2025-61731
📋 TL;DR
This vulnerability allows attackers to write arbitrary content to files they control by exploiting the '#cgo pkg-config:' directive in Go source files. Attackers can use the '--log-file' argument to redirect pkg-config output to arbitrary locations. This affects Go applications that process untrusted source files using cmd/go.
💻 Affected Systems
- Go programming language
📦 What is this software?
Go by Golang
Go by Golang
⚠️ Risk & Real-World Impact
Worst Case
Arbitrary file write could lead to remote code execution if combined with other vulnerabilities, or data corruption by overwriting critical system files.
Likely Case
Local file system manipulation, potentially enabling privilege escalation or data exfiltration by writing to sensitive locations.
If Mitigated
Limited impact if proper sandboxing and file permission controls prevent writes to sensitive directories.
🎯 Exploit Status
Exploitation requires the ability to provide malicious Go source files to cmd/go, typically through build systems or code analysis tools.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: Go 1.24.0
Vendor Advisory: https://groups.google.com/g/golang-announce/c/Vd2tYVM8eUc
Restart Required: No
Instructions:
1. Download Go 1.24.0 or later from https://go.dev/dl/ 2. Install the new version 3. Rebuild any affected Go applications with the updated toolchain
🔧 Temporary Workarounds
Disable pkg-config logging
allConfigure pkg-config to not use --log-file argument
export PKG_CONFIG="pkg-config --log-file=/dev/null"
Sandbox build environments
allRun cmd/go in restricted environments with limited file write permissions
🧯 If You Can't Patch
- Implement strict input validation to reject Go source files containing suspicious #cgo directives
- Run cmd/go in containers or VMs with restricted filesystem access
🔍 How to Verify
Check if Vulnerable:
Check Go version with 'go version'. If version is earlier than 1.24.0, the system is vulnerable.
Check Version:
go version
Verify Fix Applied:
After updating, verify with 'go version' shows 1.24.0 or later.
📡 Detection & Monitoring
Log Indicators:
- Unusual pkg-config invocations with --log-file arguments
- File writes to unexpected locations during Go builds
SIEM Query:
Process execution where command contains 'pkg-config' AND arguments contain '--log-file'