CVE-2022-30580: Empty Cmd.Path can trigger unintended binary in os/exec on Windows
Summary
CVE-2022-30580: Empty Cmd.Path can trigger unintended binary in os/exec on Windows. Affects stdlib across 2 version ranges.
< 1.17.11
>= 1.18.0-0, < 1.18.3
Fixed in 1.17.11 or 1.18.3, depending on the release line you run. How to fix ↓
Also tracked for
The same CVE-2022-30580 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
The stdlib package in the Go ecosystem provides a set of standard libraries for the Go programming language. One of the packages in stdlib is os/exec, which allows the execution of external commands. This vulnerability affects the os/exec package on Windows systems. The package provides functionality to run commands and retrieve their output, but when the Cmd.Path is unset, it can unintentionally execute binaries in the working directory named either "..com" or "..exe".
Vulnerability Detail
The vulnerability arises when using the Cmd.Run, Cmd.Start, Cmd.Output, or Cmd.CombinedOutput functions in the os/exec package on Windows. If the Cmd.Path is not set, it will default to an empty value. This can lead to unintended execution of binaries in the working directory that have names ending in ".com" or ".exe". An attacker could place a malicious binary with such a name in the working directory and trick the application into executing it. This could result in arbitrary code execution with the privileges of the application.
How To Fix
Latest published version: go1.25.5 as of 22 Oct 2026
go get stdlib@vgo1.25.5
Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.
If you can't move to the latest
The minimum fixed version depends on the release line you run.
-
< 1.17.111.17.11go get stdlib@v1.17.11 -
>= 1.18.0-0, < 1.18.31.18.3go get stdlib@v1.18.3
Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →
Workaround
As a workaround, developers can explicitly set the Cmd.Path to a valid executable path before calling the affected functions. By ensuring that the Cmd.Path is always set to a trusted and expected value, the vulnerability can be mitigated. Here is an example of how to set the Cmd.Path:
package main
import (
"os/exec"
"fmt"
)
func main() {
cmd := exec.Command("C:\\path\\to\\executable.exe")
// Rest of the code
}
Conclusion
The CVE-2022-30580 vulnerability in the Go stdlib package's os/exec package on Windows systems allows unintended execution of binaries in the working directory. This can result in arbitrary code execution with the application's privileges. It is crucial to update the Go stdlib package to versions 1.17.11 or 1.18.3 to mitigate this vulnerability. Alternatively, developers can set the Cmd.Path explicitly to a trusted executable path as a temporary workaround. For further assistance with vulnerability remediation, contact DevNack.com.
See every vulnerability recorded for stdlib →
FAQ
This vulnerability can lead to arbitrary code execution with the privileges of the application. An attacker could place a malicious binary in the working directory and trick the application into executing it.
Versions 0.0.0 to 1.17.10 and 1.18.0-0 to 1.18.2 of the Go stdlib package are affected.
No, this vulnerability only affects Windows systems.
Yes, updating the Go stdlib package to version 1.17.11 or 1.18.3 will fix this vulnerability.
As a temporary workaround, you can explicitly set the Cmd.Path to a valid executable path before calling the affected functions.
References
Related vulnerabilities
Recent vulnerabilities recorded for stdlib.