Skip to content

Commit 52b3ad9

Browse files
[AUTO-CHERRYPICK] Patch application-gateway-kubernetes-ingress for CVE-2025-30204 [High] - branch 3.0-dev (#13230)
Co-authored-by: Kanishk Bansal <[email protected]>
1 parent 6492914 commit 52b3ad9

File tree

2 files changed

+140
-1
lines changed

2 files changed

+140
-1
lines changed
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
From 84c7f3d0b9dccb4a20d0ad4de10896d40344ba26 Mon Sep 17 00:00:00 2001
2+
From: Kanishk-Bansal <[email protected]>
3+
Date: Fri, 28 Mar 2025 20:43:26 +0000
4+
Subject: [PATCH] CVE-2025-30204
5+
Upstream Patch Reference :
6+
v4 : https://github.com/golang-jwt/jwt/commit/2f0e9add62078527821828c76865661aa7718a84
7+
v5 : https://github.com/golang-jwt/jwt/commit/0951d184286dece21f73c85673fd308786ffe9c3
8+
---
9+
github.com/golang-jwt/jwt/v4/parser.go | 36 +++++++++++++++++++++++---
10+
github.com/golang-jwt/jwt/v5/parser.go | 36 +++++++++++++++++++++++---
11+
2 files changed, 66 insertions(+), 6 deletions(-)
12+
13+
diff --git a/vendor/github.com/golang-jwt/jwt/v4/parser.go b/vendor/github.com/golang-jwt/jwt/v4/parser.go
14+
index c0a6f69..8e7e67c 100644
15+
--- a/vendor/github.com/golang-jwt/jwt/v4/parser.go
16+
+++ b/vendor/github.com/golang-jwt/jwt/v4/parser.go
17+
@@ -7,6 +7,8 @@ import (
18+
"strings"
19+
)
20+
21+
+const tokenDelimiter = "."
22+
+
23+
type Parser struct {
24+
// If populated, only these methods will be considered valid.
25+
//
26+
@@ -123,9 +125,10 @@ func (p *Parser) ParseWithClaims(tokenString string, claims Claims, keyFunc Keyf
27+
// It's only ever useful in cases where you know the signature is valid (because it has
28+
// been checked previously in the stack) and you want to extract values from it.
29+
func (p *Parser) ParseUnverified(tokenString string, claims Claims) (token *Token, parts []string, err error) {
30+
- parts = strings.Split(tokenString, ".")
31+
- if len(parts) != 3 {
32+
- return nil, parts, NewValidationError("token contains an invalid number of segments", ValidationErrorMalformed)
33+
+ var ok bool
34+
+ parts, ok = splitToken(tokenString)
35+
+ if !ok {
36+
+ return nil, nil, NewValidationError("token contains an invalid number of segments", ValidationErrorMalformed)
37+
}
38+
39+
token = &Token{Raw: tokenString}
40+
@@ -175,3 +178,30 @@ func (p *Parser) ParseUnverified(tokenString string, claims Claims) (token *Toke
41+
42+
return token, parts, nil
43+
}
44+
+
45+
+// splitToken splits a token string into three parts: header, claims, and signature. It will only
46+
+// return true if the token contains exactly two delimiters and three parts. In all other cases, it
47+
+// will return nil parts and false.
48+
+func splitToken(token string) ([]string, bool) {
49+
+ parts := make([]string, 3)
50+
+ header, remain, ok := strings.Cut(token, tokenDelimiter)
51+
+ if !ok {
52+
+ return nil, false
53+
+ }
54+
+ parts[0] = header
55+
+ claims, remain, ok := strings.Cut(remain, tokenDelimiter)
56+
+ if !ok {
57+
+ return nil, false
58+
+ }
59+
+ parts[1] = claims
60+
+ // One more cut to ensure the signature is the last part of the token and there are no more
61+
+ // delimiters. This avoids an issue where malicious input could contain additional delimiters
62+
+ // causing unecessary overhead parsing tokens.
63+
+ signature, _, unexpected := strings.Cut(remain, tokenDelimiter)
64+
+ if unexpected {
65+
+ return nil, false
66+
+ }
67+
+ parts[2] = signature
68+
+
69+
+ return parts, true
70+
+}
71+
diff --git a/vendor/github.com/golang-jwt/jwt/v5/parser.go b/vendor/github.com/golang-jwt/jwt/v5/parser.go
72+
index ecf99af..054c7eb 100644
73+
--- a/vendor/github.com/golang-jwt/jwt/v5/parser.go
74+
+++ b/vendor/github.com/golang-jwt/jwt/v5/parser.go
75+
@@ -8,6 +8,8 @@ import (
76+
"strings"
77+
)
78+
79+
+const tokenDelimiter = "."
80+
+
81+
type Parser struct {
82+
// If populated, only these methods will be considered valid.
83+
validMethods []string
84+
@@ -136,9 +138,10 @@ func (p *Parser) ParseWithClaims(tokenString string, claims Claims, keyFunc Keyf
85+
// It's only ever useful in cases where you know the signature is valid (since it has already
86+
// been or will be checked elsewhere in the stack) and you want to extract values from it.
87+
func (p *Parser) ParseUnverified(tokenString string, claims Claims) (token *Token, parts []string, err error) {
88+
- parts = strings.Split(tokenString, ".")
89+
- if len(parts) != 3 {
90+
- return nil, parts, newError("token contains an invalid number of segments", ErrTokenMalformed)
91+
+ var ok bool
92+
+ parts, ok = splitToken(tokenString)
93+
+ if !ok {
94+
+ return nil, nil, newError("token contains an invalid number of segments", ErrTokenMalformed)
95+
}
96+
97+
token = &Token{Raw: tokenString}
98+
@@ -196,6 +199,33 @@ func (p *Parser) ParseUnverified(tokenString string, claims Claims) (token *Toke
99+
return token, parts, nil
100+
}
101+
102+
+// splitToken splits a token string into three parts: header, claims, and signature. It will only
103+
+// return true if the token contains exactly two delimiters and three parts. In all other cases, it
104+
+// will return nil parts and false.
105+
+func splitToken(token string) ([]string, bool) {
106+
+ parts := make([]string, 3)
107+
+ header, remain, ok := strings.Cut(token, tokenDelimiter)
108+
+ if !ok {
109+
+ return nil, false
110+
+ }
111+
+ parts[0] = header
112+
+ claims, remain, ok := strings.Cut(remain, tokenDelimiter)
113+
+ if !ok {
114+
+ return nil, false
115+
+ }
116+
+ parts[1] = claims
117+
+ // One more cut to ensure the signature is the last part of the token and there are no more
118+
+ // delimiters. This avoids an issue where malicious input could contain additional delimiters
119+
+ // causing unecessary overhead parsing tokens.
120+
+ signature, _, unexpected := strings.Cut(remain, tokenDelimiter)
121+
+ if unexpected {
122+
+ return nil, false
123+
+ }
124+
+ parts[2] = signature
125+
+
126+
+ return parts, true
127+
+}
128+
+
129+
// DecodeSegment decodes a JWT specific base64url encoding. This function will
130+
// take into account whether the [Parser] is configured with additional options,
131+
// such as [WithStrictDecoding] or [WithPaddingAllowed].
132+
--
133+
2.45.2
134+

SPECS/application-gateway-kubernetes-ingress/application-gateway-kubernetes-ingress.spec

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Summary: Application Gateway Ingress Controller
33
Name: application-gateway-kubernetes-ingress
44
Version: 1.7.7
5-
Release: 1%{?dist}
5+
Release: 2%{?dist}
66
License: MIT
77
Vendor: Microsoft Corporation
88
Distribution: Azure Linux
@@ -13,6 +13,7 @@ Source0: https://github.com/Azure/application-gateway-kubernetes-ingress/
1313
# NOTE: govendor-v1 format is for inplace CVE updates so that we do not have to overwrite in the blob-store.
1414
# After fixing any possible CVE for the vendored source, we must bump v1 -> v2
1515
Source1: %{name}-%{version}-govendor-v1.tar.gz
16+
Patch0: CVE-2025-30204.patch
1617

1718
BuildRequires: golang >= 1.23
1819

@@ -25,6 +26,7 @@ to act as the ingress for an AKS cluster.
2526

2627
rm -rf vendor
2728
tar -xf %{SOURCE1} --no-same-owner
29+
%autopatch -p1
2830

2931
%build
3032
export VERSION=%{version}
@@ -43,6 +45,9 @@ cp appgw-ingress %{buildroot}%{_bindir}/
4345
%{_bindir}/appgw-ingress
4446

4547
%changelog
48+
* Sat Mar 29 2025 Kanishk Bansal <[email protected]> - 1.7.7-2
49+
- Patch CVE-2025-30204
50+
4651
* Tue Feb 04 2025 Gary Swalling <[email protected]> - 1.7.7-1
4752
- Upgrade to v1.7.7 with golang.org/x/net v0.33.0 for CVE-2023-39325, CVE-2023-44487,
4853
- CVE-2023-45288, CVE-2024-51744, CVE-2024-35255, CVE-2023-3978

0 commit comments

Comments
 (0)