Skip to content

Commit 30afeb5

Browse files
[AUTO-CHERRYPICK] [Medium] Patch keda for CVE-2025-22870 and CVE-2024-51744 - branch main (#13221)
Co-authored-by: Sreenivasulu Malavathula (HCL Technologies Ltd) <v-smalavathu@microsoft.com>
1 parent 2ec1f91 commit 30afeb5

3 files changed

Lines changed: 139 additions & 1 deletion

File tree

SPECS/keda/CVE-2024-51744.patch

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

SPECS/keda/CVE-2025-22870.patch

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

SPECS/keda/keda.spec

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Summary: Kubernetes-based Event Driven Autoscaling
22
Name: keda
33
Version: 2.4.0
4-
Release: 28%{?dist}
4+
Release: 29%{?dist}
55
License: ASL 2.0
66
Vendor: Microsoft Corporation
77
Distribution: Mariner
@@ -37,6 +37,8 @@ Patch5: CVE-2024-45338.patch
3737
Patch6: CVE-2024-28180.patch
3838
Patch7: CVE-2025-27144.patch
3939
Patch8: CVE-2022-3162.patch
40+
Patch9: CVE-2025-22870.patch
41+
Patch10: CVE-2024-51744.patch
4042

4143
BuildRequires: golang
4244

@@ -72,6 +74,9 @@ cp ./bin/keda-adapter %{buildroot}%{_bindir}
7274
%{_bindir}/%{name}-adapter
7375

7476
%changelog
77+
* Fri Mar 14 2025 Sreeniavsulu Malavathula <v-smalavathu@microsoft.com> - 2.4.0-29
78+
- Patch to fix CVE-2025-22870, CVE-2024-51744 with an upstream patch
79+
7580
* Thu Mar 06 2025 Sandeep Karambelkar <skarambelkar@microsoft.com> - 2.4.0-28
7681
- Fix CVE-2022-3162 with upstream patch
7782

0 commit comments

Comments
 (0)