CVE-2025-61731: Arbitrary File Write via pkg-config Argument Injection in Go cmd/go
- Vendor
- Golang
CVE-2025-61731 is an argument-injection vulnerability in Go's cmd/go build tooling. Arguments supplied through the #cgo pkg-config: directive are passed to pkg-config without sufficient allowlist validation. A malicious Go source file can supply the --log-file option to cause pkg-config to write to an attacker-selected location, with partial attacker control over the written content. Exploitation occurs during a build and can cause unauthorized file creation or modification, potentially leading to arbitrary code execution.
Impact, mitigation & remediation
What it means and what to do now: patch path, interim mitigations, and the assume-compromise checklist.
Impact
What an attacker gets, and what they’ve been doing with it.
Successful exploitation compromises filesystem integrity under the permissions of the build process by writing partially attacker-controlled content to an attacker-selected location. Depending on the destination and subsequent use of the modified file, this may lead to arbitrary code execution. The primitive does not provide unrestricted control over the written content.
Mitigation
If you can’t patch tonight, do this now.
Avoid building untrusted Go source with vulnerable toolchains. Where compatible with the project, disable cgo using CGO_ENABLED=0. Otherwise, isolate builds in a sandbox with least-privilege filesystem access and restrict writes outside designated build directories. Monitor or reject unexpected pkg-config arguments, particularly --log-file.
Remediation
Patch, then assume compromise.
Upgrade the Go toolchain to Go 1.24.12, Go 1.25.6, or a later patched release. The fix sanitizes arguments arising from CgoPkgConfig before invoking pkg-config, preventing options outside the permitted allowlist. For vendor-distributed Go packages or bundled toolchains, apply the corresponding vendor security update.
Exploits
No public exploits tracked yet. Mallory keeps watching.
Affected products & vendors
Products and vendors Mallory has correlated with this vulnerability. Open in Mallory to drill down to specific CPE configurations and version ranges.
References
Frequently asked questions
- Is CVE-2025-61731 exploited in the wild?
- As of Nov 23, 2026, Mallory has no reports of CVE-2025-61731 being exploited in the wild. It is not listed in CISA KEV.
- Is there a public exploit for CVE-2025-61731?
- As of Nov 23, 2026, Mallory has found no public exploit for CVE-2025-61731.
- Is there a patch for CVE-2025-61731?
- Upgrade the Go toolchain to Go 1.24.12, Go 1.25.6, or a later patched release. The fix sanitizes arguments arising from CgoPkgConfig before invoking pkg-config, preventing options outside the permitted allowlist.
- What products are affected by CVE-2025-61731?
- Golang Go.
- How severe is CVE-2025-61731?
- CVE-2025-61731 has a CVSS v3.1 score of 8.6 (High) and an EPSS score of 0.49% (35th percentile) as of Nov 23, 2026.
Recent activity
40 sources tracked across advisories, community write-ups, and news. New activity surfaces here as Mallory finds it.