Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Medium] Patch telegraf for CVE-2025-22870 and CVE-2024-51744 #13245

Open
wants to merge 1 commit into
base: fasttrack/2.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions SPECS/telegraf/CVE-2024-51744.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
From 4bd952e94db0897447aeff4b61e9fb98f6077aa1 Mon Sep 17 00:00:00 2001
From: Sreenivasulu Malavathula <v-smalavathu@microsoft.com>
Date: Mon, 31 Mar 2025 16:56:12 -0500
Subject: [PATCH] Address CVE-2024-51744
Upstream Patch Reference: https://github.com/golang-jwt/jwt/commit/7b1c1c00a171c6c79bbdb40e4ce7d197060c1c2c

---
vendor/github.com/golang-jwt/jwt/v4/parser.go | 41 +++++++++----------
1 file changed, 20 insertions(+), 21 deletions(-)

diff --git a/vendor/github.com/golang-jwt/jwt/v4/parser.go b/vendor/github.com/golang-jwt/jwt/v4/parser.go
index 8e7e67c4..0fc510a0 100644
--- a/vendor/github.com/golang-jwt/jwt/v4/parser.go
+++ b/vendor/github.com/golang-jwt/jwt/v4/parser.go
@@ -38,19 +38,21 @@ func NewParser(options ...ParserOption) *Parser {
return p
}

-// Parse parses, validates, verifies the signature and returns the parsed token.
-// keyFunc will receive the parsed token and should return the key for validating.
+// Parse parses, validates, verifies the signature and returns the parsed token. keyFunc will
+// receive the parsed token and should return the key for validating.
func (p *Parser) Parse(tokenString string, keyFunc Keyfunc) (*Token, error) {
return p.ParseWithClaims(tokenString, MapClaims{}, keyFunc)
}

-// ParseWithClaims parses, validates, and verifies like Parse, but supplies a default object implementing the Claims
-// interface. This provides default values which can be overridden and allows a caller to use their own type, rather
-// than the default MapClaims implementation of Claims.
+// ParseWithClaims parses, validates, and verifies like Parse, but supplies a default object
+// implementing the Claims interface. This provides default values which can be overridden and
+// allows a caller to use their own type, rather than the default MapClaims implementation of
+// Claims.
//
-// Note: If you provide a custom claim implementation that embeds one of the standard claims (such as RegisteredClaims),
-// make sure that a) you either embed a non-pointer version of the claims or b) if you are using a pointer, allocate the
-// proper memory for it before passing in the overall claims, otherwise you might run into a panic.
+// Note: If you provide a custom claim implementation that embeds one of the standard claims (such
+// as RegisteredClaims), make sure that a) you either embed a non-pointer version of the claims or
+// b) if you are using a pointer, allocate the proper memory for it before passing in the overall
+// claims, otherwise you might run into a panic.
func (p *Parser) ParseWithClaims(tokenString string, claims Claims, keyFunc Keyfunc) (*Token, error) {
token, parts, err := p.ParseUnverified(tokenString, claims)
if err != nil {
@@ -87,12 +89,17 @@ func (p *Parser) ParseWithClaims(tokenString string, claims Claims, keyFunc Keyf
return token, &ValidationError{Inner: err, Errors: ValidationErrorUnverifiable}
}

+ // Perform validation
+ token.Signature = parts[2]
+ if err := token.Method.Verify(strings.Join(parts[0:2], "."), token.Signature, key); err != nil {
+ return token, &ValidationError{Inner: err, Errors: ValidationErrorSignatureInvalid}
+ }
+
vErr := &ValidationError{}

// Validate Claims
if !p.SkipClaimsValidation {
if err := token.Claims.Valid(); err != nil {
-
// If the Claims Valid returned an error, check if it is a validation error,
// If it was another error type, create a ValidationError with a generic ClaimsInvalid flag set
if e, ok := err.(*ValidationError); !ok {
@@ -100,22 +107,14 @@ func (p *Parser) ParseWithClaims(tokenString string, claims Claims, keyFunc Keyf
} else {
vErr = e
}
+ return token, vErr
}
}

- // Perform validation
- token.Signature = parts[2]
- if err = token.Method.Verify(strings.Join(parts[0:2], "."), token.Signature, key); err != nil {
- vErr.Inner = err
- vErr.Errors |= ValidationErrorSignatureInvalid
- }
-
- if vErr.valid() {
- token.Valid = true
- return token, nil
- }
+ // No errors so far, token is valid.
+ token.Valid = true

- return token, vErr
+ return token, nil
}

// ParseUnverified parses the token but doesn't validate the signature.
--
2.45.2

48 changes: 48 additions & 0 deletions SPECS/telegraf/CVE-2025-22870.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
From 26e8e415585682d6c42f4808f71c035ab0bbe792 Mon Sep 17 00:00:00 2001
From: Sreenivasulu Malavathula <v-smalavathu@microsoft.com>
Date: Mon, 31 Mar 2025 16:50:08 -0500
Subject: [PATCH] Address CVE-2025-22870
Upstream Patch Reference: https://github.com/golang/go/commit/25177ecde0922c50753c043579d17828b7ee88e7

---
vendor/golang.org/x/net/http/httpproxy/proxy.go | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/vendor/golang.org/x/net/http/httpproxy/proxy.go b/vendor/golang.org/x/net/http/httpproxy/proxy.go
index c3bd9a1e..864961c7 100644
--- a/vendor/golang.org/x/net/http/httpproxy/proxy.go
+++ b/vendor/golang.org/x/net/http/httpproxy/proxy.go
@@ -14,6 +14,7 @@ import (
"errors"
"fmt"
"net"
+ "net/netip"
"net/url"
"os"
"strings"
@@ -180,8 +181,10 @@ func (cfg *config) useProxy(addr string) bool {
if host == "localhost" {
return false
}
- ip := net.ParseIP(host)
- if ip != nil {
+ nip, err := netip.ParseAddr(host)
+ var ip net.IP
+ if err == nil {
+ ip = net.IP(nip.AsSlice())
if ip.IsLoopback() {
return false
}
@@ -363,6 +366,9 @@ type domainMatch struct {
}

func (m domainMatch) match(host, port string, ip net.IP) bool {
+ if ip != nil {
+ return false
+ }
if strings.HasSuffix(host, m.host) || (m.matchHost && host == m.host[1:]) {
return m.port == "" || m.port == port
}
--
2.45.2

7 changes: 6 additions & 1 deletion SPECS/telegraf/telegraf.spec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Summary: agent for collecting, processing, aggregating, and writing metrics.
Name: telegraf
Version: 1.29.4
Release: 13%{?dist}
Release: 14%{?dist}
License: MIT
Vendor: Microsoft Corporation
Distribution: Mariner
Expand All @@ -23,6 +23,8 @@ Patch9: CVE-2025-22868.patch
Patch10: CVE-2025-22869.patch
Patch11: CVE-2025-27144.patch
Patch12: CVE-2025-30204.patch
Patch13: CVE-2025-22870.patch
Patch14: CVE-2024-51744.patch
BuildRequires: golang
BuildRequires: iana-etc
BuildRequires: systemd-devel
Expand Down Expand Up @@ -93,6 +95,9 @@ fi
%dir %{_sysconfdir}/%{name}/telegraf.d

%changelog
* Mon Mar 31 2025 Sreeniavsulu Malavathula <v-smalavathu@microsoft.com> - 1.29.4-14
- Patch to fix CVE-2025-22870, CVE-2024-51744 with an upstream patch

* Mon Mar 31 2025 Kanishk Bansal <kanbansal@microsoft.com> - 1.29.4-13
- Patch CVE-2025-30204

Expand Down
Loading