Skip to content

Commit 52c5c1d

Browse files
[AUTO-CHERRYPICK] [Low] Patch prometheus for CVE-2024-51744 - branch main (#13354)
Co-authored-by: Sreenivasulu Malavathula (HCL Technologies Ltd) <v-smalavathu@microsoft.com>
1 parent 211d741 commit 52c5c1d

2 files changed

Lines changed: 92 additions & 2 deletions

File tree

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
From f9b6dbc85af1b8cc977b9e534d8211d1e261d991 Mon Sep 17 00:00:00 2001
2+
From: Sreenivasulu Malavathula <v-smalavathu@microsoft.com>
3+
Date: Wed, 2 Apr 2025 15:11:18 -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 | 36 +++++++++++--------
9+
1 file changed, 21 insertions(+), 15 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 9484f28..0fc510a 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,12 +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
28+
+// implementing the Claims interface. This provides default values which can be overridden and
29+
+// allows a caller to use their own type, rather than the default MapClaims implementation of
30+
+// Claims.
31+
+//
32+
+// Note: If you provide a custom claim implementation that embeds one of the standard claims (such
33+
+// as RegisteredClaims), make sure that a) you either embed a non-pointer version of the claims or
34+
+// b) if you are using a pointer, allocate the proper memory for it before passing in the overall
35+
+// claims, otherwise you might run into a panic.
36+
func (p *Parser) ParseWithClaims(tokenString string, claims Claims, keyFunc Keyfunc) (*Token, error) {
37+
token, parts, err := p.ParseUnverified(tokenString, claims)
38+
if err != nil {
39+
@@ -80,12 +89,17 @@ func (p *Parser) ParseWithClaims(tokenString string, claims Claims, keyFunc Keyf
40+
return token, &ValidationError{Inner: err, Errors: ValidationErrorUnverifiable}
41+
}
42+
43+
+ // Perform validation
44+
+ token.Signature = parts[2]
45+
+ if err := token.Method.Verify(strings.Join(parts[0:2], "."), token.Signature, key); err != nil {
46+
+ return token, &ValidationError{Inner: err, Errors: ValidationErrorSignatureInvalid}
47+
+ }
48+
+
49+
vErr := &ValidationError{}
50+
51+
// Validate Claims
52+
if !p.SkipClaimsValidation {
53+
if err := token.Claims.Valid(); err != nil {
54+
-
55+
// If the Claims Valid returned an error, check if it is a validation error,
56+
// If it was another error type, create a ValidationError with a generic ClaimsInvalid flag set
57+
if e, ok := err.(*ValidationError); !ok {
58+
@@ -93,22 +107,14 @@ func (p *Parser) ParseWithClaims(tokenString string, claims Claims, keyFunc Keyf
59+
} else {
60+
vErr = e
61+
}
62+
+ return token, vErr
63+
}
64+
}
65+
66+
- // Perform validation
67+
- token.Signature = parts[2]
68+
- if err = token.Method.Verify(strings.Join(parts[0:2], "."), token.Signature, key); err != nil {
69+
- vErr.Inner = err
70+
- vErr.Errors |= ValidationErrorSignatureInvalid
71+
- }
72+
-
73+
- if vErr.valid() {
74+
- token.Valid = true
75+
- return token, nil
76+
- }
77+
+ // No errors so far, token is valid.
78+
+ token.Valid = true
79+
80+
- return token, vErr
81+
+ return token, nil
82+
}
83+
84+
// ParseUnverified parses the token but doesn't validate the signature.
85+
--
86+
2.45.2
87+

SPECS/prometheus/prometheus.spec

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Summary: Prometheus monitoring system and time series database
55
Name: prometheus
66
Version: 2.37.9
7-
Release: 3%{?dist}
7+
Release: 4%{?dist}
88
License: Apache-2.0
99
Vendor: Microsoft Corporation
1010
Distribution: Mariner
@@ -23,7 +23,7 @@ Patch2: CVE-2024-24786.patch
2323
Patch3: CVE-2023-39325.patch
2424
Patch4: CVE-2023-45288.patch
2525
Patch5: CVE-2025-30204.patch
26-
26+
Patch6: CVE-2024-51744.patch
2727
BuildRequires: golang
2828
BuildRequires: nodejs
2929
BuildRequires: systemd-rpm-macros
@@ -137,6 +137,9 @@ fi
137137
%doc README.md RELEASE.md documentation
138138

139139
%changelog
140+
* Thu Apr 03 2025 Sreeniavsulu Malavathula <v-smalavathu@microsoft.com> - 2.37.9-4
141+
- Fix CVE-2024-51744 with an upstream patch
142+
140143
* Sun Mar 30 2025 Kanishk Bansal <kanbansal@microsoft.com> - 2.37.9-3
141144
- Patch CVE-2025-30204
142145

0 commit comments

Comments
 (0)