Skip to content

Commit ac1eeb2

Browse files
[AUTO-CHERRYPICK] Patch packer for CVE-2025-30204 [High] - branch main (#13215)
Co-authored-by: Kanishk Bansal <103916909+Kanishk-Bansal@users.noreply.github.com>
1 parent d7bab58 commit ac1eeb2

2 files changed

Lines changed: 79 additions & 2 deletions

File tree

SPECS/packer/CVE-2025-30204.patch

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
From 3b49efd441bf131dd895fd75dcf669a493b95638 Mon Sep 17 00:00:00 2001
2+
From: Kanishk-Bansal <kbkanishk975@gmail.com>
3+
Date: Sat, 29 Mar 2025 17:54:57 +0000
4+
Subject: [PATCH] CVE-2025-30204
5+
6+
Upstream Patch Reference : v4: https://github.com/golang-jwt/jwt/commit/2f0e9add62078527821828c76865661aa7718a84
7+
8+
---
9+
vendor/github.com/golang-jwt/jwt/v4/parser.go | 36 +++++++++++++++++++++++---
10+
1 file changed, 33 insertions(+), 3 deletions(-)
11+
12+
diff --git a/vendor/github.com/golang-jwt/jwt/v4/parser.go b/vendor/github.com/golang-jwt/jwt/v4/parser.go
13+
index 2f61a69..9484f28 100644
14+
--- a/vendor/github.com/golang-jwt/jwt/v4/parser.go
15+
+++ b/vendor/github.com/golang-jwt/jwt/v4/parser.go
16+
@@ -7,6 +7,8 @@ import (
17+
"strings"
18+
)
19+
20+
+const tokenDelimiter = "."
21+
+
22+
type Parser struct {
23+
// If populated, only these methods will be considered valid.
24+
//
25+
@@ -116,9 +118,10 @@ func (p *Parser) ParseWithClaims(tokenString string, claims Claims, keyFunc Keyf
26+
// It's only ever useful in cases where you know the signature is valid (because it has
27+
// been checked previously in the stack) and you want to extract values from it.
28+
func (p *Parser) ParseUnverified(tokenString string, claims Claims) (token *Token, parts []string, err error) {
29+
- parts = strings.Split(tokenString, ".")
30+
- if len(parts) != 3 {
31+
- return nil, parts, NewValidationError("token contains an invalid number of segments", ValidationErrorMalformed)
32+
+ var ok bool
33+
+ parts, ok = splitToken(tokenString)
34+
+ if !ok {
35+
+ return nil, nil, NewValidationError("token contains an invalid number of segments", ValidationErrorMalformed)
36+
}
37+
38+
token = &Token{Raw: tokenString}
39+
@@ -168,3 +171,30 @@ func (p *Parser) ParseUnverified(tokenString string, claims Claims) (token *Toke
40+
41+
return token, parts, nil
42+
}
43+
+
44+
+// splitToken splits a token string into three parts: header, claims, and signature. It will only
45+
+// return true if the token contains exactly two delimiters and three parts. In all other cases, it
46+
+// will return nil parts and false.
47+
+func splitToken(token string) ([]string, bool) {
48+
+ parts := make([]string, 3)
49+
+ header, remain, ok := strings.Cut(token, tokenDelimiter)
50+
+ if !ok {
51+
+ return nil, false
52+
+ }
53+
+ parts[0] = header
54+
+ claims, remain, ok := strings.Cut(remain, tokenDelimiter)
55+
+ if !ok {
56+
+ return nil, false
57+
+ }
58+
+ parts[1] = claims
59+
+ // One more cut to ensure the signature is the last part of the token and there are no more
60+
+ // delimiters. This avoids an issue where malicious input could contain additional delimiters
61+
+ // causing unecessary overhead parsing tokens.
62+
+ signature, _, unexpected := strings.Cut(remain, tokenDelimiter)
63+
+ if unexpected {
64+
+ return nil, false
65+
+ }
66+
+ parts[2] = signature
67+
+
68+
+ return parts, true
69+
+}
70+
--
71+
2.45.2
72+

SPECS/packer/packer.spec

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Summary: Tool for creating identical machine images for multiple platform
55
Name: packer
66
Epoch: 1
77
Version: 1.9.5
8-
Release: 11%{?dist}
8+
Release: 12%{?dist}
99
License: MPLv2.0
1010
Vendor: Microsoft Corporation
1111
Distribution: Mariner
@@ -42,6 +42,7 @@ Patch6: CVE-2025-22868.patch
4242
Patch7: CVE-2025-22869.patch
4343
Patch8: CVE-2025-22870.patch
4444
Patch9: CVE-2024-51744.patch
45+
Patch10: CVE-2025-30204.patch
4546
BuildRequires: golang
4647
BuildRequires: kernel-headers
4748
BuildRequires: glibc-devel
@@ -75,7 +76,11 @@ go test -mod=vendor
7576
%{_bindir}/packer
7677

7778
%changelog
78-
* Fri Mar 14 2025 Sreeniavsulu Malavathula <v-smalavathu@microsoft.com> - 2.4.0-28
79+
* Sat Mar 29 2025 Kanishk Bansal <kanbansal@microsoft.com> - 1.9.5-12
80+
- Patch CVE-2025-30204
81+
- Fix previous changelog
82+
83+
* Fri Mar 14 2025 Sreeniavsulu Malavathula <v-smalavathu@microsoft.com> - 1.9.5-11
7984
- Patch to fix CVE-2025-22870, CVE-2024-51744 with an upstream patch
8085

8186
* Sun Mar 02 2025 Kanishk Bansal <kanbansal@microsoft.com> - 1.9.5-10

0 commit comments

Comments
 (0)