GO-2023-2095

Arbitrary code execution during build via line directives in cmd/go

At a glance

Published
Updated
CVE
CVE-2023-39323
Aliases
BIT-golang-2023-39323

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

PackageVersions
Go · toolchainintroduced 0, fixed 1.20.9, introduced 1.21.0-0, fixed 1.21.2

References

Sources

SourceLicence
OSV.devCC-BY 4.0 — Go Vulnerability Database