# CVE-2025-61731: Google Go argument injection in cmd/go cgo directive

Source: https://junglewise.ai/threats/cve-2025-61731-google-go-argument-injection-in-cmd-go-cgo-directive  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-01-28. Updated: 2026-06-30  
License: CC BY 4.0 with a link back

CVE-2025-61731 · Severity: high · CVSS 7.8 · Published 2026-01-28

A vulnerability in the Go programming language's build tool allows a malicious source file to trigger unauthorized file writes on a developer's system. By including a specially crafted directive in a Go file, an attacker can force the build process to write data to unintended locations, potentially leading to system compromise or arbitrary code execution when the project is built.

Technologies: [toolchain (Go)](https://junglewise.ai/threats/technologies/toolchain). Vendors: [Go](https://junglewise.ai/threats/vendors/go).

## Quick answers

**Is CVE-2025-61731 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2025-61731 being exploited in the wild.

**How severe is CVE-2025-61731?** High severity, with a CVSS score of 7.8, published 28 January 2026.

**Which products and versions are affected?** toolchain (Go) SEMVER:introduced=0,fixed=1.24.12,introduced=1.25.0,fixed=1.25.6.

**Is there a fix for CVE-2025-61731?** Yes. toolchain (Go): upgrade to 1.25.6 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2025-61731 attacked?** It is attacked with local access, in a software library.

**Am I affected by CVE-2025-61731?** Check whether you run toolchain (Go) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- toolchain (Go): upgrade to 1.25.6 or later

  ```sh
  go get toolchain@v1.25.6
  ```


## Technical details

A vulnerability exists in the 'cmd/go' component of the Go standard library due to insufficient sanitization of flags in the '#cgo pkg-config:' directive. An attacker can bypass flag sanitization by providing a '--log-file' argument within a Go source file, which is then passed to the pkg-config binary. This allows the attacker to trigger a write to an arbitrary file path with partial control over the content. While the primary impact is an unauthorized file write, the Go project notes this can lead to arbitrary code execution. The issue is tracked as CVE-2025-61731 and is fixed in Go versions 1.24.12 and 1.25.6.

## Affected products

- Google Go before 1.24.12, 1.25.0 to 1.25.5

## Identifiers

- CVE-2025-61731
- GO-2026-4339

## Timeline

- 2026-01-07: disclosed: Issue opened on Go GitHub repository
- 2026-01-28: advisory: Official Go security advisory published

## References

- [https://pkg.go.dev/](https://pkg.go.dev/)
- [https://go.dev/cl/736711](https://go.dev/cl/736711)
- [https://go.dev/issue/77100](https://go.dev/issue/77100)
- [https://groups.google.com/g/golang-announce/c/Vd2tYVM8eUc](https://groups.google.com/g/golang-announce/c/Vd2tYVM8eUc)
- [https://pkg.go.dev/vuln/GO-2026-4339](https://pkg.go.dev/vuln/GO-2026-4339)
- [https://access.redhat.com/errata/RHSA-2026:12118](https://access.redhat.com/errata/RHSA-2026:12118)
- [https://access.redhat.com/errata/RHSA-2026:12282](https://access.redhat.com/errata/RHSA-2026:12282)

## Related threats

- [Go cgo LDFLAGS validation bypass in cmd/cgo](https://junglewise.ai/threats/cve-2026-97043-building-a-malicious-package-that-uses-cgo-could-bypass-cgo)
- [Go compiler unsafe library path validation in Windows linker](https://junglewise.ai/threats/cve-2026-97042-building-a-malicious-package-that-uses-go-cgo-import-dynamic-or)
- [Go compiler cgo linker flag injection via directives](https://junglewise.ai/threats/cve-2026-97041-building-a-malicious-package-containing-go-cgo-compiler)
- [Go linker arbitrary flag injection via crafted .syso files](https://junglewise.ai/threats/cve-2026-97040-building-a-package-containing-a-crafted-syso-file-could-bypass)
- [Go command unsafe pkg-config flag handling in cgo](https://junglewise.ai/threats/cve-2026-97039-building-a-malicious-package-that-uses-cgo-pkg-config-directives)
