Skip to content

Commit f25f496

Browse files
mayankfzMayank Singh
andauthored
Patch telegraf for CVE-2025-22872 [Medium] (#13525)
Signed-off-by: Mayank Singh <mayansingh@microsoft.com> Co-authored-by: Mayank Singh <mayansingh@microsoft.com>
1 parent e85b5be commit f25f496

2 files changed

Lines changed: 48 additions & 5 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
From c3bde8676a99155b88f7d0342e1e6b36a3f83324 Mon Sep 17 00:00:00 2001
2+
From: Mayank Singh <mayansingh@microsoft.com>
3+
Date: Tue, 22 Apr 2025 05:00:39 +0000
4+
Subject: [PATCH] Address CVE-2025-22872.patch
5+
Upstream Reference Link: https://github.com/golang/net/commit/e1fcd82abba34df74614020343be8eb1fe85f0d9
6+
7+
---
8+
vendor/golang.org/x/net/html/token.go | 18 ++++++++++++++++--
9+
1 file changed, 16 insertions(+), 2 deletions(-)
10+
11+
diff --git a/vendor/golang.org/x/net/html/token.go b/vendor/golang.org/x/net/html/token.go
12+
index 3c57880d..6598c1f7 100644
13+
--- a/vendor/golang.org/x/net/html/token.go
14+
+++ b/vendor/golang.org/x/net/html/token.go
15+
@@ -839,8 +839,22 @@ func (z *Tokenizer) readStartTag() TokenType {
16+
if raw {
17+
z.rawTag = strings.ToLower(string(z.buf[z.data.start:z.data.end]))
18+
}
19+
- // Look for a self-closing token like "<br/>".
20+
- if z.err == nil && z.buf[z.raw.end-2] == '/' {
21+
+ // Look for a self-closing token (e.g. <br/>).
22+
+ //
23+
+ // Originally, we did this by just checking that the last character of the
24+
+ // tag (ignoring the closing bracket) was a solidus (/) character, but this
25+
+ // is not always accurate.
26+
+ //
27+
+ // We need to be careful that we don't misinterpret a non-self-closing tag
28+
+ // as self-closing, as can happen if the tag contains unquoted attribute
29+
+ // values (i.e. <p a=/>).
30+
+ //
31+
+ // To avoid this, we check that the last non-bracket character of the tag
32+
+ // (z.raw.end-2) isn't the same character as the last non-quote character of
33+
+ // the last attribute of the tag (z.pendingAttr[1].end-1), if the tag has
34+
+ // attributes.
35+
+ nAttrs := len(z.attr)
36+
+ if z.err == nil && z.buf[z.raw.end-2] == '/' && (nAttrs == 0 || z.raw.end-2 != z.attr[nAttrs-1][1].end-1) {
37+
return SelfClosingTagToken
38+
}
39+
return StartTagToken
40+
--
41+
2.45.3
42+

SPECS/telegraf/telegraf.spec

Lines changed: 6 additions & 5 deletions
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: 9%{?dist}
4+
Release: 10%{?dist}
55
License: MIT
66
Vendor: Microsoft Corporation
77
Distribution: Azure Linux
@@ -22,6 +22,7 @@ Patch7: CVE-2024-51744.patch
2222
Patch8: CVE-2025-30204.patch
2323
Patch9: CVE-2025-27144.patch
2424
Patch10: CVE-2025-30215.patch
25+
Patch11: CVE-2025-22872.patch
2526

2627
BuildRequires: golang
2728
BuildRequires: systemd-devel
@@ -42,10 +43,7 @@ the community can easily add support for collecting metrics from well known serv
4243
Postgres, or Redis) and third party APIs (like Mailchimp, AWS CloudWatch, or Google Analytics).
4344

4445
%prep
45-
%autosetup -N
46-
# setup vendor before patching
47-
tar -xf %{SOURCE1} --no-same-owner
48-
%autopatch -p1
46+
%autosetup -a1 -p1
4947

5048
%build
5149
go build -mod=vendor ./cmd/telegraf
@@ -89,6 +87,9 @@ fi
8987
%dir %{_sysconfdir}/%{name}/telegraf.d
9088

9189
%changelog
90+
* Tue Apr 22 2025 Mayank Singh <mayansingh@microsoft.com> - 1.31.0-10
91+
- Fix CVE-2025-22872 with an upstream patch
92+
9293
* Thu Apr 17 2025 Sudipta Pandit <sudpandit@microsoft.com> - 1.31.0-9
9394
- Patch CVE-2025-30215
9495

0 commit comments

Comments
 (0)