From 2257649bc3b8a5a54b8ab3ed67a2a261628208a2 Mon Sep 17 00:00:00 2001 From: hanchao Date: Mon, 15 Apr 2024 13:08:00 +0800 Subject: [PATCH] backport: fix CVE-2023-45288 --- ...p-update-bundled-golang.org-x-net-ht.patch | 88 +++++++++++++++++++ golang.spec | 9 +- 2 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 0120-Backport-net-http-update-bundled-golang.org-x-net-ht.patch diff --git a/0120-Backport-net-http-update-bundled-golang.org-x-net-ht.patch b/0120-Backport-net-http-update-bundled-golang.org-x-net-ht.patch new file mode 100644 index 0000000..877e735 --- /dev/null +++ b/0120-Backport-net-http-update-bundled-golang.org-x-net-ht.patch @@ -0,0 +1,88 @@ +From a5f9012235b09aa36007efe2346c07ba68c9e1bf Mon Sep 17 00:00:00 2001 +From: Damien Neil +Date: Thu, 28 Mar 2024 16:49:40 -0700 +Subject: [PATCH] [Backport] net/http: update bundled golang.org/x/net/http2 + +Offering: Cloud Core Network +CVE: CVE-2023-45288 +Reference: https://go-review.googlesource.com/c/go/+/576075 + +Disable cmd/internal/moddeps test, since this update includes PRIVATE +track fixes. + +Note: The upstream does not submit this change to go1.16 according to the rules of MinorReleases. +Corego2.x are based on go1.16.5. Therefore, it need to submit the change to corego2.x. + +Edited-by: machangwang m00509938 + +Fixes CVE-2023-45288 +For #65051 +Fixes #65387 + +Change-Id: I17da6da2fe0dd70062b49f94377875acb34829a1 +Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/2197267 +Reviewed-by: Dmitri Shuralyov +Run-TryBot: Damien Neil +Reviewed-by: Tatiana Bradley +Reviewed-on: https://go-review.googlesource.com/c/go/+/576075 +TryBot-Bypass: Dmitri Shuralyov +Commit-Queue: Dmitri Shuralyov +Auto-Submit: Dmitri Shuralyov +Reviewed-by: Than McIntosh +Signed-off-by: Ma Chang Wang machangwang@huawei.com +--- + src/net/http/h2_bundle.go | 31 +++++++++++++++++++++++++++++++ + 1 file changed, 31 insertions(+) + +diff --git a/src/net/http/h2_bundle.go b/src/net/http/h2_bundle.go +index c539654998..634c7c76f8 100644 +--- a/src/net/http/h2_bundle.go ++++ b/src/net/http/h2_bundle.go +@@ -2764,6 +2764,7 @@ func (fr *http2Framer) readMetaFrame(hf *http2HeadersFrame) (*http2MetaHeadersFr + if size > remainSize { + hdec.SetEmitEnabled(false) + mh.Truncated = true ++ remainSize = 0 + return + } + remainSize -= size +@@ -2776,6 +2777,36 @@ func (fr *http2Framer) readMetaFrame(hf *http2HeadersFrame) (*http2MetaHeadersFr + var hc http2headersOrContinuation = hf + for { + frag := hc.HeaderBlockFragment() ++ ++ // Avoid parsing large amounts of headers that we will then discard. ++ // If the sender exceeds the max header list size by too much, ++ // skip parsing the fragment and close the connection. ++ // ++ // "Too much" is either any CONTINUATION frame after we've already ++ // exceeded the max header list size (in which case remainSize is 0), ++ // or a frame whose encoded size is more than twice the remaining ++ // header list bytes we're willing to accept. ++ if int64(len(frag)) > int64(2*remainSize) { ++ if http2VerboseLogs { ++ log.Printf("http2: header list too large") ++ } ++ // It would be nice to send a RST_STREAM before sending the GOAWAY, ++ // but the struture of the server's frame writer makes this difficult. ++ return nil, http2ConnectionError(http2ErrCodeProtocol) ++ } ++ ++ // Also close the connection after any CONTINUATION frame following an ++ // invalid header, since we stop tracking the size of the headers after ++ // an invalid one. ++ if invalid != nil { ++ if http2VerboseLogs { ++ log.Printf("http2: invalid header: %v", invalid) ++ } ++ // It would be nice to send a RST_STREAM before sending the GOAWAY, ++ // but the struture of the server's frame writer makes this difficult. ++ return nil, http2ConnectionError(http2ErrCodeProtocol) ++ } ++ + if _, err := hdec.Write(frag); err != nil { + return nil, http2ConnectionError(http2ErrCodeCompression) + } +-- +2.33.0 + diff --git a/golang.spec b/golang.spec index 38b965c..eb8a52e 100644 --- a/golang.spec +++ b/golang.spec @@ -58,7 +58,7 @@ Name: golang Version: 1.15.7 -Release: 42 +Release: 43 Summary: The Go Programming Language License: BSD and Public Domain URL: https://golang.org/ @@ -261,6 +261,7 @@ Patch6116: 0116-release-branch.go1.21-net-http-net-http-cookiejar-av.patch Patch6117: 0117-Backport-net-mail-properly-handle-special-characters.patch Patch6118: 0118-1.15-backport-runtime-decrement-netpollWaiters-in-ne.patch Patch6119: 0119-1.15-backport-runtime-adjust-netpollWaiters-after-go.patch +Patch6120: 0120-Backport-net-http-update-bundled-golang.org-x-net-ht.patch Patch9001: 0001-drop-hard-code-cert.patch Patch9002: 0002-fix-patch-cmd-go-internal-modfetch-do-not-sho.patch @@ -500,6 +501,12 @@ fi %files devel -f go-tests.list -f go-misc.list -f go-src.list %changelog +* Mon Apr 15 2024 hanchao - 1.15.7-43 +- Type:CVE +- CVE:CVE-2023-45288 +- SUG:NA +- DESC:fix CVE-2023-45288 + * Thu Mar 28 2024 wangshuo - 1.15.7-42 - Type:bugfix - ID:NA -- Gitee