Skip to main content
Live Webinar with SANS (June 25)— Agentic CTI Automation for Fun & ProfitRegister Free
Mallory
High

Arbitrary file write in Go cmd/go via malicious #cgo pkg-config directive

IdentifiersCVE-2025-61731CWE-73

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.

Share:
For your environment

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.

ANALYST BRIEF

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.

Successful exploitation allows an attacker to cause writes to attacker-selected files accessible to the user or service account performing the build. Although content control is partial, this can enable file tampering, corruption of build artifacts or configuration files, and potentially follow-on code execution depending on the targeted path and surrounding environment. In CI/CD or developer build environments, this creates a supply-chain risk because building untrusted Go code can trigger unintended filesystem modification outside the expected workspace.

Mitigation

If you can’t patch tonight, do this now.

Do not build untrusted Go source code with vulnerable toolchains. Where feasible, disable cgo for untrusted builds (for example, CGO_ENABLED=0), and sandbox builds in containers or VMs with least-privilege filesystem access and read-only or tightly scoped writable directories. Restrict pkg-config availability or monitor for unexpected pkg-config arguments, especially "--log-file". Limit build account permissions so arbitrary writes cannot affect sensitive paths.

Remediation

Patch, then assume compromise.

Upgrade the Go toolchain to a fixed release. The provided content states that Go 1.25.6 and Go 1.24.12 include the fix for CVE-2025-61731. Rebuild affected environments and ensure build systems, developer workstations, and CI runners use the patched cmd/go version.
PUBLIC EXPLOITS

Exploits

No public exploits tracked yet. Mallory keeps watching.

VALID 0 / 0 TOTALView more in app

No public exploit code observed for this vulnerability.

EXPOSURE SURFACE

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.

VendorProductType
Go ProjectGo (Cmd/Go)application
GolangGoapplication

Vendor-confirmed product mapping. Mallory continuously reconciles this list against your asset inventory.

What this page doesn’t show

The version that knows your environment.

This page is what’s public. Mallory adds the parts that aren’t: which of your assets are affected, which adversaries are exploiting it right now, which detections to deploy, and what to do tonight.
Exposure mapping

Query your assets running an affected version, and investigate the blast radius.

Threat actor evidence

Every observed campaign linking this CVE to a named adversary.

Associated malware

Malware families riding this exploit, with evidence and IOCs.

Detection signatures

YARA, Sigma, Snort, and vendor rules, auto-deployed to your SIEM.

Vendor-by-vendor mapping

Cross-references every affected SKU, including bundled OEM variants.

Social activity16

Community discussion across Reddit, Mastodon, and other social sources.