Vulnerability · Published Oct 5, 2023 · Assigned by Go

CVE-2023-39323Arbitrary code execution during build via line directives in cmd/go

High 8.1

In plain English

A high-severity security flaw in cmd/go from Go toolchain. There are no confirmed reports of exploitation so far. The chance it is exploited in the next 30 days is estimated at 1.9% (higher than 80% of all known vulnerabilities). Fixed versions are available - upgrade the affected package.

Severity (CVSS 3.1)8.1High
Exploit odds (30 days)1.9%top 20.1% of all CVEs
Exploited in the wildNo reportsCISA SSVC: none
Attack toolingNoneno public tooling known

Official description

Line directives ("//line") can be used to bypass the restrictions on "//go:cgo_" directives, allowing blocked linker and compiler flags to be passed during compilation. This can result in unexpected execution of arbitrary code when running "go build". The line directive requires the absolute path of the file in which the directive lives, which makes exploiting this issue significantly more complex.

Affected packages & fixed versions

EcosystemPackageFixed inAdvisory
Alpine:v3.20go1.21.2-r0ALPINE-CVE-2023-39323
Alpine:v3.21go1.21.2-r0ALPINE-CVE-2023-39323
Alpine:v3.22go1.21.2-r0ALPINE-CVE-2023-39323
Alpine:v3.23go1.21.2-r0ALPINE-CVE-2023-39323
Alpine:v3.24go1.21.2-r0ALPINE-CVE-2023-39323
Debian:12golang-1.19no fix listedDEBIAN-CVE-2023-39323
Gotoolchain1.20.9, 1.21.2GO-2023-2095
Ubuntu:22.04:LTSgolang-1.171.17.13-3ubuntu1.3USN-7111-1
Ubuntu:22.04:LTSgolang-1.171.17.13-3ubuntu1.3UBUNTU-CVE-2023-39323
Ubuntu:22.04:LTSgolang-1.181.18.1-1ubuntu1.2USN-7109-1
Ubuntu:22.04:LTSgolang-1.181.18.1-1ubuntu1.2UBUNTU-CVE-2023-39323
Ubuntu:22.04:LTSgolang-1.201.20.3-1ubuntu0.1~22.04.1USN-6574-1
Ubuntu:22.04:LTSgolang-1.201.20.3-1ubuntu0.1~22.04.1UBUNTU-CVE-2023-39323
Ubuntu:22.04:LTSgolang-1.211.21.1-1~ubuntu22.04.2UBUNTU-CVE-2023-39323
Ubuntu:22.04:LTSgolang-1.211.21.1-1~ubuntu22.04.2USN-6574-1

Affected products (as reported)

VendorProductVersions
Go toolchain cmd/go 0 – before 1.20.91.21.0-0 – before 1.21.2

References