Skip to content

Commit

Permalink
resolve kubernetes CVE-2024-28180
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Li committed Oct 1, 2024
1 parent a5e9d27 commit 400e0da
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 1 deletion.
76 changes: 76 additions & 0 deletions SPECS/kubernetes/CVE-2024-28180.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
diff --git a/./vendor/gopkg.in/square/go-jose.v2/crypter.go b/../kubernetes/vendor/gopkg.in/square/go-jose.v2/crypter.go
index be7433e..763eae0 100644
--- a/./vendor/gopkg.in/square/go-jose.v2/crypter.go
+++ b/../kubernetes/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/../kubernetes/vendor/gopkg.in/square/go-jose.v2/encoding.go
index 70f7385..ab9e086 100644
--- a/./vendor/gopkg.in/square/go-jose.v2/encoding.go
+++ b/../kubernetes/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/kubernetes/kubernetes.spec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Summary: Microsoft Kubernetes
Name: kubernetes
Version: 1.28.4
Release: 10%{?dist}
Release: 11%{?dist}
License: ASL 2.0
Vendor: Microsoft Corporation
Distribution: Mariner
Expand All @@ -22,6 +22,7 @@ Patch0: CVE-2024-21626.patch
Patch1: CVE-2023-48795.patch
Patch2: CVE-2023-5408.patch
Patch3: CVE-2023-45288.patch
Patch4: CVE-2024-28180.patch
BuildRequires: flex-devel
BuildRequires: glibc-static >= 2.35-7%{?dist}
BuildRequires: golang
Expand Down Expand Up @@ -268,6 +269,9 @@ fi
%{_exec_prefix}/local/bin/pause

%changelog
* Mon Oct 01 2024 Henry Li <[email protected]> - 1.28.4-11
- Add patch to resolve CVE-2024-28180

* Mon Sep 09 2024 CBL-Mariner Servicing Account <[email protected]> - 1.28.4-10
- Bump release to rebuild with go 1.22.7

Expand Down

0 comments on commit 400e0da

Please sign in to comment.