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

High 8.1 Published Updated

Attackers can execute arbitrary code during Go builds by using line directives to bypass compiler restrictions, affecting developers using the Go toolchain.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Over the internet
Victim action needed
Not needed
Fix
Available

What is CVE-2023-39323?

CVE-2023-39323 is a high-severity code injection vulnerability in Fedoraproject Fedora, published on 5 Oct 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.

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.

Which versions are affected by CVE-2023-39323?

2 open source packages ship an affected version, including golang and toolchain. It affects 2 products.

PackageAffectedFixed in
golang BitnamiAll versions1.20.9, 1.21.2
toolchain GoAll versions1.20.9, 1.21.2
Linux distribution packages (10)
go1.20 SUSE:Linux Enterprise Module for Development Tools 15 SP4All versions1.20.9-150000.1.26.1
go1.21 SUSE:Linux Enterprise Module for Development Tools 15 SP4All versions1.21.2-150000.1.9.1
go1.20 SUSE:Linux Enterprise Module for Development Tools 15 SP5All versions1.20.9-150000.1.26.1
go1.21 SUSE:Linux Enterprise Module for Development Tools 15 SP5All versions1.21.2-150000.1.9.1
go1.20 openSUSE:Leap 15.4All versions1.20.9-150000.1.26.1
go1.21 openSUSE:Leap 15.4All versions1.21.2-150000.1.9.1
go1.20 openSUSE:Leap 15.5All versions1.20.9-150000.1.26.1
go1.21 openSUSE:Leap 15.5All versions1.21.2-150000.1.9.1
go1.20 openSUSE:TumbleweedAll versions1.20.9-1.1
go1.21 openSUSE:TumbleweedAll versions1.21.2-1.1

Products include Fedoraproject Fedora, Golang Go.

How do I fix CVE-2023-39323?

Upgrade golang to a fixed version for your release line: 1.20.9 or 1.21.2.

Upgrade, and never evaluate templates, expressions or code built from user input. More about Code injection.

Is CVE-2023-39323 being exploited?

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

All Fedoraproject Fedora vulnerabilities

Sources

Also known as AZL-31107, AZL-37358, AZL-37389, AZL-52845, AZL-78984, AZL-98871 and 11 more.

Is CVE-2023-39323 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free