From 3f2e9dc40c9964965b075c00719829f9bb17e65f Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Fri, 22 Jan 2021 12:34:21 +0100 Subject: [PATCH] http2: add unknownProtocol timeout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit add a configuration options named unknownProtocolTimeout which can be specified to set a value for the timeout in milliseconds that a server should wait when an unknowProtocol is sent to it. When this happens a timer will be started and the if the socket has not been destroyed during that time the timer callback will destoy it. CVE-ID: CVE-2021-22883 Refs: https://hackerone.com/reports/1043360 PR-URL: https://github.com/nodejs/node/pull/246 Backport PR-URL: https://github.com/nodejs/node/pull/248 Reviewed-By: Beth Griggs Reviewed-By: Matteo Collina Reviewed-By: Michael Dawson Reviewed-By: Rich Trott Reviewed-By: Tobias Nießen Reference: https://github.com/nodejs/node/commit/3f2e9dc40c9964965b075c00719829f9bb17e65f --- doc/api/http2.md | 25 +++++++++++++- lib/internal/http2/core.js | 32 +++++++++++++++--- .../test-http2-server-unknown-protocol.js | 33 +++++++++++++++++++ 3 files changed, 85 insertions(+), 5 deletions(-) create mode 100644 test/parallel/test-http2-server-unknown-protocol.js diff --git a/doc/api/http2.md b/doc/api/http2.md index bb0ac52..9d0c258 100644 --- a/doc/api/http2.md +++ b/doc/api/http2.md @@ -1864,7 +1864,9 @@ added: v8.4.0 The `'unknownProtocol'` event is emitted when a connecting client fails to negotiate an allowed protocol (i.e. HTTP/2 or HTTP/1.1). The event handler receives the socket for handling. If no listener is registered for this event, -the connection is terminated. See the [Compatibility API][]. +the connection is terminated. A timeout may be specified using the +`'unknownProtocolTimeout'` option passed to [`http2.createSecureServer()`][]. +See the [Compatibility API][]. #### server.close([callback])