summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools
diff options
context:
space:
mode:
authorSoumya Sambu <soumya.sambu@windriver.com>2023-08-25 07:41:38 +0000
committerSteve Sakoman <steve@sakoman.com>2023-08-30 04:46:35 -1000
commitf81d353d5bb44d47217ddc131e32a567534302d4 (patch)
tree388e81b778c9b12576b4b032ac3e3835edabccb4 /meta/recipes-devtools
parente5f546b58b4a049d2ab701f912b40f3a9282d703 (diff)
downloadpoky-f81d353d5bb44d47217ddc131e32a567534302d4.tar.gz
go: Fix CVE-2023-29409
Extremely large RSA keys in certificate chains can cause a client/server to expend significant CPU time verifying signatures. With fix, the size of RSA keys transmitted during handshakes is restricted to <= 8192 bits. Based on a survey of publicly trusted RSA keys, there are currently only three certificates in circulation with keys larger than this, and all three appear to be test certificates that are not actively deployed. It is possible there are larger keys in use in private PKIs, but we target the web PKI, so causing breakage here in the interests of increasing the default safety of users of crypto/tls seems reasonable. References: https://nvd.nist.gov/vuln/detail/CVE-2023-29409 (From OE-Core rev: 51c2fee0e4bb4b3131c61d91510394cd4b4f9eb9) Signed-off-by: Soumya Sambu <soumya.sambu@windriver.com> Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'meta/recipes-devtools')
-rw-r--r--meta/recipes-devtools/go/go-1.17.13.inc1
-rw-r--r--meta/recipes-devtools/go/go-1.19/CVE-2023-29409.patch175
2 files changed, 176 insertions, 0 deletions
diff --git a/meta/recipes-devtools/go/go-1.17.13.inc b/meta/recipes-devtools/go/go-1.17.13.inc
index e0f02f3e28..91dd886cd0 100644
--- a/meta/recipes-devtools/go/go-1.17.13.inc
+++ b/meta/recipes-devtools/go/go-1.17.13.inc
@@ -42,6 +42,7 @@ SRC_URI += "\
42 file://CVE-2023-24536_3.patch \ 42 file://CVE-2023-24536_3.patch \
43 file://CVE-2023-24531_1.patch \ 43 file://CVE-2023-24531_1.patch \
44 file://CVE-2023-24531_2.patch \ 44 file://CVE-2023-24531_2.patch \
45 file://CVE-2023-29409.patch \
45" 46"
46SRC_URI[main.sha256sum] = "a1a48b23afb206f95e7bbaa9b898d965f90826f6f1d1fc0c1d784ada0cd300fd" 47SRC_URI[main.sha256sum] = "a1a48b23afb206f95e7bbaa9b898d965f90826f6f1d1fc0c1d784ada0cd300fd"
47 48
diff --git a/meta/recipes-devtools/go/go-1.19/CVE-2023-29409.patch b/meta/recipes-devtools/go/go-1.19/CVE-2023-29409.patch
new file mode 100644
index 0000000000..38451f7555
--- /dev/null
+++ b/meta/recipes-devtools/go/go-1.19/CVE-2023-29409.patch
@@ -0,0 +1,175 @@
1From 2300f7ef07718f6be4d8aa8486c7de99836e233f Mon Sep 17 00:00:00 2001
2From: Roland Shoemaker <bracewell@google.com>
3Date: Wed, 23 Aug 2023 12:03:43 +0000
4Subject: [PATCH] crypto/tls: restrict RSA keys in certificates to <= 8192 bits
5
6Extremely large RSA keys in certificate chains can cause a client/server
7to expend significant CPU time verifying signatures. Limit this by
8restricting the size of RSA keys transmitted during handshakes to <=
98192 bits.
10
11Based on a survey of publicly trusted RSA keys, there are currently only
12three certificates in circulation with keys larger than this, and all
13three appear to be test certificates that are not actively deployed. It
14is possible there are larger keys in use in private PKIs, but we target
15the web PKI, so causing breakage here in the interests of increasing the
16default safety of users of crypto/tls seems reasonable.
17
18Thanks to Mateusz Poliwczak for reporting this issue.
19
20Updates #61460
21Fixes #61579
22Fixes CVE-2023-29409
23
24Change-Id: Ie35038515a649199a36a12fc2c5df3af855dca6c
25Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1912161
26Reviewed-by: Damien Neil <dneil@google.com>
27Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
28Run-TryBot: Roland Shoemaker <bracewell@google.com>
29(cherry picked from commit d865c715d92887361e4bd5596e19e513f27781b7)
30Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1965487
31Reviewed-on: https://go-review.googlesource.com/c/go/+/514915
32Run-TryBot: David Chase <drchase@google.com>
33Reviewed-by: Matthew Dempsky <mdempsky@google.com>
34TryBot-Bypass: David Chase <drchase@google.com>
35
36CVE: CVE-2023-29409
37
38Upstream-Status: Backport [https://github.com/golang/go/commit/2300f7ef07718f6be4d8aa8486c7de99836e233f]
39
40Signed-off-by: Soumya Sambu <soumya.sambu@windriver.com>
41---
42 src/crypto/tls/handshake_client.go | 8 +++
43 src/crypto/tls/handshake_client_test.go | 78 +++++++++++++++++++++++++
44 src/crypto/tls/handshake_server.go | 4 ++
45 3 files changed, 90 insertions(+)
46
47diff --git a/src/crypto/tls/handshake_client.go b/src/crypto/tls/handshake_client.go
48index 85622f1..828d2cb 100644
49--- a/src/crypto/tls/handshake_client.go
50+++ b/src/crypto/tls/handshake_client.go
51@@ -852,6 +852,10 @@ func (hs *clientHandshakeState) sendFinished(out []byte) error {
52 return nil
53 }
54
55+// maxRSAKeySize is the maximum RSA key size in bits that we are willing
56+// to verify the signatures of during a TLS handshake.
57+const maxRSAKeySize = 8192
58+
59 // verifyServerCertificate parses and verifies the provided chain, setting
60 // c.verifiedChains and c.peerCertificates or sending the appropriate alert.
61 func (c *Conn) verifyServerCertificate(certificates [][]byte) error {
62@@ -862,6 +866,10 @@ func (c *Conn) verifyServerCertificate(certificates [][]byte) error {
63 c.sendAlert(alertBadCertificate)
64 return errors.New("tls: failed to parse certificate from server: " + err.Error())
65 }
66+ if cert.PublicKeyAlgorithm == x509.RSA && cert.PublicKey.(*rsa.PublicKey).N.BitLen() > maxRSAKeySize {
67+ c.sendAlert(alertBadCertificate)
68+ return fmt.Errorf("tls: server sent certificate containing RSA key larger than %d bits", maxRSAKeySize)
69+ }
70 certs[i] = cert
71 }
72
73diff --git a/src/crypto/tls/handshake_client_test.go b/src/crypto/tls/handshake_client_test.go
74index 0228745..d581cb1 100644
75--- a/src/crypto/tls/handshake_client_test.go
76+++ b/src/crypto/tls/handshake_client_test.go
77@@ -2595,3 +2595,81 @@ func TestClientHandshakeContextCancellation(t *testing.T) {
78 t.Error("Client connection was not closed when the context was canceled")
79 }
80 }
81+
82+// discardConn wraps a net.Conn but discards all writes, but reports that they happened.
83+type discardConn struct {
84+ net.Conn
85+}
86+
87+func (dc *discardConn) Write(data []byte) (int, error) {
88+ return len(data), nil
89+}
90+
91+// largeRSAKeyCertPEM contains a 8193 bit RSA key
92+const largeRSAKeyCertPEM = `-----BEGIN CERTIFICATE-----
93+MIIInjCCBIWgAwIBAgIBAjANBgkqhkiG9w0BAQsFADASMRAwDgYDVQQDEwd0ZXN0
94+aW5nMB4XDTIzMDYwNzIxMjMzNloXDTIzMDYwNzIzMjMzNlowEjEQMA4GA1UEAxMH
95+dGVzdGluZzCCBCIwDQYJKoZIhvcNAQEBBQADggQPADCCBAoCggQBAWdHsf6Rh2Ca
96+n2SQwn4t4OQrOjbLLdGE1pM6TBKKrHUFy62uEL8atNjlcfXIsa4aEu3xNGiqxqur
97+ZectlkZbm0FkaaQ1Wr9oikDY3KfjuaXdPdO/XC/h8AKNxlDOylyXwUSK/CuYb+1j
98+gy8yF5QFvVfwW/xwTlHmhUeSkVSQPosfQ6yXNNsmMzkd+ZPWLrfq4R+wiNtwYGu0
99+WSBcI/M9o8/vrNLnIppoiBJJ13j9CR1ToEAzOFh9wwRWLY10oZhoh1ONN1KQURx4
100+qedzvvP2DSjZbUccdvl2rBGvZpzfOiFdm1FCnxB0c72Cqx+GTHXBFf8bsa7KHky9
101+sNO1GUanbq17WoDNgwbY6H51bfShqv0CErxatwWox3we4EcAmFHPVTCYL1oWVMGo
102+a3Eth91NZj+b/nGhF9lhHKGzXSv9brmLLkfvM1jA6XhNhA7BQ5Vz67lj2j3XfXdh
103+t/BU5pBXbL4Ut4mIhT1YnKXAjX2/LF5RHQTE8Vwkx5JAEKZyUEGOReD/B+7GOrLp
104+HduMT9vZAc5aR2k9I8qq1zBAzsL69lyQNAPaDYd1BIAjUety9gAYaSQffCgAgpRO
105+Gt+DYvxS+7AT/yEd5h74MU2AH7KrAkbXOtlwupiGwhMVTstncDJWXMJqbBhyHPF8
106+3UmZH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cvNOT5IBk3X
138+9lwJoZk/B2i+ZMRNSP34ztAwtxmasPt6RAWGQpWCn9qmttAHAnMfDqe7F7jVR6rS
139+u58=
140+-----END CERTIFICATE-----`
141+
142+func TestHandshakeRSATooBig(t *testing.T) {
143+ testCert, _ := pem.Decode([]byte(largeRSAKeyCertPEM))
144+
145+ c := &Conn{conn: &discardConn{}, config: testConfig.Clone()}
146+
147+ expectedErr := "tls: server sent certificate containing RSA key larger than 8192 bits"
148+ err := c.verifyServerCertificate([][]byte{testCert.Bytes})
149+ if err == nil || err.Error() != expectedErr {
150+ t.Errorf("Conn.verifyServerCertificate unexpected error: want %q, got %q", expectedErr, err)
151+ }
152+
153+ expectedErr = "tls: client sent certificate containing RSA key larger than 8192 bits"
154+ err = c.processCertsFromClient(Certificate{Certificate: [][]byte{testCert.Bytes}})
155+ if err == nil || err.Error() != expectedErr {
156+ t.Errorf("Conn.processCertsFromClient unexpected error: want %q, got %q", expectedErr, err)
157+ }
158+}
159diff --git a/src/crypto/tls/handshake_server.go b/src/crypto/tls/handshake_server.go
160index 8d51e7e..a5d8f4a 100644
161--- a/src/crypto/tls/handshake_server.go
162+++ b/src/crypto/tls/handshake_server.go
163@@ -812,6 +812,10 @@ func (c *Conn) processCertsFromClient(certificate Certificate) error {
164 c.sendAlert(alertBadCertificate)
165 return errors.New("tls: failed to parse client certificate: " + err.Error())
166 }
167+ if certs[i].PublicKeyAlgorithm == x509.RSA && certs[i].PublicKey.(*rsa.PublicKey).N.BitLen() > maxRSAKeySize {
168+ c.sendAlert(alertBadCertificate)
169+ return fmt.Errorf("tls: client sent certificate containing RSA key larger than %d bits", maxRSAKeySize)
170+ }
171 }
172
173 if len(certs) == 0 && requiresClientCert(c.config.ClientAuth) {
174--
1752.40.0