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 misuse a cgo build directive to make pkg-config write partially controlled content to an attacker-chosen file. Exploitation requires someone or an automated build system to build the malicious source. Successful abuse could compromise sensitive files and the broader build environment.
Executive priority
Treat this as a high-priority build-chain issue where teams compile third-party or untrusted Go code. Prioritize shared CI infrastructure and privileged build systems because an attacker-controlled file write could affect other workloads, credentials, or produced artifacts. Internet-facing emergency treatment is not supported by the supplied evidence.
Technical view
CVE-2025-61731 is command-line argument injection in cmd/go’s handling of “#cgo pkg-config:” directives. An attacker can supply a “--log-file” argument, directing pkg-config to write partially controlled content to an attacker-selected path. The supplied CVSS 3.1 score is 8.6, with CWE-78 and CWE-88 classifications.
Likely exposure
Exposure is concentrated in developer workstations, CI runners, build containers, and services that compile untrusted or newly introduced Go source using cgo and pkg-config. Systems that do not build such source are less likely to be directly exposed. The supplied version data does not clearly define the complete affected range.
Exploitation context
The vulnerability requires a malicious file to be built, so it is not described as direct remote exploitation. KEV is false, and the supplied sources provide no evidence of active exploitation in the wild.
Researcher notes
The core primitive is argument injection from a cgo directive into pkg-config, producing an arbitrary-path write with only partial content control. The structured affected entry lists versions “0” and “1.25.0” while stating a default status of unaffected; therefore, confirm the precise vulnerable and fixed version boundaries through the official advisories.
Mitigation direction
Apply the Go toolchain update identified by official Go guidance; the supplied bundle does not state the fixed version.
Apply applicable Red Hat errata to Red Hat-managed build hosts and images.
Until remediated, avoid building untrusted Go source that uses cgo pkg-config directives.
Run builds with least privilege and isolate writable paths from sensitive host locations.
Validation and detection
Inventory Go toolchain versions across developer workstations, CI runners, build containers, and ephemeral build environments.
Compare each version and operating-system package against the official Go advisory and applicable vendor errata.
Review repositories and dependencies for cgo pkg-config directives, prioritizing code from untrusted or newly introduced sources.
Investigate unexpected file writes associated with Go builds or pkg-config execution.
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.