Skip to content

Commit 7635cf1

Browse files
[AUTO-CHERRYPICK] [Low] Patch kubernetes for CVE-2024-51744 - branch main (#13364)
Co-authored-by: Sreenivasulu Malavathula (HCL Technologies Ltd) <v-smalavathu@microsoft.com>
1 parent 18dbf29 commit 7635cf1

2 files changed

Lines changed: 98 additions & 1 deletion

File tree

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
From 33e233f3c97bcb4e114beb53f3c4c9d714adf4a7 Mon Sep 17 00:00:00 2001
2+
From: Sreenivasulu Malavathula <v-smalavathu@microsoft.com>
3+
Date: Tue, 1 Apr 2025 16:50:59 -0500
4+
Subject: [PATCH] Address CVE-2024-51744
5+
Upstream Patch Reference: https://github.com/golang-jwt/jwt/commit/7b1c1c00a171c6c79bbdb40e4ce7d197060c1c2c
6+
7+
---
8+
vendor/github.com/golang-jwt/jwt/v4/parser.go | 41 +++++++++----------
9+
1 file changed, 20 insertions(+), 21 deletions(-)
10+
11+
diff --git a/vendor/github.com/golang-jwt/jwt/v4/parser.go b/vendor/github.com/golang-jwt/jwt/v4/parser.go
12+
index 8e7e67c4..0fc510a0 100644
13+
--- a/vendor/github.com/golang-jwt/jwt/v4/parser.go
14+
+++ b/vendor/github.com/golang-jwt/jwt/v4/parser.go
15+
@@ -38,19 +38,21 @@ func NewParser(options ...ParserOption) *Parser {
16+
return p
17+
}
18+
19+
-// Parse parses, validates, verifies the signature and returns the parsed token.
20+
-// keyFunc will receive the parsed token and should return the key for validating.
21+
+// Parse parses, validates, verifies the signature and returns the parsed token. keyFunc will
22+
+// receive the parsed token and should return the key for validating.
23+
func (p *Parser) Parse(tokenString string, keyFunc Keyfunc) (*Token, error) {
24+
return p.ParseWithClaims(tokenString, MapClaims{}, keyFunc)
25+
}
26+
27+
-// ParseWithClaims parses, validates, and verifies like Parse, but supplies a default object implementing the Claims
28+
-// interface. This provides default values which can be overridden and allows a caller to use their own type, rather
29+
-// than the default MapClaims implementation of Claims.
30+
+// ParseWithClaims parses, validates, and verifies like Parse, but supplies a default object
31+
+// implementing the Claims interface. This provides default values which can be overridden and
32+
+// allows a caller to use their own type, rather than the default MapClaims implementation of
33+
+// Claims.
34+
//
35+
-// Note: If you provide a custom claim implementation that embeds one of the standard claims (such as RegisteredClaims),
36+
-// make sure that a) you either embed a non-pointer version of the claims or b) if you are using a pointer, allocate the
37+
-// proper memory for it before passing in the overall claims, otherwise you might run into a panic.
38+
+// Note: If you provide a custom claim implementation that embeds one of the standard claims (such
39+
+// as RegisteredClaims), make sure that a) you either embed a non-pointer version of the claims or
40+
+// b) if you are using a pointer, allocate the proper memory for it before passing in the overall
41+
+// claims, otherwise you might run into a panic.
42+
func (p *Parser) ParseWithClaims(tokenString string, claims Claims, keyFunc Keyfunc) (*Token, error) {
43+
token, parts, err := p.ParseUnverified(tokenString, claims)
44+
if err != nil {
45+
@@ -87,12 +89,17 @@ func (p *Parser) ParseWithClaims(tokenString string, claims Claims, keyFunc Keyf
46+
return token, &ValidationError{Inner: err, Errors: ValidationErrorUnverifiable}
47+
}
48+
49+
+ // Perform validation
50+
+ token.Signature = parts[2]
51+
+ if err := token.Method.Verify(strings.Join(parts[0:2], "."), token.Signature, key); err != nil {
52+
+ return token, &ValidationError{Inner: err, Errors: ValidationErrorSignatureInvalid}
53+
+ }
54+
+
55+
vErr := &ValidationError{}
56+
57+
// Validate Claims
58+
if !p.SkipClaimsValidation {
59+
if err := token.Claims.Valid(); err != nil {
60+
-
61+
// If the Claims Valid returned an error, check if it is a validation error,
62+
// If it was another error type, create a ValidationError with a generic ClaimsInvalid flag set
63+
if e, ok := err.(*ValidationError); !ok {
64+
@@ -100,22 +107,14 @@ func (p *Parser) ParseWithClaims(tokenString string, claims Claims, keyFunc Keyf
65+
} else {
66+
vErr = e
67+
}
68+
+ return token, vErr
69+
}
70+
}
71+
72+
- // Perform validation
73+
- token.Signature = parts[2]
74+
- if err = token.Method.Verify(strings.Join(parts[0:2], "."), token.Signature, key); err != nil {
75+
- vErr.Inner = err
76+
- vErr.Errors |= ValidationErrorSignatureInvalid
77+
- }
78+
-
79+
- if vErr.valid() {
80+
- token.Valid = true
81+
- return token, nil
82+
- }
83+
+ // No errors so far, token is valid.
84+
+ token.Valid = true
85+
86+
- return token, vErr
87+
+ return token, nil
88+
}
89+
90+
// ParseUnverified parses the token but doesn't validate the signature.
91+
--
92+
2.45.2
93+

SPECS/kubernetes/kubernetes.spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
Summary: Microsoft Kubernetes
1111
Name: kubernetes
1212
Version: 1.28.4
13-
Release: 16%{?dist}
13+
Release: 17%{?dist}
1414
License: ASL 2.0
1515
Vendor: Microsoft Corporation
1616
Distribution: Mariner
@@ -30,6 +30,7 @@ Patch8: CVE-2025-27144.patch
3030
Patch9: CVE-2025-22868.patch
3131
Patch10: CVE-2025-22869.patch
3232
Patch11: CVE-2025-30204.patch
33+
Patch12: CVE-2024-51744.patch
3334
BuildRequires: flex-devel
3435
BuildRequires: glibc-static >= 2.35-7%{?dist}
3536
BuildRequires: golang
@@ -275,6 +276,9 @@ fi
275276
%{_exec_prefix}/local/bin/pause
276277

277278
%changelog
279+
* Tue Apr 01 2025 Sreeniavsulu Malavathula <v-smalavathu@microsoft.com> - 1.28.4-17
280+
- Fix CVE-2024-51744 with an upstream patch
281+
278282
* Sat Mar 29 2025 Kanishk Bansal <kanbansal@microsoft.com> - 1.28.4-16
279283
- Patch CVE-2025-30204
280284

0 commit comments

Comments
 (0)