summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSoumya Sambu <soumya.sambu@windriver.com>2024-08-01 04:55:33 +0000
committerSteve Sakoman <steve@sakoman.com>2024-08-08 09:03:45 -0700
commit7506cbff40f07ae937758a5fbf872ce751e8c3ba (patch)
tree9a497832d1eb2fba464839140bfa2e38e6360771
parentae4a66db4bd23f3b6ee71ff27986a6a3d2b84f66 (diff)
downloadpoky-7506cbff40f07ae937758a5fbf872ce751e8c3ba.tar.gz
go: Fix CVE-2024-24789
The archive/zip package's handling of certain types of invalid zip files differs from the behavior of most zip implementations. This misalignment could be exploited to create an zip file with contents that vary depending on the implementation reading the file. The archive/zip package now rejects files containing these errors. References: https://nvd.nist.gov/vuln/detail/CVE-2024-24789 Upstream-patch: https://github.com/golang/go/commit/c8e40338cf00f3c1d86c8fb23863ad67a4c72bcc (From OE-Core rev: f198fdc392c6e3b99431383ab6577749e83f1cb3) Signed-off-by: Soumya Sambu <soumya.sambu@windriver.com> Signed-off-by: Steve Sakoman <steve@sakoman.com>
-rw-r--r--meta/recipes-devtools/go/go-1.17.13.inc1
-rw-r--r--meta/recipes-devtools/go/go-1.21/CVE-2024-24789.patch78
2 files changed, 79 insertions, 0 deletions
diff --git a/meta/recipes-devtools/go/go-1.17.13.inc b/meta/recipes-devtools/go/go-1.17.13.inc
index 95fb572362..e83c4dfa80 100644
--- a/meta/recipes-devtools/go/go-1.17.13.inc
+++ b/meta/recipes-devtools/go/go-1.17.13.inc
@@ -56,6 +56,7 @@ SRC_URI += "\
56 file://CVE-2024-24784.patch \ 56 file://CVE-2024-24784.patch \
57 file://CVE-2024-24785.patch \ 57 file://CVE-2024-24785.patch \
58 file://CVE-2023-45288.patch \ 58 file://CVE-2023-45288.patch \
59 file://CVE-2024-24789.patch \
59" 60"
60SRC_URI[main.sha256sum] = "a1a48b23afb206f95e7bbaa9b898d965f90826f6f1d1fc0c1d784ada0cd300fd" 61SRC_URI[main.sha256sum] = "a1a48b23afb206f95e7bbaa9b898d965f90826f6f1d1fc0c1d784ada0cd300fd"
61 62
diff --git a/meta/recipes-devtools/go/go-1.21/CVE-2024-24789.patch b/meta/recipes-devtools/go/go-1.21/CVE-2024-24789.patch
new file mode 100644
index 0000000000..2679109a0e
--- /dev/null
+++ b/meta/recipes-devtools/go/go-1.21/CVE-2024-24789.patch
@@ -0,0 +1,78 @@
1From c8e40338cf00f3c1d86c8fb23863ad67a4c72bcc Mon Sep 17 00:00:00 2001
2From: Damien Neil <dneil@google.com>
3Date: Tue, 14 May 2024 14:39:10 -0700
4Subject: [PATCH] [release-branch.go1.21] archive/zip: treat truncated EOCDR
5 comment as an error
6
7When scanning for an end of central directory record,
8treat an EOCDR signature with a record containing a truncated
9comment as an error. Previously, we would skip over the invalid
10record and look for another one. Other implementations do not
11do this (they either consider this a hard error, or just ignore
12the truncated comment). This parser misalignment allowed
13presenting entirely different archive contents to Go programs
14and other zip decoders.
15
16For #66869
17Fixes #67553
18
19Change-Id: I94e5cb028534bb5704588b8af27f1e22ea49c7c6
20Reviewed-on: https://go-review.googlesource.com/c/go/+/585397
21Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
22Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
23LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
24(cherry picked from commit 33d725e5758bf1fea62e6c77fc70b57a828a49f5)
25Reviewed-on: https://go-review.googlesource.com/c/go/+/588795
26Reviewed-by: Matthew Dempsky <mdempsky@google.com>
27
28CVE: CVE-2024-24789
29
30Upstream-Status: Backport [https://github.com/golang/go/commit/c8e40338cf00f3c1d86c8fb23863ad67a4c72bcc]
31
32Signed-off-by: Soumya Sambu <soumya.sambu@windriver.com>
33---
34 src/archive/zip/reader.go | 8 ++++++--
35 src/archive/zip/reader_test.go | 8 ++++++++
36 2 files changed, 14 insertions(+), 2 deletions(-)
37
38diff --git a/src/archive/zip/reader.go b/src/archive/zip/reader.go
39index e40a2c6..987f543 100644
40--- a/src/archive/zip/reader.go
41+++ b/src/archive/zip/reader.go
42@@ -644,9 +644,13 @@ func findSignatureInBlock(b []byte) int {
43 if b[i] == 'P' && b[i+1] == 'K' && b[i+2] == 0x05 && b[i+3] == 0x06 {
44 // n is length of comment
45 n := int(b[i+directoryEndLen-2]) | int(b[i+directoryEndLen-1])<<8
46- if n+directoryEndLen+i <= len(b) {
47- return i
48+ if n+directoryEndLen+i > len(b) {
49+ // Truncated comment.
50+ // Some parsers (such as Info-ZIP) ignore the truncated comment
51+ // rather than treating it as a hard error.
52+ return -1
53 }
54+ return i
55 }
56 }
57 return -1
58diff --git a/src/archive/zip/reader_test.go b/src/archive/zip/reader_test.go
59index a549153..7ac394d 100644
60--- a/src/archive/zip/reader_test.go
61+++ b/src/archive/zip/reader_test.go
62@@ -487,6 +487,14 @@ var tests = []ZipTest{
63 },
64 },
65 },
66+ // Issue 66869: Don't skip over an EOCDR with a truncated comment.
67+ // The test file sneakily hides a second EOCDR before the first one;
68+ // previously we would extract one file ("file") from this archive,
69+ // while most other tools would reject the file or extract a different one ("FILE").
70+ {
71+ Name: "comment-truncated.zip",
72+ Error: ErrFormat,
73+ },
74 }
75
76 func TestReader(t *testing.T) {
77--
782.40.0