CVE-2025-61731

7.8

The Go Project · Go toolchain (cmd/go)

A vulnerability in the Go toolchain allows attackers to write to arbitrary files by injecting malicious arguments into the #cgo pkg-config directive.

Executive summary

A high-severity flaw in the Go toolchain permits unauthorized file writes, potentially leading to system compromise via OS command injection.

Vulnerability

The vulnerability stems from improper neutralization of command-line arguments within the #cgo pkg-config directive. By supplying a --log-file argument, a local attacker with low privileges can force the tool to write to arbitrary locations on the filesystem.

Business impact

The ability to write to attacker-controlled files on a system typically leads to complete compromise of confidentiality, integrity, and availability. With a CVSS score of 7.8, this flaw represents a significant risk to development environments and CI/CD pipelines where untrusted Go source code might be processed. Exploitation could allow an attacker to overwrite sensitive configuration files or inject malicious code into build processes.

Remediation

Immediate Action: Update the Go toolchain to version 1.24.12, 1.25.6, or newer versions that contain the fix for this directive injection issue.

Proactive Monitoring: Review build logs for unexpected file write operations or unusual command-line arguments passed to the pkg-config tool during the compilation phase.

Compensating Controls: Ensure that Go projects are built in isolated, ephemeral environments with restricted filesystem permissions to limit the impact of potential file-write exploits.

Exploitation status

Public Exploit Available: No

Analyst recommendation

Given the potential for total system impact and the role of the Go toolchain in modern software development, organizations must prioritize updating their build environments. Failure to patch allows for a critical vector of attack against the software supply chain. Please ensure all build agents and developer workstations running affected versions of the Go toolchain are updated immediately.

More The Go Project CVEs

Sources

Originally found and disclosed by RyotaK (https://ryotak.net) of GMO Flatt Security Inc., per the CVE Program record.