Advisory

GO-2022-0201

Also known as: CVE-2018-6574

Summary

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

Details

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.

Severity

Not rated by the source.

Dates

Published
2022-08-09 18:15 UTC
Modified
2024-05-20 16:03 UTC

Affected packages and fixes

toolchain

Go · All systems

Affected

  • introduced 0, fixed 1.8.7, introduced 1.9.0-0, fixed 1.9.4 (semver)

Fixed versions

1.8.7, 1.9.4

Fix

The export has no generic command for this ecosystem.

Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.

Check your own computer: guard packages check

View this record on OSV.dev

Source

Source: Go Vulnerability Database · CC BY 4.0

Sources & licences