Skip to content

Commit 0c1e3a6

Browse files
[AUTO-CHERRYPICK] [Medium] Patch telegraf for CVE-2025-22870 and CVE-2024-51744 - branch 3.0-dev (#13161)
Co-authored-by: Sreenivasulu Malavathula (HCL Technologies Ltd) <v-smalavathu@microsoft.com>
1 parent 4148d4d commit 0c1e3a6

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 d579cfcd4359e79a390ac4d166a0affdf3e263d4 Mon Sep 17 00:00:00 2001
2+
From: Sreenivasulu Malavathula <v-smalavathu@microsoft.com>
3+
Date: Wed, 26 Mar 2025 15:37:27 -0500
4+
Subject: [PATCH] Addressing 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 c0a6f692..9dd36e5a 100644
13+
--- a/vendor/github.com/golang-jwt/jwt/v4/parser.go
14+
+++ b/vendor/github.com/golang-jwt/jwt/v4/parser.go
15+
@@ -36,19 +36,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+
@@ -85,12 +87,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+
@@ -98,22 +105,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 02f7d1db9057c5a70b3267d2b5288f98035c5a64 Mon Sep 17 00:00:00 2001
2+
From: Sreenivasulu Malavathula <v-smalavathu@microsoft.com>
3+
Date: Wed, 26 Mar 2025 15:29:29 -0500
4+
Subject: [PATCH] Addressing 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 6404aaf1..d89c257a 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+
@@ -177,8 +178,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+
@@ -360,6 +363,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/telegraf/telegraf.spec

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Summary: agent for collecting, processing, aggregating, and writing metrics.
22
Name: telegraf
33
Version: 1.31.0
4-
Release: 5%{?dist}
4+
Release: 6%{?dist}
55
License: MIT
66
Vendor: Microsoft Corporation
77
Distribution: Azure Linux
@@ -15,6 +15,8 @@ Patch1: CVE-2024-45337.patch
1515
Patch2: CVE-2024-45338.patch
1616
Patch3: CVE-2025-22868.patch
1717
Patch4: CVE-2025-22869.patch
18+
Patch5: CVE-2025-22870.patch
19+
Patch6: CVE-2024-51744.patch
1820
BuildRequires: golang
1921
BuildRequires: systemd-devel
2022
Requires: logrotate
@@ -81,6 +83,9 @@ fi
8183
%dir %{_sysconfdir}/%{name}/telegraf.d
8284

8385
%changelog
86+
* Tue Mar 26 2025 Sreeniavsulu Malavathula <v-smalavathu@microsoft.com> - 1.31.0-6
87+
- Fix CVE-2025-22870, CVE-2024-51744 with an upstream patch
88+
8489
* Wed Mar 05 2025 Kanishk Bansal <kanbansal@microsoft.com> - 1.31.0-5
8590
- Patch CVE-2025-22868, CVE-2025-22869
8691

0 commit comments

Comments
 (0)