Skip to content

Commit 5ade69f

Browse files
[AUTO-CHERRYPICK] [Medium] Patch prometheus for CVE-2025-22870 and CVE-2024-51744 - branch 3.0-dev (#13564)
Co-authored-by: Sreenivasulu Malavathula (HCL Technologies Ltd) <v-smalavathu@microsoft.com>
1 parent 976368d commit 5ade69f

3 files changed

Lines changed: 147 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 2b1e1d0f9e8d12b297996b6aea71156794844a3e Mon Sep 17 00:00:00 2001
2+
From: Sreenivasulu Malavathula <v-smalavathu@microsoft.com>
3+
Date: Thu, 3 Apr 2025 12:41:39 -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+
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
From 31238fb0b1b52a54942f9766fde5067ffa078320 Mon Sep 17 00:00:00 2001
2+
From: Sreenivasulu Malavathula <v-smalavathu@microsoft.com>
3+
Date: Thu, 3 Apr 2025 12:36:33 -0500
4+
Subject: [PATCH] Address CVE-2025-22870
5+
Upstream Patch Reference: https://github.com/golang/go/commit/25177ecde0922c50753c043579d17828b7ee88e7
6+
7+
---
8+
vendor/golang.org/x/net/http/httpproxy/proxy.go | 10 ++++++++--
9+
1 file changed, 8 insertions(+), 2 deletions(-)
10+
11+
diff --git a/vendor/golang.org/x/net/http/httpproxy/proxy.go b/vendor/golang.org/x/net/http/httpproxy/proxy.go
12+
index c3bd9a1e..864961c7 100644
13+
--- a/vendor/golang.org/x/net/http/httpproxy/proxy.go
14+
+++ b/vendor/golang.org/x/net/http/httpproxy/proxy.go
15+
@@ -14,6 +14,7 @@ import (
16+
"errors"
17+
"fmt"
18+
"net"
19+
+ "net/netip"
20+
"net/url"
21+
"os"
22+
"strings"
23+
@@ -180,8 +181,10 @@ func (cfg *config) useProxy(addr string) bool {
24+
if host == "localhost" {
25+
return false
26+
}
27+
- ip := net.ParseIP(host)
28+
- if ip != nil {
29+
+ nip, err := netip.ParseAddr(host)
30+
+ var ip net.IP
31+
+ if err == nil {
32+
+ ip = net.IP(nip.AsSlice())
33+
if ip.IsLoopback() {
34+
return false
35+
}
36+
@@ -363,6 +366,9 @@ type domainMatch struct {
37+
}
38+
39+
func (m domainMatch) match(host, port string, ip net.IP) bool {
40+
+ if ip != nil {
41+
+ return false
42+
+ }
43+
if strings.HasSuffix(host, m.host) || (m.matchHost && host == m.host[1:]) {
44+
return m.port == "" || m.port == port
45+
}
46+
--
47+
2.45.2
48+

SPECS/prometheus/prometheus.spec

Lines changed: 6 additions & 1 deletion
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.45.4
7-
Release: 11%{?dist}
7+
Release: 12%{?dist}
88
License: Apache-2.0
99
Vendor: Microsoft Corporation
1010
Distribution: Azure Linux
@@ -27,6 +27,8 @@ Patch6: CVE-2025-30204.patch
2727
Patch7: 0001-Fix-exit-condition-of-TestQuerierIndexQueriesRace.patch
2828
Patch8: 0002-Improve-sensitivity-of-TestQuerierIndexQueriesRace.patch
2929
Patch9: CVE-2024-35255.patch
30+
Patch10: CVE-2025-22870.patch
31+
Patch11: CVE-2024-51744.patch
3032

3133
BuildRequires: golang
3234
BuildRequires: nodejs
@@ -144,6 +146,9 @@ fi
144146
%doc README.md RELEASE.md documentation
145147

146148
%changelog
149+
* Mon Apr 21 2025 Sreeniavsulu Malavathula <v-smalavathu@microsoft.com> - 2.45.4-12
150+
- Patch CVE-2025-22870, CVE-2024-51744
151+
147152
* Mon Apr 14 2025 Mayank Singh <mayansingh@microsoft.com> - 2.45.4-11
148153
- Fix CVE-2024-35255 with an upstream patch
149154

0 commit comments

Comments
 (0)