CVE-2025-61731: Arbitrary file write using cgo pkg-config directive in 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.
Security readout for executives and security teams
Plain-English summary
A malicious Go source file can cause the Go build process to write data to an attacker-chosen file path through cgo pkg-config handling. The main business risk is compromised developer or CI build environments, especially where untrusted code is built.
Executive priority
Prioritize remediation for engineering and CI systems that compile untrusted Go code. Runtime-only systems are less directly exposed unless they also include build tooling or package-building workflows.
Technical view
cmd/go passes arguments from the "#cgo pkg-config:" directive to Go's pkg-config handling. Provided sources state an attacker can supply a "--log-file" argument, causing pkg-config to write partially controlled content to an attacker-controlled location during build.
Likely exposure
Exposure is most likely in developer workstations, CI systems, package builders, and automation that build Go source with cgo/pkg-config enabled, especially from pull requests, forks, third-party modules, or untrusted archives.
Exploitation context
The CVSS vector is local with required user interaction, low complexity, no privileges, and changed scope. The provided bundle does not show KEV listing or active exploitation evidence, so active exploitation should not be claimed.
Researcher notes
The issue is an arbitrary file write during build, with only partial control of written content described. Sources identify cmd/go and cgo pkg-config directive handling; they do not provide complete affected-version or fixed-version detail in the bundle.
Mitigation direction
Apply applicable Go toolchain or OS vendor updates from Go and Red Hat guidance.
Check GO-2026-4339 and vendor advisories for fixed package versions.
Avoid building untrusted Go source in privileged or broadly writable environments.
Run untrusted builds in isolated, disposable CI workers with least privilege.
Restrict cgo/pkg-config use where it is not required.
Validation and detection
Inventory Go toolchain versions used by developers, CI, and package builders.
Identify pipelines that build untrusted Go source, forks, or third-party modules.
Confirm whether cgo and pkg-config are enabled in affected build paths.
Compare installed packages against Go vulnerability guidance and Red Hat errata.
Review build worker permissions and sensitive writable paths.
Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.
Potential ATT&CK relevance
Conservative CVE-to-ATT&CK context
These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.
ATT&CK lookup starting points
Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.
cwe · medium confidence lookup
CWE-78: Command execution behavior lookup
Command injection weaknesses can lead defenders to review execution techniques and command interpreter telemetry. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.
Command injection weaknesses can lead defenders to review execution techniques and command interpreter telemetry. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.
The CVE wording references file access or upload behavior, so file telemetry and web shell review may help. This is a Glexia inferred lookup path, not an official MITRE, ATT&CK, or CVE Program mapping.
These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.
2CVSS vectors
5Timeline events
2ADP providers
39Source links
SSVC decision data
CISA-ADPCISA Coordinator
Timestamp
Version
2.0.3
Exploitation: noneAutomatable: noTechnical Impact: total
CVSS vector scores
2 official scores
We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.
CWE links open Glexia weakness intelligence pages with official CWE context, developer remediation guidance, and related CVE mappings.
CWE-78 · source CWE mapping
Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection') represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.
Improper Neutralization of Argument Delimiters in a Command ('Argument Injection')
Improper Neutralization of Argument Delimiters in a Command ('Argument Injection') represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.