]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.21] cmd/go: disallow -lto_library in LDFLAGS
authorRoland Shoemaker <bracewell@google.com>
Thu, 25 Apr 2024 20:09:54 +0000 (13:09 -0700)
committerCherry Mui <cherryyz@google.com>
Tue, 7 May 2024 15:23:16 +0000 (15:23 +0000)
commita79ea27e36a1c56ae48dc36ce48549c9787ca4b7
treeedbb1f16f0d7cc8aa71316c17ab5c9f689497672
parent78d89b2b67e26f1e56357f37cdaefe5a2207b4d3
[release-branch.go1.21] cmd/go: disallow -lto_library in LDFLAGS

The darwin linker allows setting the LTO library with the -lto_library
flag. This wasn't caught by our "safe linker flags" check because it
was covered by the -lx flag used for linking libraries. This change
adds a specific check for excluded flags which otherwise satisfy our
existing checks.

Loading a mallicious LTO library would allow an attacker to cause the
linker to execute abritrary code when "go build" was called.

Thanks to Juho Forsén of Mattermost for reporting this issue.

Fixes #67119
Fixes #67121
Fixes CVE-2024-24787

Change-Id: I77ac8585efbdbdfd5f39c39ed623b9408a0f9eaf
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/1380
Reviewed-by: Russ Cox <rsc@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
(cherry picked from commit 9a79141fbbca1105e5c786f15e38741ca7843290)
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/1401
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/583795
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
src/cmd/go/internal/work/security.go
src/cmd/go/testdata/script/darwin_lto_library_ldflag.txt [new file with mode: 0644]