Skip to content

Commit

Permalink
influxdb: Fix CVE-2024-28180 [Medium] (#12021)
Browse files Browse the repository at this point in the history
Co-authored-by: kavyasree <[email protected]>
Co-authored-by: Riken Maharjan <[email protected]>
(cherry picked from commit e7b95d9)
  • Loading branch information
KavyaSree2610 authored and CBL-Mariner-Bot committed Jan 22, 2025
1 parent c402b55 commit b16d6ee
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 1 deletion.
88 changes: 88 additions & 0 deletions SPECS/influxdb/CVE-2024-28180.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
From 0dd4dd541c665fb292d664f77604ba694726f298 Mon Sep 17 00:00:00 2001
From: Jacob Hoffman-Andrews <[email protected]>
Date: Thu, 7 Mar 2024 14:25:21 -0800
Subject: [PATCH] v2: backport decompression limit fix (#109)

Backport from #107.
Modified to apply to vendored code by : Kavya Sree Kaitepalli <[email protected]>
---
vendor/gopkg.in/square/go-jose.v2/crypter.go | 6 ++++
vendor/gopkg.in/square/go-jose.v2/encoding.go | 21 +++++++++---
2 files changed, 141 insertions(+), 4 deletions(-)

diff --git a/vendor/gopkg.in/square/go-jose.v2/crypter.go b/vendor/gopkg.in/square/go-jose.v2/crypter.go
index 73aab0f..0ae2e5e 100644
--- a/vendor/gopkg.in/square/go-jose.v2/crypter.go
+++ b/vendor/gopkg.in/square/go-jose.v2/crypter.go
@@ -406,6 +406,9 @@ func (ctx *genericEncrypter) Options() EncrypterOptions {
// Decrypt and validate the object and return the plaintext. Note that this
// function does not support multi-recipient, if you desire multi-recipient
// decryption use DecryptMulti instead.
+//
+// Automatically decompresses plaintext, but returns an error if the decompressed
+// data would be >250kB or >10x the size of the compressed data, whichever is larger.
func (obj JSONWebEncryption) Decrypt(decryptionKey interface{}) ([]byte, error) {
headers := obj.mergedHeaders(nil)

@@ -470,6 +473,9 @@ func (obj JSONWebEncryption) Decrypt(decryptionKey interface{}) ([]byte, error)
// with support for multiple recipients. It returns the index of the recipient
// for which the decryption was successful, the merged headers for that recipient,
// and the plaintext.
+//
+// Automatically decompresses plaintext, but returns an error if the decompressed
+// data would be >250kB or >3x the size of the compressed data, whichever is larger.
func (obj JSONWebEncryption) DecryptMulti(decryptionKey interface{}) (int, Header, []byte, error) {
globalHeaders := obj.mergedHeaders(nil)

diff --git a/vendor/gopkg.in/square/go-jose.v2/encoding.go b/vendor/gopkg.in/square/go-jose.v2/encoding.go
index 40b688b..636f6c8 100644
--- a/vendor/gopkg.in/square/go-jose.v2/encoding.go
+++ b/vendor/gopkg.in/square/go-jose.v2/encoding.go
@@ -21,6 +21,7 @@ import (
"compress/flate"
"encoding/base64"
"encoding/binary"
+ "fmt"
"io"
"math/big"
"strings"
@@ -85,7 +86,7 @@ func decompress(algorithm CompressionAlgorithm, input []byte) ([]byte, error) {
}
}

-// Compress with DEFLATE
+// deflate compresses the input.
func deflate(input []byte) ([]byte, error) {
output := new(bytes.Buffer)

@@ -97,15 +98,27 @@ func deflate(input []byte) ([]byte, error) {
return output.Bytes(), err
}

-// Decompress with DEFLATE
+// inflate decompresses the input.
+//
+// Errors if the decompressed data would be >250kB or >10x the size of the
+// compressed data, whichever is larger.
func inflate(input []byte) ([]byte, error) {
output := new(bytes.Buffer)
reader := flate.NewReader(bytes.NewBuffer(input))

- _, err := io.Copy(output, reader)
- if err != nil {
+ maxCompressedSize := 10 * int64(len(input))
+ if maxCompressedSize < 250000 {
+ maxCompressedSize = 250000
+ }
+
+ limit := maxCompressedSize + 1
+ n, err := io.CopyN(output, reader, limit)
+ if err != nil && err != io.EOF {
return nil, err
}
+ if n == limit {
+ return nil, fmt.Errorf("uncompressed data would be too large (>%d bytes)", maxCompressedSize)
+ }

err = reader.Close()
return output.Bytes(), err
6 changes: 5 additions & 1 deletion SPECS/influxdb/influxdb.spec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
Summary: Scalable datastore for metrics, events, and real-time analytics
Name: influxdb
Version: 2.6.1
Release: 19%{?dist}
Release: 20%{?dist}
License: MIT
Vendor: Microsoft Corporation
Distribution: Mariner
Expand Down Expand Up @@ -59,6 +59,7 @@ Patch0: CVE-2024-6104.patch
Patch1: CVE-2022-32149.patch
Patch2: CVE-2024-24786.patch
Patch3: CVE-2024-45338.patch
Patch4: CVE-2024-28180.patch
BuildRequires: clang
BuildRequires: golang <= 1.18.8
BuildRequires: kernel-headers
Expand Down Expand Up @@ -148,6 +149,9 @@ go test ./...
%{_tmpfilesdir}/influxdb.conf

%changelog
* Wed Jan 22 2025 Kavya Sree Kaitepalli <[email protected]> - 2.6.1-20
- Patch for CVE-2024-28180

* Fri Jan 03 2025 Sumedh Sharma <[email protected]> - 2.6.1-19
- Add patch for CVE-2024-45338

Expand Down

0 comments on commit b16d6ee

Please sign in to comment.