Skip to content

Commit 944102a

Browse files
[AUTO-CHERRYPICK] Patch cert-manager for CVE-2025-30204 [High] - branch 3.0-dev (#13228)
Co-authored-by: Kanishk Bansal <103916909+Kanishk-Bansal@users.noreply.github.com>
1 parent 79eac29 commit 944102a

2 files changed

Lines changed: 76 additions & 1 deletion

File tree

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

SPECS/cert-manager/cert-manager.spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Summary: Automatically provision and manage TLS certificates in Kubernetes
22
Name: cert-manager
33
Version: 1.12.15
4-
Release: 2%{?dist}
4+
Release: 3%{?dist}
55
License: ASL 2.0
66
Vendor: Microsoft Corporation
77
Distribution: Azure Linux
@@ -17,6 +17,7 @@ Patch0: CVE-2024-45338.patch
1717
Patch1: CVE-2025-27144.patch
1818
Patch2: CVE-2025-22868.patch
1919
Patch3: CVE-2025-22869.patch
20+
Patch4: CVE-2025-30204.patch
2021
BuildRequires: golang
2122
Requires: %{name}-acmesolver
2223
Requires: %{name}-cainjector
@@ -107,6 +108,9 @@ install -D -m0755 bin/webhook %{buildroot}%{_bindir}/
107108
%{_bindir}/webhook
108109

109110
%changelog
111+
* Fri Mar 28 2025 Kanishk Bansal <kanbansal@microsoft.com> - 1.12.15-3
112+
- Patch CVE-2025-30204
113+
110114
* Mon Mar 03 2025 Kanishk Bansal <kanbansal@microsoft.com> - 1.12.15-2
111115
- Fix CVE-2025-22868, CVE-2025-22869 & CVE-2025-27144 with an upstream patch
112116

0 commit comments

Comments
 (0)