-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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. Refs: https://hackerone.com/reports/1043360 CVE-ID: CVE-2021-22883 PR-URL: nodejs-private/node-private#246 Backport-PR-URL: nodejs-private/node-private#250 Reviewed-By: Beth Griggs <bgriggs@redhat.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
- Loading branch information
1 parent
1564752
commit 922ada7
Showing
3 changed files
with
84 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const fixtures = require('../common/fixtures'); | ||
|
||
// This test verifies that when a server receives an unknownProtocol it will | ||
// not leave the socket open if the client does not close it. | ||
|
||
if (!common.hasCrypto) | ||
common.skip('missing crypto'); | ||
|
||
const h2 = require('http2'); | ||
const tls = require('tls'); | ||
|
||
const server = h2.createSecureServer({ | ||
key: fixtures.readKey('rsa_private.pem'), | ||
cert: fixtures.readKey('rsa_cert.crt'), | ||
unknownProtocolTimeout: 500, | ||
allowHalfOpen: true | ||
}); | ||
|
||
server.on('connection', (socket) => { | ||
socket.on('close', common.mustCall(() => { | ||
server.close(); | ||
})); | ||
}); | ||
|
||
server.listen(0, function() { | ||
tls.connect({ | ||
port: server.address().port, | ||
rejectUnauthorized: false, | ||
ALPNProtocols: ['bogus'] | ||
}); | ||
}); |