summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorMing Liu <liu.ming50@gmail.com>2024-02-12 13:15:11 +0100
committerSteve Sakoman <steve@sakoman.com>2024-02-16 03:35:51 -1000
commiteb0915c699fbe86488de172d529f073a30d05b6a (patch)
treeee71a04d81481cc4daaa79ef4b94ea168537b9e0 /meta
parent5c5d9d5bccf6a33ee636b3d9c684232eca8c60c5 (diff)
downloadpoky-eb0915c699fbe86488de172d529f073a30d05b6a.tar.gz
go: add a complementary fix for CVE-2023-29406
The original CVE-2023-29406.patch is not complete, causing docker failures at runtime, backport a complementary fix from golang upstream. (From OE-Core rev: bff621d5399e5ff2930d21f403bb2f274febd2e4) Signed-off-by: Ming Liu <liu.ming50@gmail.com> Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'meta')
-rw-r--r--meta/recipes-devtools/go/go-1.14.inc3
-rw-r--r--meta/recipes-devtools/go/go-1.14/CVE-2023-29406-1.patch (renamed from meta/recipes-devtools/go/go-1.14/CVE-2023-29406.patch)0
-rw-r--r--meta/recipes-devtools/go/go-1.14/CVE-2023-29406-2.patch114
3 files changed, 116 insertions, 1 deletions
diff --git a/meta/recipes-devtools/go/go-1.14.inc b/meta/recipes-devtools/go/go-1.14.inc
index 42a9ac8435..4fbf9d7590 100644
--- a/meta/recipes-devtools/go/go-1.14.inc
+++ b/meta/recipes-devtools/go/go-1.14.inc
@@ -71,7 +71,8 @@ SRC_URI += "\
71 file://CVE-2023-29402.patch \ 71 file://CVE-2023-29402.patch \
72 file://CVE-2023-29404.patch \ 72 file://CVE-2023-29404.patch \
73 file://CVE-2023-29400.patch \ 73 file://CVE-2023-29400.patch \
74 file://CVE-2023-29406.patch \ 74 file://CVE-2023-29406-1.patch \
75 file://CVE-2023-29406-2.patch \
75 file://CVE-2023-29409.patch \ 76 file://CVE-2023-29409.patch \
76 file://CVE-2022-41725-pre1.patch \ 77 file://CVE-2022-41725-pre1.patch \
77 file://CVE-2022-41725-pre2.patch \ 78 file://CVE-2022-41725-pre2.patch \
diff --git a/meta/recipes-devtools/go/go-1.14/CVE-2023-29406.patch b/meta/recipes-devtools/go/go-1.14/CVE-2023-29406-1.patch
index 080def4682..080def4682 100644
--- a/meta/recipes-devtools/go/go-1.14/CVE-2023-29406.patch
+++ b/meta/recipes-devtools/go/go-1.14/CVE-2023-29406-1.patch
diff --git a/meta/recipes-devtools/go/go-1.14/CVE-2023-29406-2.patch b/meta/recipes-devtools/go/go-1.14/CVE-2023-29406-2.patch
new file mode 100644
index 0000000000..637f46a537
--- /dev/null
+++ b/meta/recipes-devtools/go/go-1.14/CVE-2023-29406-2.patch
@@ -0,0 +1,114 @@
1From c08a5fa413a34111c9a37fd9e545de27ab0978b1 Mon Sep 17 00:00:00 2001
2From: Damien Neil <dneil@google.com>
3Date: Wed, 19 Jul 2023 10:30:46 -0700
4Subject: [PATCH] [release-branch.go1.19] net/http: permit requests with
5 invalid Host headers
6
7Historically, the Transport has silently truncated invalid
8Host headers at the first '/' or ' ' character. CL 506996 changed
9this behavior to reject invalid Host headers entirely.
10Unfortunately, Docker appears to rely on the previous behavior.
11
12When sending a HTTP/1 request with an invalid Host, send an empty
13Host header. This is safer than truncation: If you care about the
14Host, then you should get the one you set; if you don't care,
15then an empty Host should be fine.
16
17Continue to fully validate Host headers sent to a proxy,
18since proxies generally can't productively forward requests
19without a Host.
20
21For #60374
22Fixes #61431
23Fixes #61825
24
25Change-Id: If170c7dd860aa20eb58fe32990fc93af832742b6
26Reviewed-on: https://go-review.googlesource.com/c/go/+/511155
27TryBot-Result: Gopher Robot <gobot@golang.org>
28Reviewed-by: Roland Shoemaker <roland@golang.org>
29Run-TryBot: Damien Neil <dneil@google.com>
30(cherry picked from commit b9153f6ef338baee5fe02a867c8fbc83a8b29dd1)
31Reviewed-on: https://go-review.googlesource.com/c/go/+/518855
32Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
33Run-TryBot: Roland Shoemaker <roland@golang.org>
34Reviewed-by: Russ Cox <rsc@golang.org>
35
36Upstream-Status: Backport [https://github.com/golang/go/commit/c08a5fa413a34111c9a37fd9e545de27ab0978b1]
37CVE: CVE-2023-29406
38Signed-off-by: Ming Liu <liu.ming50@gmail.com>
39---
40 src/net/http/request.go | 23 ++++++++++++++++++++++-
41 src/net/http/request_test.go | 17 ++++++++++++-----
42 2 files changed, 34 insertions(+), 6 deletions(-)
43
44diff --git a/src/net/http/request.go b/src/net/http/request.go
45index 3100037386..91cb8a66b9 100644
46--- a/src/net/http/request.go
47+++ b/src/net/http/request.go
48@@ -582,8 +582,29 @@ func (r *Request) write(w io.Writer, usingProxy bool, extraHeaders Header, waitF
49 if err != nil {
50 return err
51 }
52+ // Validate that the Host header is a valid header in general,
53+ // but don't validate the host itself. This is sufficient to avoid
54+ // header or request smuggling via the Host field.
55+ // The server can (and will, if it's a net/http server) reject
56+ // the request if it doesn't consider the host valid.
57 if !httpguts.ValidHostHeader(host) {
58- return errors.New("http: invalid Host header")
59+ // Historically, we would truncate the Host header after '/' or ' '.
60+ // Some users have relied on this truncation to convert a network
61+ // address such as Unix domain socket path into a valid, ignored
62+ // Host header (see https://go.dev/issue/61431).
63+ //
64+ // We don't preserve the truncation, because sending an altered
65+ // header field opens a smuggling vector. Instead, zero out the
66+ // Host header entirely if it isn't valid. (An empty Host is valid;
67+ // see RFC 9112 Section 3.2.)
68+ //
69+ // Return an error if we're sending to a proxy, since the proxy
70+ // probably can't do anything useful with an empty Host header.
71+ if !usingProxy {
72+ host = ""
73+ } else {
74+ return errors.New("http: invalid Host header")
75+ }
76 }
77
78 // According to RFC 6874, an HTTP client, proxy, or other
79diff --git a/src/net/http/request_test.go b/src/net/http/request_test.go
80index fddc85d6a9..dd1e2dc2a1 100644
81--- a/src/net/http/request_test.go
82+++ b/src/net/http/request_test.go
83@@ -770,16 +770,23 @@ func TestRequestWriteBufferedWriter(t *testing.T) {
84 }
85 }
86
87-func TestRequestBadHost(t *testing.T) {
88+func TestRequestBadHostHeader(t *testing.T) {
89 got := []string{}
90 req, err := NewRequest("GET", "http://foo/after", nil)
91 if err != nil {
92 t.Fatal(err)
93 }
94- req.Host = "foo.com with spaces"
95- req.URL.Host = "foo.com with spaces"
96- if err := req.Write(logWrites{t, &got}); err == nil {
97- t.Errorf("Writing request with invalid Host: succeded, want error")
98+ req.Host = "foo.com\nnewline"
99+ req.URL.Host = "foo.com\nnewline"
100+ req.Write(logWrites{t, &got})
101+ want := []string{
102+ "GET /after HTTP/1.1\r\n",
103+ "Host: \r\n",
104+ "User-Agent: " + DefaultUserAgent + "\r\n",
105+ "\r\n",
106+ }
107+ if !reflect.DeepEqual(got, want) {
108+ t.Errorf("Writes = %q\n Want = %q", got, want)
109 }
110 }
111
112--
1132.34.1
114