Skip to content

Commit 63f3442

Browse files
[AUTO-CHERRYPICK] Patch rook for CVE-2024-28180 - branch main (#12133)
Co-authored-by: Kanishk Bansal <103916909+Kanishk-Bansal@users.noreply.github.com>
1 parent 1a1c51b commit 63f3442

2 files changed

Lines changed: 93 additions & 1 deletion

File tree

SPECS/rook/CVE-2024-28180.patch

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
From 960568549a9ba6027df43c30a845233e3a5a0697 Mon Sep 17 00:00:00 2001
2+
From: Kanishk Bansal <kbkanishk975@gmail.com>
3+
Date: Wed, 29 Jan 2025 11:54:24 +0000
4+
Subject: [PATCH] Address CVE CVE-2024-28180
5+
6+
---
7+
vendor/gopkg.in/square/go-jose.v2/crypter.go | 6 ++++++
8+
vendor/gopkg.in/square/go-jose.v2/encoding.go | 20 ++++++++++++++++----
9+
2 files changed, 22 insertions(+), 4 deletions(-)
10+
11+
diff --git a/vendor/gopkg.in/square/go-jose.v2/crypter.go b/vendor/gopkg.in/square/go-jose.v2/crypter.go
12+
index d24cabf..a628386 100644
13+
--- a/vendor/gopkg.in/square/go-jose.v2/crypter.go
14+
+++ b/vendor/gopkg.in/square/go-jose.v2/crypter.go
15+
@@ -405,6 +405,9 @@ func (ctx *genericEncrypter) Options() EncrypterOptions {
16+
// Decrypt and validate the object and return the plaintext. Note that this
17+
// function does not support multi-recipient, if you desire multi-recipient
18+
// decryption use DecryptMulti instead.
19+
+//
20+
+// Automatically decompresses plaintext, but returns an error if the decompressed
21+
+// data would be >250kB or >10x the size of the compressed data, whichever is larger.
22+
func (obj JSONWebEncryption) Decrypt(decryptionKey interface{}) ([]byte, error) {
23+
headers := obj.mergedHeaders(nil)
24+
25+
@@ -469,6 +472,9 @@ func (obj JSONWebEncryption) Decrypt(decryptionKey interface{}) ([]byte, error)
26+
// with support for multiple recipients. It returns the index of the recipient
27+
// for which the decryption was successful, the merged headers for that recipient,
28+
// and the plaintext.
29+
+//
30+
+// Automatically decompresses plaintext, but returns an error if the decompressed
31+
+// data would be >250kB or >3x the size of the compressed data, whichever is larger.
32+
func (obj JSONWebEncryption) DecryptMulti(decryptionKey interface{}) (int, Header, []byte, error) {
33+
globalHeaders := obj.mergedHeaders(nil)
34+
35+
diff --git a/vendor/gopkg.in/square/go-jose.v2/encoding.go b/vendor/gopkg.in/square/go-jose.v2/encoding.go
36+
index 70f7385..2b92116 100644
37+
--- a/vendor/gopkg.in/square/go-jose.v2/encoding.go
38+
+++ b/vendor/gopkg.in/square/go-jose.v2/encoding.go
39+
@@ -21,6 +21,7 @@ import (
40+
"compress/flate"
41+
"encoding/base64"
42+
"encoding/binary"
43+
+ "fmt"
44+
"io"
45+
"math/big"
46+
"strings"
47+
@@ -85,7 +86,7 @@ func decompress(algorithm CompressionAlgorithm, input []byte) ([]byte, error) {
48+
}
49+
}
50+
51+
-// Compress with DEFLATE
52+
+// deflate compresses the input.
53+
func deflate(input []byte) ([]byte, error) {
54+
output := new(bytes.Buffer)
55+
56+
@@ -97,15 +98,26 @@ func deflate(input []byte) ([]byte, error) {
57+
return output.Bytes(), err
58+
}
59+
60+
-// Decompress with DEFLATE
61+
+// inflate decompresses the input.
62+
+//
63+
+// Errors if the decompressed data would be >250kB or >10x the size of the
64+
+// compressed data, whichever is larger.
65+
func inflate(input []byte) ([]byte, error) {
66+
output := new(bytes.Buffer)
67+
reader := flate.NewReader(bytes.NewBuffer(input))
68+
69+
- _, err := io.Copy(output, reader)
70+
- if err != nil {
71+
+ maxCompressedSize := 10 * int64(len(input))
72+
+ if maxCompressedSize < 250000 {
73+
+ maxCompressedSize = 250000
74+
+ }
75+
+ limit := maxCompressedSize + 1
76+
+ n, err := io.CopyN(output, reader, limit)
77+
+ if err != nil && err != io.EOF {
78+
return nil, err
79+
}
80+
+ if n == limit {
81+
+ return nil, fmt.Errorf("uncompressed data would be too large (>%d bytes)", maxCompressedSize)
82+
+ }
83+
84+
err = reader.Close()
85+
return output.Bytes(), err
86+
--
87+
2.43.0
88+

SPECS/rook/rook.spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
Summary: Orchestrator for distributed storage systems in cloud-native environments
2020
Name: rook
2121
Version: 1.6.2
22-
Release: 22%{?dist}
22+
Release: 23%{?dist}
2323
License: Apache-2.0
2424
Vendor: Microsoft Corporation
2525
Distribution: Mariner
@@ -58,6 +58,7 @@ Patch1: CVE-2022-21698.patch
5858
Patch2: CVE-2023-44487.patch
5959
Patch3: CVE-2021-44716.patch
6060
Patch4: CVE-2024-6104.patch
61+
Patch5: CVE-2024-28180.patch
6162
# Ceph version is needed to set correct container tag in manifests
6263
BuildRequires: ceph
6364
# Rook requirements
@@ -256,6 +257,9 @@ sed -i -e "s|\(.*tag: \)VERSION|\1%{helm_appVersion}|" %{values_yaml}
256257
# bother adding docs or changelog or anything
257258

258259
%changelog
260+
* Wed Jan 29 2025 Kanishk Bansal <kanbansal@microsoft.com> - 1.6.2-23
261+
- Fix CVE-2024-28180 with an upstream patch
262+
259263
* Mon Sep 09 2024 CBL-Mariner Servicing Account <cblmargh@microsoft.com> - 1.6.2-22
260264
- Bump release to rebuild with go 1.22.7
261265

0 commit comments

Comments
 (0)