-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: allow flags in CGO_LDFLAGS environment variable not in security allowlist #42565
Comments
@gopherbot Please open backport issues. This is a usability regression introduced by the security fix for #42556. The security fix was applied to all release branches, and we should follow up with a fix for this usability regression. |
Backport issue(s) opened: #42566 (for 1.14), #42567 (for 1.15). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases. |
Change https://golang.org/cl/269818 mentions this issue: |
It's a bit more then that though. In Arch Linux we utilize |
It also broke (so far) tinygo build on FreeBSD: |
I used the patch from the change set on our go compiler, and it works on our end. |
Change https://golang.org/cl/270137 mentions this issue: |
Change https://golang.org/cl/270080 mentions this issue: |
I apologize for this problem. It was caused by a patch to fix a security problem. Because that patch could not be shared before the fix, it was not widely tested. Please don't comment just to say that the problem affects you too. See https://golang.org/wiki/NoPlusOne. Thanks. This will be fixed in the next release. Until then, the workaround, as mentioned in the original issue report, is to copy Again, sorry for the problem. |
…ldflag For #42565 Fixes #42567 Change-Id: If7cf39905d124dbd54dfac6a53ee38270498efed Reviewed-on: https://go-review.googlesource.com/c/go/+/269818 Trust: Ian Lance Taylor <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Jay Conrod <[email protected]> (cherry picked from commit 782cf56) Reviewed-on: https://go-review.googlesource.com/c/go/+/270137
…ldflag For #42565 Fixes #42566 Change-Id: If7cf39905d124dbd54dfac6a53ee38270498efed Reviewed-on: https://go-review.googlesource.com/c/go/+/269818 Trust: Ian Lance Taylor <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Jay Conrod <[email protected]> (cherry picked from commit 782cf56) Reviewed-on: https://go-review.googlesource.com/c/go/+/270080
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
What did you expect to see?
Build succeeds, embedding the specified flags as
//go:cgo_ldflag
pragmas in compiled packages.What did you see instead?
Build fails with:
I believe this is an unintentional side effect of 3215982, the fix for #42558.
Previously, the security check was applied to flags in
#cgo LDFLAGS
directives in source files. That prevents malicious source files from executing arbitrary code.With the commit above, we now apply the security check to all
//go:cgo_ldflag
pragmas in generated cgo code, in case there's a way for the original source code to cause such a comment to appear in generated code.However, the
CGO_LDFLAGS
environment variable causes//go:cgo_ldflag
pragmas to be written in generated cgo code. The user has complete control over flags in that environment variable, so they should not be subject to the security check.A workaround is to set
CGO_ALLOW_LDFLAGS
to a regular expression that covers everything inCGO_LDFLAGS
.The text was updated successfully, but these errors were encountered: