Go Module Mirror served backdoor to devs for 3 years
arstechnica.com
arstechnica.com
export GOPROXY="direct"
I've had this in my ENV for a long time, primarily because I don't agree with how the Go proxy operates. For teams/organizations, as well as CI environments it also makes sense to set up an own proxy [2] and use this variable to let the toolchain use that instead.
While this wouldn't have completely prevented this incident from having an effect, I would argue that it would have at least minimized the impact.
[1]: https://github.com/mrusme/dotfiles/blob/772f09615cdcac94fec9... [2]: https://github.com/goproxy/goproxy
" Go Supply Chain Attack: Malicious Package Exploits Go Module Proxy Caching For" - https://news.ycombinator.com/item?id=42927365
a C programmer thinks twice whether to use a 3rd party library, because users will have to install it using their distro package manager. so they generally stick to what's commonly available there or write their own 20 lines for micro-tasks. one of the benefits that come along with that is that these distro packages are usually well vetted.
You update a dependency to version x and check its code to ensure it's safe. Then the threat actor adds malware to that library you're depending on, and makes the old tag x point to the malicious commit. Yor coworker does "go get" to download dependencies and gets the malware.
One solution (on dev side) is to vendor, which Go has native support for. Another (on Go side) is to show a warning on hash mismatch.