Skip to content

Commit 0ccbd00

Browse files
[AUTO-CHERRYPICK] influxdb: Fix CVE-2024-28180 [Medium] - branch main (#12027)
Co-authored-by: KavyaSree2610 <92566732+KavyaSree2610@users.noreply.github.com>
1 parent f7c0443 commit 0ccbd00

2 files changed

Lines changed: 93 additions & 1 deletion

File tree

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

SPECS/influxdb/influxdb.spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
Summary: Scalable datastore for metrics, events, and real-time analytics
1919
Name: influxdb
2020
Version: 2.6.1
21-
Release: 19%{?dist}
21+
Release: 20%{?dist}
2222
License: MIT
2323
Vendor: Microsoft Corporation
2424
Distribution: Mariner
@@ -59,6 +59,7 @@ Patch0: CVE-2024-6104.patch
5959
Patch1: CVE-2022-32149.patch
6060
Patch2: CVE-2024-24786.patch
6161
Patch3: CVE-2024-45338.patch
62+
Patch4: CVE-2024-28180.patch
6263
BuildRequires: clang
6364
BuildRequires: golang <= 1.18.8
6465
BuildRequires: kernel-headers
@@ -148,6 +149,9 @@ go test ./...
148149
%{_tmpfilesdir}/influxdb.conf
149150

150151
%changelog
152+
* Wed Jan 22 2025 Kavya Sree Kaitepalli <kkaitepalli@microsoft.com> - 2.6.1-20
153+
- Patch for CVE-2024-28180
154+
151155
* Fri Jan 03 2025 Sumedh Sharma <sumsharma@microsoft.com> - 2.6.1-19
152156
- Add patch for CVE-2024-45338
153157

0 commit comments

Comments
 (0)