CVE-2025-61731: CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection') in Go toolchain cmd/go
Building a malicious file with cmd/go can cause can cause a write to an attacker-controlled file with partial control of the file content. The "#cgo pkg-config:" directive in a Go source file provides command-line arguments to provide to the Go pkg-config command. An attacker can provide a "--log-file" argument to this directive, causing pkg-config to write to an attacker-controlled location.
AI Analysis
Technical Summary
The vulnerability in cmd/go arises from improper neutralization of special elements in OS command arguments (CWE-78 and CWE-88). Specifically, the '#cgo pkg-config:' directive in Go source files can be abused by an attacker to pass a '--log-file' argument to pkg-config, causing it to write to an arbitrary file controlled by the attacker. This arbitrary file write can modify or poison build artifacts and caches, impacting build integrity and behavior. The vulnerability requires local access with at least low privileges and no user interaction. Red Hat has released security updates for golang packages to address this issue.
Potential Impact
An attacker with the ability to build malicious Go source files can cause arbitrary file writes during the build process, potentially leading to broken builds, altered tool behavior, and poisoned caches or artifacts. Although this does not directly enable code execution, it compromises build integrity and can disrupt development workflows. The impact affects confidentiality, integrity, and availability of the build environment and artifacts.
Mitigation Recommendations
Red Hat has released updated golang packages that fix this vulnerability. Users should apply these security updates as soon as possible. Currently, no effective mitigations meet Red Hat's criteria for ease of use and deployment. Until patched, restricting build permissions and limiting untrusted source builds may reduce risk. Refer to Red Hat advisory RHSA-2026:5943 for update instructions.
CVE-2025-61731: CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection') in Go toolchain cmd/go
Description
Building a malicious file with cmd/go can cause can cause a write to an attacker-controlled file with partial control of the file content. The "#cgo pkg-config:" directive in a Go source file provides command-line arguments to provide to the Go pkg-config command. An attacker can provide a "--log-file" argument to this directive, causing pkg-config to write to an attacker-controlled location.
CVSS v3.1
Score 7.8high
Affected software
Go toolchain
cmd/go
Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
The vulnerability in cmd/go arises from improper neutralization of special elements in OS command arguments (CWE-78 and CWE-88). Specifically, the '#cgo pkg-config:' directive in Go source files can be abused by an attacker to pass a '--log-file' argument to pkg-config, causing it to write to an arbitrary file controlled by the attacker. This arbitrary file write can modify or poison build artifacts and caches, impacting build integrity and behavior. The vulnerability requires local access with at least low privileges and no user interaction. Red Hat has released security updates for golang packages to address this issue.
Potential Impact
An attacker with the ability to build malicious Go source files can cause arbitrary file writes during the build process, potentially leading to broken builds, altered tool behavior, and poisoned caches or artifacts. Although this does not directly enable code execution, it compromises build integrity and can disrupt development workflows. The impact affects confidentiality, integrity, and availability of the build environment and artifacts.
Mitigation Recommendations
Red Hat has released updated golang packages that fix this vulnerability. Users should apply these security updates as soon as possible. Currently, no effective mitigations meet Red Hat's criteria for ease of use and deployment. Until patched, restricting build permissions and limiting untrusted source builds may reduce risk. Refer to Red Hat advisory RHSA-2026:5943 for update instructions.
Technical Details
- Data Version
- 5.2
- Assigner Short Name
- Go
- Date Reserved
- 2025-09-30T15:05:03.605Z
- State
- PUBLISHED
- Vendor Advisory Urls
- [{"url":"https://access.redhat.com/security/cve/CVE-2025-61731","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:5943","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:5941","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:6949","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:7878","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:7879","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:7876","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:7877","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:7883","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:7833","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:7834","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:5944","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:5942","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:7385","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:7291","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:12282","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:14100","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:21691","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:15091","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:14774","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:20088","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:5907","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:12118","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:5133","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:13736","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:4434","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:3855","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:3559","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:3556","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:5948","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:5950","vendor":"Red Hat"},{"url":"https://access.redhat.com/errata/RHSA-2026:5952","vendor":"Red Hat"}]
Threat ID: 697a653b4623b1157cea4ee6
Added to database: 01/28/2026, 19:36:27 UTC
Last enriched: 08/15/2026, 15:35:21 UTC
Last updated: 09/10/2026, 19:36:51 UTC
Views: 178
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
External Links
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.