Unsafe cgo compiler flags
A malicious cgo package can use compiler or linker flags such as --sysroot or -target to execute code during the build.
Go 1.27.4 and 1.26.11 fix 12 vulnerabilities. Malicious build inputs can trigger code execution. A separate race can crash HTTP/1 servers whose handlers use MaxBytesReader or MaxBytesHandler and concurrently read the body and write response headers.
Go released 1.27.4 and 1.26.11 on November 10. Eleven fixes address build inputs such as cgo directives, native objects and compiler or linker arguments. Several flaws can execute code as the build user when it builds a malicious package. The path depends on the input and toolchain. Examples include GCC spec files, Apple linker plugins and crafted .syso objects. Review CI jobs that compile untrusted contributions or newly introduced dependencies and can access credentials or publishing permissions.
The separate net/http flaw affects HTTP/1 handlers using MaxBytesReader or MaxBytesHandler. When the request body exceeds the limit, reading it concurrently with writing response headers can cause a panic that crashes the server. Upgrade the toolchain used to produce deployed binaries and rebuild affected services. Updating the build machine alone leaves existing binaries unchanged.
A malicious cgo package can use compiler or linker flags such as --sysroot or -target to execute code during the build.
With GCC, a malicious cgo package can make certain linker options load a package-controlled specs file and execute commands.
A malicious cgo package can abuse Clang -gen-* or GCC -gnat* flags to execute code or write files to arbitrary directories.
On Darwin, a malicious cgo package can make the Apple linker combine -l and to_library to load a package-chosen plugin.
Split -Wl, arguments and certain options accepted by GNU ld.bfd can let a malicious cgo package supply linker scripts that execute code.
Crafted .syso files or cgo linker inputs can inject flags or execute code at link time.
A malicious package using #cgo pkg-config: directives can load untrusted .pc files or pass unchecked compiler and linker flags.
A package can disguise a Go object as a .syso file to inject cgo linker directives.
Crafted //go:cgo_* directives in a malicious package can inject arbitrary flags into the external linker on ELF platforms.
A malicious package can pass unsafe library arguments through //go:cgo_import_dynamic or through a crafted PE object on Windows.
A malicious cgo package can use escaped quotes in //go:cgo_ldflag to execute code during the build or cause the go command to panic.
An HTTP/1 server using MaxBytesReader or MaxBytesHandler may crash when the body exceeds the limit and the handler reads it concurrently with writing response headers.
Run go version on each box, then type the version or pick the closest match.
| Branch | Safe from | Status |
|---|---|---|
| Go 1.27 | 1.27.4 | Supported |
| Go 1.26 | 1.26.11 | Supported |
| Older Go releases | none | Upgrade to a supported branch |
Nov 10, 17:14 UTC
Go publishes 1.27.4 and 1.26.11
The announcement details 11 toolchain fixes and one net/http fix.
Nov 11, 02:51 UTC
Go publishes the vulnerability records
The 12 records give affected ranges and the two fixed versions.
We list each claim and who made it. Primary sources (the vendor, the researcher, the registry) are marked. Where reports disagree, we grade by the worst credible case.