Arbitrary file write in Go cmd/go via malicious #cgo pkg-config directive
CVE-2025-61731 affects Go's cmd/go toolchain when processing cgo directives in Go source files. A malicious source file can include a crafted "#cgo pkg-config:" directive that causes cmd/go to invoke pkg-config with attacker-controlled arguments that bypass intended flag sanitization. Specifically, an attacker can supply the "--log-file" option so that pkg-config writes output to an attacker-chosen filesystem path. This results in an arbitrary file write primitive with partial control over file contents during the build process. The issue is described as a bypass of CgoPkgConfig flag sanitization in cmd/go.
Are you exposed to this one?
Mallory correlates every CVE against your assets, your vendors, and active adversary campaigns. Know which vulnerabilities matter for you, not just which ones are loud.
Impact, mitigation & remediation
What it means. What to do now. Patch path, mitigations, and the assume-compromise checklist.
Impact
What an attacker gets, and what they’ve been doing with it.
Mitigation
If you can’t patch tonight, do this now.
Remediation
Patch, then assume compromise.
Exploits
No public exploits tracked yet. Mallory keeps watching.
No public exploit code observed for this vulnerability.
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.
Vendor-confirmed product mapping. Mallory continuously reconciles this list against your asset inventory.
Recent activity
21 sources tracked across advisories, community write-ups, and news. New activity surfaces here as Mallory finds it.
Go toolchain (cmd/go) code execution risk via CgoPkgConfig flag sanitization bypass, allowing malicious parameters to influence pkg-config invocation and potentially lead to unintended command execution or dangerous compiler/linker option injection in build environments.
An arbitrary code execution risk in Go’s cmd/go where CgoPkgConfig can bypass flag sanitization and invoke pkg-config with unsafe inputs.
The version that knows your environment.
Query your assets running an affected version, and investigate the blast radius.
Every observed campaign linking this CVE to a named adversary.
Malware families riding this exploit, with evidence and IOCs.
YARA, Sigma, Snort, and vendor rules, auto-deployed to your SIEM.
Cross-references every affected SKU, including bundled OEM variants.
Community discussion across Reddit, Mastodon, and other social sources.