diff options
author | Poonam Jadhav <Poonam.Jadhav@kpit.com> | 2023-03-03 18:02:12 +0530 |
---|---|---|
committer | Armin Kuster <akuster808@gmail.com> | 2023-03-18 16:16:42 -0400 |
commit | df7fba37446e8af5f043b7d4ba0e2611578a016f (patch) | |
tree | 0b949a22464c09124309601bd181ff04e6d2247c | |
parent | 0a7d275985afc53ea86d994b6e5e711996c9cbf7 (diff) | |
download | meta-openembedded-df7fba37446e8af5f043b7d4ba0e2611578a016f.tar.gz |
nodejs: Fix CVE-2022-32212
Add patch to fix CVE-2022-32212
Link: https://sources.debian.org/src/nodejs/12.22.12~dfsg-1~deb11u3/debian/patches/cve-2022-32212.patch
Signed-off-by: Poonam Jadhav <Poonam.Jadhav@kpit.com>
Signed-off-by: Omkar Patil <omkarpatil10.93@gmail.com>
Signed-off-by: Armin Kuster <akuster808@gmail.com>
-rw-r--r-- | meta-oe/recipes-devtools/nodejs/nodejs/CVE-2022-32212.patch | 133 | ||||
-rw-r--r-- | meta-oe/recipes-devtools/nodejs/nodejs_12.22.12.bb | 1 |
2 files changed, 134 insertions, 0 deletions
diff --git a/meta-oe/recipes-devtools/nodejs/nodejs/CVE-2022-32212.patch b/meta-oe/recipes-devtools/nodejs/nodejs/CVE-2022-32212.patch new file mode 100644 index 0000000000..f7b4b61f47 --- /dev/null +++ b/meta-oe/recipes-devtools/nodejs/nodejs/CVE-2022-32212.patch | |||
@@ -0,0 +1,133 @@ | |||
1 | commit 48c5aa5cab718d04473fa2761d532657c84b8131 | ||
2 | Author: Tobias Nießen <tniessen@tnie.de> | ||
3 | Date: Fri May 27 21:18:49 2022 +0000 | ||
4 | |||
5 | src: fix IPv4 validation in inspector_socket | ||
6 | |||
7 | Co-authored-by: RafaelGSS <rafael.nunu@hotmail.com> | ||
8 | PR-URL: https://github.com/nodejs-private/node-private/pull/320 | ||
9 | Backport-PR-URL: https://github.com/nodejs-private/node-private/pull/325 | ||
10 | Reviewed-By: Matteo Collina <matteo.collina@gmail.com> | ||
11 | Reviewed-By: RafaelGSS <rafael.nunu@hotmail.com> | ||
12 | CVE-ID: CVE-2022-32212 | ||
13 | |||
14 | CVE: CVE-2022-32212 | ||
15 | Upstream-Status: Backport [https://sources.debian.org/src/nodejs/12.22.12~dfsg-1~deb11u3/debian/patches/cve-2022-32212.patch] | ||
16 | Comment: No hunks refreshed | ||
17 | Signed-off-by: Poonam Jadhav <Poonam.Jadhav@kpit.com> | ||
18 | |||
19 | Index: nodejs-12.22.12~dfsg/src/inspector_socket.cc | ||
20 | =================================================================== | ||
21 | --- nodejs-12.22.12~dfsg.orig/src/inspector_socket.cc | ||
22 | +++ nodejs-12.22.12~dfsg/src/inspector_socket.cc | ||
23 | @@ -168,14 +168,22 @@ static std::string TrimPort(const std::s | ||
24 | static bool IsIPAddress(const std::string& host) { | ||
25 | if (host.length() >= 4 && host.front() == '[' && host.back() == ']') | ||
26 | return true; | ||
27 | - int quads = 0; | ||
28 | + uint_fast16_t accum = 0; | ||
29 | + uint_fast8_t quads = 0; | ||
30 | + bool empty = true; | ||
31 | + auto endOctet = [&accum, &quads, &empty](bool final = false) { | ||
32 | + return !empty && accum <= 0xff && ++quads <= 4 && final == (quads == 4) && | ||
33 | + (empty = true) && !(accum = 0); | ||
34 | + }; | ||
35 | for (char c : host) { | ||
36 | - if (c == '.') | ||
37 | - quads++; | ||
38 | - else if (!isdigit(c)) | ||
39 | + if (isdigit(c)) { | ||
40 | + if ((accum = (accum * 10) + (c - '0')) > 0xff) return false; | ||
41 | + empty = false; | ||
42 | + } else if (c != '.' || !endOctet()) { | ||
43 | return false; | ||
44 | + } | ||
45 | } | ||
46 | - return quads == 3; | ||
47 | + return endOctet(true); | ||
48 | } | ||
49 | |||
50 | // Constants for hybi-10 frame format. | ||
51 | Index: nodejs-12.22.12~dfsg/test/cctest/test_inspector_socket.cc | ||
52 | =================================================================== | ||
53 | --- nodejs-12.22.12~dfsg.orig/test/cctest/test_inspector_socket.cc | ||
54 | +++ nodejs-12.22.12~dfsg/test/cctest/test_inspector_socket.cc | ||
55 | @@ -851,4 +851,78 @@ TEST_F(InspectorSocketTest, HostCheckedF | ||
56 | expect_failure_no_delegate(UPGRADE_REQUEST); | ||
57 | } | ||
58 | |||
59 | +TEST_F(InspectorSocketTest, HostIPChecked) { | ||
60 | + const std::string INVALID_HOST_IP_REQUEST = "GET /json HTTP/1.1\r\n" | ||
61 | + "Host: 10.0.2.555:9229\r\n\r\n"; | ||
62 | + send_in_chunks(INVALID_HOST_IP_REQUEST.c_str(), | ||
63 | + INVALID_HOST_IP_REQUEST.length()); | ||
64 | + expect_handshake_failure(); | ||
65 | +} | ||
66 | + | ||
67 | +TEST_F(InspectorSocketTest, HostNegativeIPChecked) { | ||
68 | + const std::string INVALID_HOST_IP_REQUEST = "GET /json HTTP/1.1\r\n" | ||
69 | + "Host: 10.0.-23.255:9229\r\n\r\n"; | ||
70 | + send_in_chunks(INVALID_HOST_IP_REQUEST.c_str(), | ||
71 | + INVALID_HOST_IP_REQUEST.length()); | ||
72 | + expect_handshake_failure(); | ||
73 | +} | ||
74 | + | ||
75 | +TEST_F(InspectorSocketTest, HostIpOctetOutOfIntRangeChecked) { | ||
76 | + const std::string INVALID_HOST_IP_REQUEST = | ||
77 | + "GET /json HTTP/1.1\r\n" | ||
78 | + "Host: 127.0.0.4294967296:9229\r\n\r\n"; | ||
79 | + send_in_chunks(INVALID_HOST_IP_REQUEST.c_str(), | ||
80 | + INVALID_HOST_IP_REQUEST.length()); | ||
81 | + expect_handshake_failure(); | ||
82 | +} | ||
83 | + | ||
84 | +TEST_F(InspectorSocketTest, HostIpOctetFarOutOfIntRangeChecked) { | ||
85 | + const std::string INVALID_HOST_IP_REQUEST = | ||
86 | + "GET /json HTTP/1.1\r\n" | ||
87 | + "Host: 127.0.0.18446744073709552000:9229\r\n\r\n"; | ||
88 | + send_in_chunks(INVALID_HOST_IP_REQUEST.c_str(), | ||
89 | + INVALID_HOST_IP_REQUEST.length()); | ||
90 | + expect_handshake_failure(); | ||
91 | +} | ||
92 | + | ||
93 | +TEST_F(InspectorSocketTest, HostIpEmptyOctetStartChecked) { | ||
94 | + const std::string INVALID_HOST_IP_REQUEST = "GET /json HTTP/1.1\r\n" | ||
95 | + "Host: .0.0.1:9229\r\n\r\n"; | ||
96 | + send_in_chunks(INVALID_HOST_IP_REQUEST.c_str(), | ||
97 | + INVALID_HOST_IP_REQUEST.length()); | ||
98 | + expect_handshake_failure(); | ||
99 | +} | ||
100 | + | ||
101 | +TEST_F(InspectorSocketTest, HostIpEmptyOctetMidChecked) { | ||
102 | + const std::string INVALID_HOST_IP_REQUEST = "GET /json HTTP/1.1\r\n" | ||
103 | + "Host: 127..0.1:9229\r\n\r\n"; | ||
104 | + send_in_chunks(INVALID_HOST_IP_REQUEST.c_str(), | ||
105 | + INVALID_HOST_IP_REQUEST.length()); | ||
106 | + expect_handshake_failure(); | ||
107 | +} | ||
108 | + | ||
109 | +TEST_F(InspectorSocketTest, HostIpEmptyOctetEndChecked) { | ||
110 | + const std::string INVALID_HOST_IP_REQUEST = "GET /json HTTP/1.1\r\n" | ||
111 | + "Host: 127.0.0.:9229\r\n\r\n"; | ||
112 | + send_in_chunks(INVALID_HOST_IP_REQUEST.c_str(), | ||
113 | + INVALID_HOST_IP_REQUEST.length()); | ||
114 | + expect_handshake_failure(); | ||
115 | +} | ||
116 | + | ||
117 | +TEST_F(InspectorSocketTest, HostIpTooFewOctetsChecked) { | ||
118 | + const std::string INVALID_HOST_IP_REQUEST = "GET /json HTTP/1.1\r\n" | ||
119 | + "Host: 127.0.1:9229\r\n\r\n"; | ||
120 | + send_in_chunks(INVALID_HOST_IP_REQUEST.c_str(), | ||
121 | + INVALID_HOST_IP_REQUEST.length()); | ||
122 | + expect_handshake_failure(); | ||
123 | +} | ||
124 | + | ||
125 | +TEST_F(InspectorSocketTest, HostIpTooManyOctetsChecked) { | ||
126 | + const std::string INVALID_HOST_IP_REQUEST = "GET /json HTTP/1.1\r\n" | ||
127 | + "Host: 127.0.0.0.1:9229\r\n\r\n"; | ||
128 | + send_in_chunks(INVALID_HOST_IP_REQUEST.c_str(), | ||
129 | + INVALID_HOST_IP_REQUEST.length()); | ||
130 | + expect_handshake_failure(); | ||
131 | +} | ||
132 | + | ||
133 | } // anonymous namespace | ||
diff --git a/meta-oe/recipes-devtools/nodejs/nodejs_12.22.12.bb b/meta-oe/recipes-devtools/nodejs/nodejs_12.22.12.bb index 8dbdd088e9..2258cb1086 100644 --- a/meta-oe/recipes-devtools/nodejs/nodejs_12.22.12.bb +++ b/meta-oe/recipes-devtools/nodejs/nodejs_12.22.12.bb | |||
@@ -22,6 +22,7 @@ SRC_URI = "http://nodejs.org/dist/v${PV}/node-v${PV}.tar.xz \ | |||
22 | file://big-endian.patch \ | 22 | file://big-endian.patch \ |
23 | file://mips-warnings.patch \ | 23 | file://mips-warnings.patch \ |
24 | file://0001-Remove-use-of-register-r7-because-llvm-now-issues-an.patch \ | 24 | file://0001-Remove-use-of-register-r7-because-llvm-now-issues-an.patch \ |
25 | file://CVE-2022-32212.patch \ | ||
25 | " | 26 | " |
26 | SRC_URI_append_class-target = " \ | 27 | SRC_URI_append_class-target = " \ |
27 | file://0002-Using-native-binaries.patch \ | 28 | file://0002-Using-native-binaries.patch \ |