Skip to content

Commit 3f88cc7

Browse files
CBL-Mariner-Botbhagyapathakjslobodzian
authored
[AUTO-CHERRYPICK] Patch golang for CVE-2025-22871[High] - branch main (#13512)
Co-authored-by: bhagyapathak <bhagyapathak@users.noreply.github.com> Co-authored-by: jslobodzian <joslobo@microsoft.com>
1 parent 237b307 commit 3f88cc7

3 files changed

Lines changed: 67 additions & 2 deletions

File tree

SPECS/golang/CVE-2025-22871.patch

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
From 7caf9f7ef10cb314f6af9939b8a0cda080e8989d Mon Sep 17 00:00:00 2001
2+
From: Bhagyashri Pathak <bhapathak@microsoft.com>
3+
Date: Tue, 15 Apr 2025 19:08:45 +0530
4+
Subject: [PATCH] Patch for CVE-2025-22871
5+
6+
Upstream patch reference: https://github.com/golang/go/commit/ac1f5aa3d62efe21e65ce4dc30e6996d59acfbd0
7+
---
8+
src/net/http/internal/chunked.go | 19 ++++++++++++++++---
9+
1 file changed, 16 insertions(+), 3 deletions(-)
10+
11+
diff --git a/src/net/http/internal/chunked.go b/src/net/http/internal/chunked.go
12+
index 37a72e9..436c3db 100644
13+
--- a/src/net/http/internal/chunked.go
14+
+++ b/src/net/http/internal/chunked.go
15+
@@ -137,6 +137,19 @@ func readChunkLine(b *bufio.Reader) ([]byte, error) {
16+
}
17+
return nil, err
18+
}
19+
+
20+
+ // RFC 9112 permits parsers to accept a bare \n as a line ending in headers,
21+
+ // but not in chunked encoding lines. See https://www.rfc-editor.org/errata/eid7633,
22+
+ // which explicitly rejects a clarification permitting \n as a chunk terminator.
23+
+ //
24+
+ // Verify that the line ends in a CRLF, and that no CRs appear before the end.
25+
+ if idx := bytes.IndexByte(p, '\r'); idx == -1 {
26+
+ return nil, errors.New("chunked line ends with bare LF")
27+
+ } else if idx != len(p)-2 {
28+
+ return nil, errors.New("invalid CR in chunked line")
29+
+ }
30+
+ p = p[:len(p)-2] // trim CRLF
31+
+
32+
if len(p) >= maxLineLength {
33+
return nil, ErrLineTooLong
34+
}
35+
@@ -149,14 +162,14 @@ func readChunkLine(b *bufio.Reader) ([]byte, error) {
36+
}
37+
38+
func trimTrailingWhitespace(b []byte) []byte {
39+
- for len(b) > 0 && isASCIISpace(b[len(b)-1]) {
40+
+ for len(b) > 0 && isOWS(b[len(b)-1]) {
41+
b = b[:len(b)-1]
42+
}
43+
return b
44+
}
45+
46+
-func isASCIISpace(b byte) bool {
47+
- return b == ' ' || b == '\t' || b == '\n' || b == '\r'
48+
+func isOWS(b byte) bool {
49+
+ return b == ' ' || b == '\t'
50+
}
51+
52+
var semi = []byte(";")
53+
--
54+
2.34.1
55+

SPECS/golang/golang-1.18.spec

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
Summary: Go
1414
Name: golang
1515
Version: 1.18.8
16-
Release: 6%{?dist}
16+
Release: 7%{?dist}
1717
License: BSD-3-Clause
1818
Vendor: Microsoft Corporation
1919
Distribution: Mariner
@@ -28,6 +28,7 @@ Patch1: CVE-2022-41717.patch
2828
Patch2: CVE-2024-24790.patch
2929
Patch3: CVE-2024-45341.patch
3030
Patch4: CVE-2024-34158.patch
31+
Patch5: CVE-2025-22871.patch
3132
Obsoletes: %{name} < %{version}
3233
Provides: %{name} = %{version}
3334
Provides: go = %{version}-%{release}
@@ -48,6 +49,7 @@ patch -Np1 --ignore-whitespace < %{PATCH1}
4849
patch -Np1 --ignore-whitespace < %{PATCH2}
4950
patch -Np1 --ignore-whitespace < %{PATCH3}
5051
patch -Np1 --ignore-whitespace < %{PATCH4}
52+
patch -Np1 --ignore-whitespace < %{PATCH5}
5153

5254
%build
5355
# Build go 1.4 bootstrap
@@ -128,6 +130,9 @@ fi
128130
%{_bindir}/*
129131

130132
%changelog
133+
* Mon Apr 21 2025 Bhagyashri Pathak <bhapathak@microsoft.com> - 1.18.8-7
134+
- Address CVE-2025-22871 using an upstream patch.
135+
131136
* Fri Apr 18 2025 Kshitiz Godara <kgodara@microsoft.com> - 1.18.8-6
132137
- Address CVE-2024-34158 using an upstream patch.
133138

SPECS/golang/golang.spec

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
Summary: Go
1616
Name: golang
1717
Version: 1.22.7
18-
Release: 2%{?dist}
18+
Release: 3%{?dist}
1919
License: BSD-3-Clause
2020
Vendor: Microsoft Corporation
2121
Distribution: Mariner
@@ -28,6 +28,7 @@ Source3: https://dl.google.com/go/go%{bootstrap_compiler_version_1}.src.t
2828
Patch0: go14_bootstrap_aarch64.patch
2929
Patch1: CVE-2024-45336.patch
3030
Patch2: CVE-2024-45341.patch
31+
Patch3: CVE-2025-22871.patch
3132
Obsoletes: %{name} < %{version}
3233
Provides: %{name} = %{version}
3334
Provides: go = %{version}-%{release}
@@ -45,6 +46,7 @@ mv -v go go-bootstrap
4546
%setup -q -n go
4647
%patch 1 -p1
4748
%patch 2 -p1
49+
%patch 3 -p1
4850

4951
%build
5052
# Go 1.22 requires the final point release of Go 1.20 or later for bootstrap.
@@ -160,6 +162,9 @@ fi
160162
%{_bindir}/*
161163

162164
%changelog
165+
* Thu Apr 10 2025 Bhagyashri Pathak <bhapathak@microsoft.com> - 1.22.7-3
166+
- Address CVE-2025-22871 using an upstream patch.
167+
163168
* Tue Feb 04 2025 Kanishk bansal <kanbansal@microsoft.com> - 1.22.7-2
164169
- Address CVE-2024-45336, CVE-2024-45341 using an upstream patch.
165170

0 commit comments

Comments
 (0)