Skip to content

Commit 57d8eaa

Browse files
[AUTO-CHERRYPICK] Patch msft-golang for CVE-2025-22871 [High] - branch main (#13462)
Co-authored-by: bhagyapathak <bhagyapathak@users.noreply.github.com>
1 parent ad67d53 commit 57d8eaa

2 files changed

Lines changed: 61 additions & 2 deletions

File tree

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/msft-golang/msft-golang.spec

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
Summary: Go
1616
Name: msft-golang
1717
Version: 1.24.1
18-
Release: 1%{?dist}
18+
Release: 2%{?dist}
1919
License: BSD
2020
Vendor: Microsoft Corporation
2121
Distribution: Mariner
@@ -31,6 +31,7 @@ Source3: https://github.com/microsoft/go/releases/download/v1.20.14-1/go.
3131
# bootstrap 03
3232
Source4: https://github.com/microsoft/go/releases/download/v1.22.12-2/go1.22.12-20250211.4.src.tar.gz
3333
Patch0: go14_bootstrap_aarch64.patch
34+
Patch1: CVE-2025-22871.patch
3435
Conflicts: go
3536
Conflicts: golang
3637

@@ -53,7 +54,7 @@ tar xf %{SOURCE4} --no-same-owner
5354
mv -v go go-bootstrap-03
5455

5556
%setup -q -n go
56-
57+
patch -Np1 --ignore-whitespace < %{PATCH1}
5758
%build
5859
# go 1.4 bootstraps with C.
5960
# go 1.20 bootstraps with go >= 1.17.13
@@ -159,6 +160,9 @@ fi
159160
%{_bindir}/*
160161

161162
%changelog
163+
Mon Apr 14 2025 Bhagyashri Pathak <bhapathak@microsoft.com> - 1.24.1-2
164+
- Patch to address CVE-2025-22871
165+
162166
* Mon Mar 31 2025 Andrew Phelps <anphel@microsoft.com> - 1.24.1-1
163167
- Bump version to 1.24.1 to address CVE-2025-22870, CVE-2024-45341, CVE-2024-45336, CVE-2024-34158
164168

0 commit comments

Comments
 (0)