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

> Attackers can inject environment variables on Windows via unsanitized NUL bytes in Go's os/exec and syscall packages.

- **Severity:** Medium 6.3 (`CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 2 Nov 2022
- **Updated:** 30 Oct 2024
- **Also known as:** AZL-79026, AZL-98883, BIT-golang-2022-41716, DEBIAN-CVE-2022-41716, GHSA-mh68-qf2j-8c5g, GO-2022-1095, MGASA-2022-0444, OESA-2022-2115, SUSE-SU-2022:4054-1, SUSE-SU-2022:4055-1, UBUNTU-CVE-2022-41716, openSUSE-SU-2024:12471-1, openSUSE-SU-2024:12472-1

## What is CVE-2022-41716?

CVE-2022-41716 is a medium-severity vulnerability in Golang Go, published on 2 Nov 2022. Any signed-in user can exploit it over the network, with no action from the victim.

### Official description

Due to unsanitized NUL values, attackers may be able to maliciously set environment variables on Windows. In syscall.StartProcess and os/exec.Cmd, invalid environment variable values containing NUL values are not properly checked for. A malicious environment variable value can exploit this behavior to set a value for a different environment variable. For example, the environment variable string "A=B\x00C=D" sets the variables "A=B" and "C=D".

## Which versions are affected by CVE-2022-41716?

2 open source packages ship an affected version, including golang and stdlib. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `golang` | Bitnami | All versions | 1.18.8, 1.19.3 |
| `stdlib` | Go | All versions | 1.18.8, 1.19.3 |
| `go1.18` | SUSE:Linux Enterprise Module for Development Tools 15 SP3 | All versions | 1.18.8-150000.1.37.1 |
| `go1.19` | SUSE:Linux Enterprise Module for Development Tools 15 SP3 | All versions | 1.19.3-150000.1.15.1 |
| `go1.18` | SUSE:Linux Enterprise Module for Development Tools 15 SP4 | All versions | 1.18.8-150000.1.37.1 |
| `go1.19` | SUSE:Linux Enterprise Module for Development Tools 15 SP4 | All versions | 1.19.3-150000.1.15.1 |
| `go1.18` | openSUSE:Leap 15.3 | All versions | 1.18.8-150000.1.37.1 |
| `go1.19` | openSUSE:Leap 15.3 | All versions | 1.19.3-150000.1.15.1 |
| `go1.18` | openSUSE:Leap 15.4 | All versions | 1.18.8-150000.1.37.1 |
| `go1.19` | openSUSE:Leap 15.4 | All versions | 1.19.3-150000.1.15.1 |
| `go1.18` | openSUSE:Tumbleweed | All versions | 1.18.8-1.1 |
| `go1.19` | openSUSE:Tumbleweed | All versions | 1.19.3-1.1 |

Products: Golang Go.

## How do I fix CVE-2022-41716?

Upgrade golang to a fixed version for your release line: 1.18.8 or 1.19.3.

## Is CVE-2022-41716 being exploited?

There is no known exploitation of CVE-2022-41716 in the wild and no public exploit code.

## Other vulnerabilities in Golang Go

- [CVE-2020-0601](https://insights.sbomify.com/CVE-2020-0601/): Microsoft Windows CryptoAPI Spoofing (high 8.1, exploited in the wild)
- [CVE-2026-27143](https://insights.sbomify.com/CVE-2026-27143/): Missing bound checks can lead to memory corruption in safe Go in cmd/compile (critical 9.8)
- [CVE-2024-24790](https://insights.sbomify.com/CVE-2024-24790/): Unexpected behavior from Is methods for IPv4-mapped IPv6 addresses in net/netip (critical 9.8)
- [CVE-2023-39320](https://insights.sbomify.com/CVE-2023-39320/): Arbitrary code execution via go.mod toolchain directive in cmd/go (critical 9.8)
- [CVE-2023-24540](https://insights.sbomify.com/CVE-2023-24540/): Improper handling of JavaScript whitespace in html/template (critical 9.8)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2022-41716 and fix it if it is affected.

What it is: CVE-2022-41716 is a medium-severity vulnerability in Golang Go, published on 2 Nov 2022. Any signed-in user can exploit it over the network, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2022-41716 in the wild and no public exploit code.

Affected packages and fixed versions:
- golang (Bitnami): affected all versions; fixed in 1.18.8, 1.19.3
- stdlib (Go): affected all versions; fixed in 1.18.8, 1.19.3

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2022-41716/ (Markdown: https://insights.sbomify.com/CVE-2022-41716/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2022-41716
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2022-41716
- OSV: https://osv.dev/vulnerability/CVE-2022-41716

---
From sbomify Insights: https://insights.sbomify.com/CVE-2022-41716/
Summaries are generated and may contain mistakes; the official description above is the record.
