mirror of
https://git.yoctoproject.org/poky
synced 2026-01-29 21:08:42 +01:00
go: fix CVE-2023-29404
The go command may execute arbitrary code at build time when using cgo.
This may occur when running "go get" on a malicious module, or when running
any other command which builds untrusted code. This is can by triggered by
linker flags, specified via a "#cgo LDFLAGS" directive. The arguments for a
number of flags which are non-optional are incorrectly considered optional,
allowing disallowed flags to be smuggled through the LDFLAGS sanitization.
This affects usage of both the gc and gccgo compilers.
References:
https://nvd.nist.gov/vuln/detail/CVE-2023-29404
Upstream patches:
bbeb55f5fa
(From OE-Core rev: 3e51122f8e2b4a7cd2a1c711175e6daf59b8368b)
Signed-off-by: Archana Polampalli <archana.polampalli@windriver.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
This commit is contained in:
committed by
Steve Sakoman
parent
fc697fe874
commit
19cce6f246
@@ -32,6 +32,7 @@ SRC_URI += "\
|
||||
file://CVE-2023-24538.patch \
|
||||
file://CVE-2023-24540.patch \
|
||||
file://CVE-2023-24539.patch \
|
||||
file://CVE-2023-29404.patch \
|
||||
"
|
||||
SRC_URI[main.sha256sum] = "a1a48b23afb206f95e7bbaa9b898d965f90826f6f1d1fc0c1d784ada0cd300fd"
|
||||
|
||||
|
||||
78
meta/recipes-devtools/go/go-1.19/CVE-2023-29404.patch
Normal file
78
meta/recipes-devtools/go/go-1.19/CVE-2023-29404.patch
Normal file
@@ -0,0 +1,78 @@
|
||||
From bbeb55f5faf93659e1cfd6ab073ab3c9d126d195 Mon Sep 17 00:00:00 2001
|
||||
From: Roland Shoemaker <bracewell@google.com>
|
||||
Date: Fri, 5 May 2023 13:10:34 -0700
|
||||
Subject: [PATCH] cmd/go: enforce flags with non-optional arguments
|
||||
|
||||
Enforce that linker flags which expect arguments get them, otherwise it
|
||||
may be possible to smuggle unexpected flags through as the linker can
|
||||
consume what looks like a flag as an argument to a preceding flag (i.e.
|
||||
"-Wl,-O -Wl,-R,-bad-flag" is interpreted as "-O=-R -bad-flag"). Also be
|
||||
somewhat more restrictive in the general format of some flags.
|
||||
|
||||
Thanks to Juho Nurminen of Mattermost for reporting this issue.
|
||||
|
||||
Fixes #60305
|
||||
Fixes CVE-2023-29404
|
||||
|
||||
Change-Id: I913df78a692cee390deefc3cd7d8f5b031524fc9
|
||||
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1876275
|
||||
Reviewed-by: Ian Lance Taylor <iant@google.com>
|
||||
Reviewed-by: Damien Neil <dneil@google.com>
|
||||
Reviewed-on: https://go-review.googlesource.com/c/go/+/501225
|
||||
Run-TryBot: David Chase <drchase@google.com>
|
||||
Reviewed-by: Michael Knyszek <mknyszek@google.com>
|
||||
TryBot-Result: Gopher Robot <gobot@golang.org>
|
||||
|
||||
Upstream-Status: Backport [https://github.com/golang/go/commit/bbeb55f5faf93659e1cfd6ab073ab3c9d126d195]
|
||||
CVE: CVE-2023-29404
|
||||
|
||||
Signed-off-by: Archana Polampalli <archana.polampalli@windriver.com>
|
||||
---
|
||||
src/cmd/go/internal/work/security.go | 6 +++---
|
||||
src/cmd/go/internal/work/security_test.go | 5 +++++
|
||||
2 files changed, 8 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/cmd/go/internal/work/security.go b/src/cmd/go/internal/work/security.go
|
||||
index e9b9f6c..91e6e4c 100644
|
||||
--- a/src/cmd/go/internal/work/security.go
|
||||
+++ b/src/cmd/go/internal/work/security.go
|
||||
@@ -179,10 +179,10 @@ var validLinkerFlags = []*lazyregexp.Regexp{
|
||||
re(`-Wl,-berok`),
|
||||
re(`-Wl,-Bstatic`),
|
||||
re(`-Wl,-Bsymbolic-functions`),
|
||||
- re(`-Wl,-O([^@,\-][^,]*)?`),
|
||||
+ re(`-Wl,-O[0-9]+`),
|
||||
re(`-Wl,-d[ny]`),
|
||||
re(`-Wl,--disable-new-dtags`),
|
||||
- re(`-Wl,-e[=,][a-zA-Z0-9]*`),
|
||||
+ re(`-Wl,-e[=,][a-zA-Z0-9]+`),
|
||||
re(`-Wl,--enable-new-dtags`),
|
||||
re(`-Wl,--end-group`),
|
||||
re(`-Wl,--(no-)?export-dynamic`),
|
||||
@@ -191,7 +191,7 @@ var validLinkerFlags = []*lazyregexp.Regexp{
|
||||
re(`-Wl,--hash-style=(sysv|gnu|both)`),
|
||||
re(`-Wl,-headerpad_max_install_names`),
|
||||
re(`-Wl,--no-undefined`),
|
||||
- re(`-Wl,-R([^@\-][^,@]*$)`),
|
||||
+ re(`-Wl,-R,?([^@\-,][^,@]*$)`),
|
||||
re(`-Wl,--just-symbols[=,]([^,@\-][^,@]+)`),
|
||||
re(`-Wl,-rpath(-link)?[=,]([^,@\-][^,]+)`),
|
||||
re(`-Wl,-s`),
|
||||
diff --git a/src/cmd/go/internal/work/security_test.go b/src/cmd/go/internal/work/security_test.go
|
||||
index 8d4be0a..3616548 100644
|
||||
--- a/src/cmd/go/internal/work/security_test.go
|
||||
+++ b/src/cmd/go/internal/work/security_test.go
|
||||
@@ -227,6 +227,11 @@ var badLinkerFlags = [][]string{
|
||||
{"-Wl,-R,@foo"},
|
||||
{"-Wl,--just-symbols,@foo"},
|
||||
{"../x.o"},
|
||||
+ {"-Wl,-R,"},
|
||||
+ {"-Wl,-O"},
|
||||
+ {"-Wl,-e="},
|
||||
+ {"-Wl,-e,"},
|
||||
+ {"-Wl,-R,-flag"},
|
||||
}
|
||||
|
||||
func TestCheckLinkerFlags(t *testing.T) {
|
||||
--
|
||||
2.40.0
|
||||
Reference in New Issue
Block a user