Skip to content

Commit 70fcf1f

Browse files
[AUTO-CHERRYPICK] Patch packer for CVE-2025-22869, CVE-2025-22868 [High] & CVE-2024-28180 CVE-2025-27144 [Medium] - branch 3.0-dev (#12875)
Co-authored-by: Kanishk Bansal <[email protected]>
1 parent 36b2761 commit 70fcf1f

File tree

5 files changed

+325
-1
lines changed

5 files changed

+325
-1
lines changed

SPECS/packer/CVE-2024-28180.patch

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
From 93135333edad88bda698e252c9d30c1f699a1bbe Mon Sep 17 00:00:00 2001
2+
From: Kanishk Bansal <[email protected]>
3+
Date: Fri, 31 Jan 2025 12:50:41 +0000
4+
Subject: [PATCH] Address CVE-2024-28180 for packer
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 be7433e..763eae0 100644
13+
--- a/vendor/gopkg.in/square/go-jose.v2/crypter.go
14+
+++ b/vendor/gopkg.in/square/go-jose.v2/crypter.go
15+
@@ -406,6 +406,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+
@@ -470,6 +473,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/packer/CVE-2025-22868.patch

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
From 681b4d8edca1bcfea5bce685d77ea7b82ed3e7b3 Mon Sep 17 00:00:00 2001
2+
From: Neal Patel <[email protected]>
3+
Date: Thu, 30 Jan 2025 14:10:09 -0500
4+
Subject: [PATCH] jws: split token into fixed number of parts
5+
6+
Thanks to 'jub0bs' for reporting this issue.
7+
8+
Fixes #71490
9+
Fixes CVE-2025-22868
10+
11+
Change-Id: I2552731f46d4907f29aafe7863c558387b6bd6e2
12+
Reviewed-on: https://go-review.googlesource.com/c/oauth2/+/652155
13+
Auto-Submit: Gopher Robot <[email protected]>
14+
Reviewed-by: Damien Neil <[email protected]>
15+
Reviewed-by: Roland Shoemaker <[email protected]>
16+
LUCI-TryBot-Result: Go LUCI <[email protected]>
17+
---
18+
vendor/golang.org/x/oauth2/jws/jws.go | 4 ++--
19+
1 file changed, 2 insertions(+), 2 deletions(-)
20+
21+
diff --git a/vendor/golang.org/x/oauth2/jws/jws.go b/vendor/golang.org/x/oauth2/jws/jws.go
22+
index 95015648b..6f03a49d3 100644
23+
--- a/vendor/golang.org/x/oauth2/jws/jws.go
24+
+++ b/vendor/golang.org/x/oauth2/jws/jws.go
25+
@@ -165,11 +165,11 @@ func Encode(header *Header, c *ClaimSet, key *rsa.PrivateKey) (string, error) {
26+
// Verify tests whether the provided JWT token's signature was produced by the private key
27+
// associated with the supplied public key.
28+
func Verify(token string, key *rsa.PublicKey) error {
29+
- parts := strings.Split(token, ".")
30+
- if len(parts) != 3 {
31+
+ if strings.Count(token, ".") != 2 {
32+
return errors.New("jws: invalid token received, token must have 3 parts")
33+
}
34+
35+
+ parts := strings.SplitN(token, ".", 3)
36+
signedContent := parts[0] + "." + parts[1]
37+
signatureString, err := base64.RawURLEncoding.DecodeString(parts[2])
38+
if err != nil {

SPECS/packer/CVE-2025-22869.patch

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
From 041b89a18f81265899e42e6801f830c101a96120 Mon Sep 17 00:00:00 2001
2+
From: Kanishk-Bansal <[email protected]>
3+
Date: Sun, 2 Mar 2025 13:46:00 +0000
4+
Subject: [PATCH] CVE-2025-22869
5+
6+
Upstream Reference : https://github.com/golang/crypto/commit/7292932d45d55c7199324ab0027cc86e8198aa22
7+
8+
ssh: limit the size of the internal packet queue while waiting for KEX
9+
10+
In the SSH protocol, clients and servers execute the key exchange to
11+
generate one-time session keys used for encryption and authentication.
12+
The key exchange is performed initially after the connection is
13+
established and then periodically after a configurable amount of data.
14+
While a key exchange is in progress, we add the received packets to an
15+
internal queue until we receive SSH_MSG_KEXINIT from the other side.
16+
This can result in high memory usage if the other party is slow to
17+
respond to the SSH_MSG_KEXINIT packet, or memory exhaustion if a
18+
malicious client never responds to an SSH_MSG_KEXINIT packet during a
19+
large file transfer.
20+
We now limit the internal queue to 64 packets: this means 2MB with the
21+
typical 32KB packet size.
22+
When the internal queue is full we block further writes until the
23+
pending key exchange is completed or there is a read or write error.
24+
25+
Thanks to Yuichi Watanabe for reporting this issue.
26+
27+
Change-Id: I1ce2214cc16e08b838d4bc346c74c72addafaeec
28+
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/652135
29+
Reviewed-by: Neal Patel <[email protected]>
30+
Auto-Submit: Gopher Robot <[email protected]>
31+
Reviewed-by: Roland Shoemaker <[email protected]>
32+
LUCI-TryBot-Result: Go LUCI <[email protected]>
33+
34+
---
35+
vendor/golang.org/x/crypto/ssh/handshake.go | 47 ++++++++++++++++-----
36+
1 file changed, 37 insertions(+), 10 deletions(-)
37+
38+
diff --git a/vendor/golang.org/x/crypto/ssh/handshake.go b/vendor/golang.org/x/crypto/ssh/handshake.go
39+
index 70a7369..e14eb6c 100644
40+
--- a/vendor/golang.org/x/crypto/ssh/handshake.go
41+
+++ b/vendor/golang.org/x/crypto/ssh/handshake.go
42+
@@ -24,6 +24,11 @@ const debugHandshake = false
43+
// quickly.
44+
const chanSize = 16
45+
46+
+// maxPendingPackets sets the maximum number of packets to queue while waiting
47+
+// for KEX to complete. This limits the total pending data to maxPendingPackets
48+
+// * maxPacket bytes, which is ~16.8MB.
49+
+const maxPendingPackets = 64
50+
+
51+
// keyingTransport is a packet based transport that supports key
52+
// changes. It need not be thread-safe. It should pass through
53+
// msgNewKeys in both directions.
54+
@@ -58,11 +63,19 @@ type handshakeTransport struct {
55+
incoming chan []byte
56+
readError error
57+
58+
- mu sync.Mutex
59+
- writeError error
60+
- sentInitPacket []byte
61+
- sentInitMsg *kexInitMsg
62+
- pendingPackets [][]byte // Used when a key exchange is in progress.
63+
+ mu sync.Mutex
64+
+ // Condition for the above mutex. It is used to notify a completed key
65+
+ // exchange or a write failure. Writes can wait for this condition while a
66+
+ // key exchange is in progress.
67+
+ writeCond *sync.Cond
68+
+ writeError error
69+
+ sentInitPacket []byte
70+
+ sentInitMsg *kexInitMsg
71+
+ // Used to queue writes when a key exchange is in progress. The length is
72+
+ // limited by pendingPacketsSize. Once full, writes will block until the key
73+
+ // exchange is completed or an error occurs. If not empty, it is emptied
74+
+ // all at once when the key exchange is completed in kexLoop.
75+
+ pendingPackets [][]byte
76+
writePacketsLeft uint32
77+
writeBytesLeft int64
78+
79+
@@ -114,6 +127,7 @@ func newHandshakeTransport(conn keyingTransport, config *Config, clientVersion,
80+
81+
config: config,
82+
}
83+
+ t.writeCond = sync.NewCond(&t.mu)
84+
t.resetReadThresholds()
85+
t.resetWriteThresholds()
86+
87+
@@ -236,6 +250,7 @@ func (t *handshakeTransport) recordWriteError(err error) {
88+
defer t.mu.Unlock()
89+
if t.writeError == nil && err != nil {
90+
t.writeError = err
91+
+ t.writeCond.Broadcast()
92+
}
93+
}
94+
95+
@@ -339,6 +354,8 @@ write:
96+
}
97+
}
98+
t.pendingPackets = t.pendingPackets[:0]
99+
+ // Unblock writePacket if waiting for KEX.
100+
+ t.writeCond.Broadcast()
101+
t.mu.Unlock()
102+
}
103+
104+
@@ -526,11 +543,20 @@ func (t *handshakeTransport) writePacket(p []byte) error {
105+
}
106+
107+
if t.sentInitMsg != nil {
108+
- // Copy the packet so the writer can reuse the buffer.
109+
- cp := make([]byte, len(p))
110+
- copy(cp, p)
111+
- t.pendingPackets = append(t.pendingPackets, cp)
112+
- return nil
113+
+ if len(t.pendingPackets) < maxPendingPackets {
114+
+ // Copy the packet so the writer can reuse the buffer.
115+
+ cp := make([]byte, len(p))
116+
+ copy(cp, p)
117+
+ t.pendingPackets = append(t.pendingPackets, cp)
118+
+ return nil
119+
+ }
120+
+ for t.sentInitMsg != nil {
121+
+ // Block and wait for KEX to complete or an error.
122+
+ t.writeCond.Wait()
123+
+ if t.writeError != nil {
124+
+ return t.writeError
125+
+ }
126+
+ }
127+
}
128+
129+
if t.writeBytesLeft > 0 {
130+
@@ -547,6 +573,7 @@ func (t *handshakeTransport) writePacket(p []byte) error {
131+
132+
if err := t.pushPacket(p); err != nil {
133+
t.writeError = err
134+
+ t.writeCond.Broadcast()
135+
}
136+
137+
return nil
138+
--
139+
2.45.2
140+

SPECS/packer/CVE-2025-27144.patch

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
From fa324fa38481f9d2da9109cb5983326f62ff7507 Mon Sep 17 00:00:00 2001
2+
From: Kanishk-Bansal <[email protected]>
3+
Date: Fri, 28 Feb 2025 07:45:53 +0000
4+
Subject: [PATCH] CVE-2025-27144
5+
Upstream Ref: https://github.com/go-jose/go-jose/commit/c9ed84d8f0cfadcfad817150158caca6fcbc518b
6+
7+
---
8+
vendor/gopkg.in/square/go-jose.v2/jwe.go | 5 +++--
9+
vendor/gopkg.in/square/go-jose.v2/jws.go | 5 +++--
10+
2 files changed, 6 insertions(+), 4 deletions(-)
11+
12+
diff --git a/vendor/gopkg.in/square/go-jose.v2/jwe.go b/vendor/gopkg.in/square/go-jose.v2/jwe.go
13+
index b5a6dcd..cd1de9e 100644
14+
--- a/vendor/gopkg.in/square/go-jose.v2/jwe.go
15+
+++ b/vendor/gopkg.in/square/go-jose.v2/jwe.go
16+
@@ -201,10 +201,11 @@ func (parsed *rawJSONWebEncryption) sanitized() (*JSONWebEncryption, error) {
17+
18+
// parseEncryptedCompact parses a message in compact format.
19+
func parseEncryptedCompact(input string) (*JSONWebEncryption, error) {
20+
- parts := strings.Split(input, ".")
21+
- if len(parts) != 5 {
22+
+ // Five parts is four separators
23+
+ if strings.Count(input, ".") != 4 {
24+
return nil, fmt.Errorf("square/go-jose: compact JWE format must have five parts")
25+
}
26+
+ parts := strings.SplitN(input, ".", 5)
27+
28+
rawProtected, err := base64.RawURLEncoding.DecodeString(parts[0])
29+
if err != nil {
30+
diff --git a/vendor/gopkg.in/square/go-jose.v2/jws.go b/vendor/gopkg.in/square/go-jose.v2/jws.go
31+
index 7e261f9..a8d55fb 100644
32+
--- a/vendor/gopkg.in/square/go-jose.v2/jws.go
33+
+++ b/vendor/gopkg.in/square/go-jose.v2/jws.go
34+
@@ -275,10 +275,11 @@ func (parsed *rawJSONWebSignature) sanitized() (*JSONWebSignature, error) {
35+
36+
// parseSignedCompact parses a message in compact format.
37+
func parseSignedCompact(input string, payload []byte) (*JSONWebSignature, error) {
38+
- parts := strings.Split(input, ".")
39+
- if len(parts) != 3 {
40+
+ // Three parts is two separators
41+
+ if strings.Count(input, ".") != 2 {
42+
return nil, fmt.Errorf("square/go-jose: compact JWS format must have three parts")
43+
}
44+
+ parts := strings.SplitN(input, ".", 3)
45+
46+
if parts[1] != "" && payload != nil {
47+
return nil, fmt.Errorf("square/go-jose: payload is not detached")
48+
--
49+
2.45.2
50+

SPECS/packer/packer.spec

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Summary: Tool for creating identical machine images for multiple platforms from a single source configuration.
55
Name: packer
66
Version: 1.9.5
7-
Release: 5%{?dist}
7+
Release: 6%{?dist}
88
License: MPLv2.0
99
Vendor: Microsoft Corporation
1010
Distribution: Azure Linux
@@ -35,6 +35,10 @@ Patch0: CVE-2022-3064.patch
3535
Patch1: CVE-2024-6104.patch
3636
Patch2: CVE-2024-24786.patch
3737
Patch3: CVE-2025-21613.patch
38+
Patch4: CVE-2024-28180.patch
39+
Patch5: CVE-2025-27144.patch
40+
Patch6: CVE-2025-22869.patch
41+
Patch7: CVE-2025-22868.patch
3842
BuildRequires: golang >= 1.21
3943
BuildRequires: kernel-headers
4044
BuildRequires: glibc-devel
@@ -68,6 +72,10 @@ go test -mod=vendor
6872
%{_bindir}/packer
6973

7074
%changelog
75+
76+
* Fri Feb 28 2025 Kanishk Bansal <[email protected]> - 1.9.5-6
77+
- Fix CVE-2024-28180, CVE-2025-27144, CVE-2025-22869, CVE-2025-22868 with an upstream patch
78+
7179
* Thu Jan 09 2025 Sudipta Pandit <[email protected]> - 1.9.5-5
7280
- Add patch for CVE-2025-21613 and CVE-2025-21614
7381
- Remove patch for CVE-2023-45288, CVE-2023-49569, CVE-2024-45337

0 commit comments

Comments
 (0)