CVE-2022-41716: Unsanitized NUL in environment variables on Windows in syscall and os/exec

stdlib Updated 02 Oct 2025

Summary

01/11/2022
Yes i
Unrated
Not published

CVE-2022-41716: Unsanitized NUL in environment variables on Windows in syscall and os/exec. Affects stdlib across 2 version ranges.

< 1.18.8 >= 1.19.0-0, < 1.19.3

Fixed in 1.18.8 or 1.19.3, depending on the release line you run. How to fix ↓

Also tracked for

The same CVE-2022-41716 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.

Free scan

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.

Check my app free

No signup required · Results in about 60 seconds

Sponsored Devnack Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

The Go standard library (stdlib) is a collection of packages that provide essential functionality for Go programs. It includes the syscall and os/exec packages, which are responsible for system calls and executing external commands, respectively. These packages are widely used in Go applications running on Windows operating systems.

Vulnerability Detail

The vulnerability (CVE-2022-41716) arises from the mishandling of NUL values in environment variables on Windows. In the syscall.StartProcess and os/exec.Cmd functions, there is a lack of proper validation for invalid environment variable values containing NUL values. This oversight allows attackers to set malicious values for environment variables, potentially leading to unauthorized access or privilege escalation. For instance, an attacker can exploit this vulnerability by setting a value for a different environment variable using a crafted environment variable string like "A=B\x00C=D".

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.18.8 1.18.8
    go get stdlib@v1.18.8
  • >= 1.19.0-0, < 1.19.3 1.19.3
    go get stdlib@v1.19.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 temporary workaround, developers can manually sanitize environment variable values to remove any NUL characters before passing them to the syscall.StartProcess or os/exec.Cmd functions. Here is an example of how to sanitize an environment variable value in Go:

func sanitizeEnvValue(value string) string {
    return strings.ReplaceAll(value, "\x00", "")
}

Conclusion

In conclusion, the CVE-2022-41716 vulnerability in the Go standard library exposes Windows systems to potential attacks through unsanitized NUL values in environment variables. Developers should update their Go installations to the recommended versions and regularly apply updates to ensure the security of their applications. For further assistance or support in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for stdlib →

Share this vulnerability

FAQ

This vulnerability allows attackers to set malicious values for environment variables on Windows systems. Depending on the context in which these variables are used, the impact can range from unauthorized access to privilege escalation.

Versions 0.0.0 to 1.18.7 and versions 1.19.0-0 to 1.19.2 of the Go standard library (stdlib) are affected by this vulnerability.

No, this vulnerability only affects Windows systems.

At the time of this report, there are no known public exploits for this vulnerability. However, it is advisable to apply the recommended fixes as soon as possible to mitigate any potential risks.

You can use the Vulert Playground (https://vulert.com/scanner) to check if your application is affected by this vulnerability. Simply upload your Gopkg.lock file to the playground, and it will analyze your dependencies and alert you if any of them are vulnerable.

Related vulnerabilities

Recent vulnerabilities recorded for stdlib.

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.18.8 1.18.8
    go get stdlib@v1.18.8
  • >= 1.19.0-0, < 1.19.3 1.19.3
    go get stdlib@v1.19.3

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback