Lucene search

K
osvGoogleOSV:GO-2022-0201
HistoryAug 09, 2022 - 6:15 p.m.

Remote command execution via "go get" command with cgo in cmd/go

2022-08-0918:15:41
Google
osv.dev
7

7.7 High

AI Score

Confidence

High

0.016 Low

EPSS

Percentile

87.5%

The “go get” command with cgo is vulnerable to remote command execution by leveraging the gcc or clang plugin feature.

When cgo is enabled, the build step during “go get” invokes the host C compiler, gcc or clang, adding compiler flags specified in the Go source files. Both gcc and clang support a plugin mechanism in which a shared-library plugin is loaded into the compiler, as directed by compiler flags. This means that a Go package repository can contain an attack.so file along with a Go source file that says (for example) “// #cgo CFLAGS: -fplugin=attack.so” causing the attack plugin to be loaded into the host C compiler during the build. Gcc and clang plugins are completely unrestricted in their access to the host system.