Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: packages using cgo can cause arbitrary code execution on Windows [Go 1.15] #43785

Closed
rolandshoemaker opened this issue Jan 19, 2021 · 2 comments
Labels
CherryPickApproved Used during the release process for point releases FrozenDueToAge Security
Milestone

Comments

@rolandshoemaker
Copy link
Member

The go command may execute arbitrary code at build time when using cgo on Windows. This can be triggered by running go get for a malicious package, or any other time the code is built.

This can be triggered by malicious packages which contain specifically named binaries which are executed when cgo is executed in the context of the malicious package directory. This is due to the path lookup behavior of os/exec.LookPath on Windows.

This will also affect Unix users who have “.” listed explicitly in their PATH and are running “go get” outside of a module or with module mode disabled.

This has been fixed by altering the usage of os/exec.LookPath by the go command to reject the usage of any binaries that reside in the current directory. If you are interested in understanding whether your own programs have a problem, we’ve written a blog post about the underlying issue: https://blog.golang.org/path-security.

Thanks to RyotaK (https://twitter.com/ryotkak) for reporting this issue.

This issue is CVE-2021-3115.

@rolandshoemaker rolandshoemaker added Security CherryPickApproved Used during the release process for point releases labels Jan 19, 2021
@rolandshoemaker rolandshoemaker added this to the Go1.15.7 milestone Jan 19, 2021
@rolandshoemaker
Copy link
Member Author

Fixed by e8e7fac and 07e3195.

@Foxboron
Copy link
Contributor

Foxboron commented Jan 19, 2021

Is it intentional that the commits reference an unknown security branch? The commits are not present on the actual release branch.

EDIT: Branch has been pushed.

@golang golang locked and limited conversation to collaborators Jan 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CherryPickApproved Used during the release process for point releases FrozenDueToAge Security
Projects
None yet
Development

No branches or pull requests

3 participants