| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8601394 commit a4ae272
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1939,6 +1939,9 @@ error will be thrown. | |||
| 1939 | 1939 | <!-- YAML | |
| 1940 | 1940 | added: v8.4.0 | |
| 1941 | 1941 | changes: | |
| 1942 | + - version: REPLACEME | ||
| 1943 | + pr-url: https://github.com/nodejs/node/pull/30534 | ||
| 1944 | + description: Added `maxSessionRejectedStreams` option with a default of 100. | ||
| 1942 | 1945 | - version: REPLACEME | |
| 1943 | 1946 | pr-url: https://github.com/nodejs/node/pull/30534 | |
| 1944 | 1947 | description: Added `maxSessionInvalidFrames` option with a default of 1000. | |
@@ -2005,6 +2008,12 @@ changes: | |||
| 2005 | 2008 | * `maxSessionInvalidFrames` {integer} Sets the maximum number of invalid | |
| 2006 | 2009 | frames that will be tolerated before the session is closed. | |
| 2007 | 2010 | **Default:** `1000`. | |
| 2011 | + * `maxSessionRejectedStreams` {integer} Sets the maximum number of rejected | ||
| 2012 | + upon creation streams that will be tolerated before the session is closed. | ||
| 2013 | + Each rejection is associated with an `NGHTTP2_ENHANCE_YOUR_CALM` | ||
| 2014 | + error that should tell the peer to not open any more streams, continuing | ||
| 2015 | + to open streams is therefore regarded as a sign of a misbehaving peer. | ||
| 2016 | + **Default:** `100`. | ||
| 2008 | 2017 | * `selectPadding` {Function} When `options.paddingStrategy` is equal to | |
| 2009 | 2018 | `http2.constants.PADDING_STRATEGY_CALLBACK`, provides the callback function | |
| 2010 | 2019 | used to determine the padding. See [Using `options.selectPadding()`][]. | |
@@ -2060,6 +2069,9 @@ server.listen(80); | |||
| 2060 | 2069 | <!-- YAML | |
| 2061 | 2070 | added: v8.4.0 | |
| 2062 | 2071 | changes: | |
| 2072 | + - version: REPLACEME | ||
| 2073 | + pr-url: https://github.com/nodejs/node/pull/30534 | ||
| 2074 | + description: Added `maxSessionRejectedStreams` option with a default of 100. | ||
| 2063 | 2075 | - version: REPLACEME | |
| 2064 | 2076 | pr-url: https://github.com/nodejs/node/pull/30534 | |
| 2065 | 2077 | description: Added `maxSessionInvalidFrames` option with a default of 1000. | |
@@ -2126,6 +2138,12 @@ changes: | |||
| 2126 | 2138 | * `maxSessionInvalidFrames` {integer} Sets the maximum number of invalid | |
| 2127 | 2139 | frames that will be tolerated before the session is closed. | |
| 2128 | 2140 | **Default:** `1000`. | |
| 2141 | + * `maxSessionRejectedStreams` {integer} Sets the maximum number of rejected | ||
| 2142 | + upon creation streams that will be tolerated before the session is closed. | ||
| 2143 | + Each rejection is associated with an `NGHTTP2_ENHANCE_YOUR_CALM` | ||
| 2144 | + error that should tell the peer to not open any more streams, continuing | ||
| 2145 | + to open streams is therefore regarded as a sign of a misbehaving peer. | ||
| 2146 | + **Default:** `100`. | ||
| 2129 | 2147 | * `selectPadding` {Function} When `options.paddingStrategy` is equal to | |
| 2130 | 2148 | `http2.constants.PADDING_STRATEGY_CALLBACK`, provides the callback function | |
| 2131 | 2149 | used to determine the padding. See [Using `options.selectPadding()`][]. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -212,6 +212,7 @@ const { | |||
| 212 | 212 | kSessionPriorityListenerCount, | |
| 213 | 213 | kSessionFrameErrorListenerCount, | |
| 214 | 214 | kSessionMaxInvalidFrames, | |
| 215 | + kSessionMaxRejectedStreams, | ||
| 215 | 216 | kSessionUint8FieldCount, | |
| 216 | 217 | kSessionHasRemoteSettingsListeners, | |
| 217 | 218 | kSessionRemoteSettingsIsUpToDate, | |
@@ -970,6 +971,12 @@ function setupHandle(socket, type, options) { | |||
| 970 | 971 | uint32[0] = options.maxSessionInvalidFrames; | |
| 971 | 972 | } | |
| 972 | 973 | ||
| 974 | + if (isUint32(options.maxSessionRejectedStreams)) { | ||
| 975 | + const uint32 = new Uint32Array( | ||
| 976 | + this[kNativeFields].buffer, kSessionMaxRejectedStreams, 1); | ||
| 977 | + uint32[0] = options.maxSessionRejectedStreams; | ||
| 978 | + } | ||
| 979 | + | ||
| 973 | 980 | const settings = typeof options.settings === 'object' ? | |
| 974 | 981 | options.settings : {}; | |
| 975 | 982 | ||
@@ -2804,6 +2811,13 @@ function initializeOptions(options) { | |||
| 2804 | 2811 | if (options.maxSessionInvalidFrames !== undefined) | |
| 2805 | 2812 | validateUint32(options.maxSessionInvalidFrames, 'maxSessionInvalidFrames'); | |
| 2806 | 2813 | ||
| 2814 | + if (options.maxSessionRejectedStreams !== undefined) { | ||
| 2815 | + validateUint32( | ||
| 2816 | + options.maxSessionRejectedStreams, | ||
| 2817 | + 'maxSessionRejectedStreams' | ||
| 2818 | + ); | ||
| 2819 | + } | ||
| 2820 | + | ||
| 2807 | 2821 | // Used only with allowHTTP1 | |
| 2808 | 2822 | options.Http1IncomingMessage = options.Http1IncomingMessage || | |
| 2809 | 2823 | http.IncomingMessage; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -952,7 +952,8 @@ int Http2Session::OnBeginHeadersCallback(nghttp2_session* handle, | |||
| 952 | 952 | if (UNLIKELY(!session->CanAddStream() || | |
| 953 | 953 | Http2Stream::New(session, id, frame->headers.cat) == | |
| 954 | 954 | nullptr)) { | |
| 955 | - if (session->rejected_stream_count_++ > 100 && | ||
| 955 | + if (session->rejected_stream_count_++ > | ||
| 956 | + session->js_fields_.max_rejected_streams && | ||
| 956 | 957 | !IsReverted(SECURITY_REVERT_CVE_2019_9514)) { | |
| 957 | 958 | return NGHTTP2_ERR_CALLBACK_FAILURE; | |
| 958 | 959 | } | |
@@ -3111,6 +3112,7 @@ void Initialize(Local<Object> target, | |||
| 3111 | 3112 | NODE_DEFINE_CONSTANT(target, kSessionPriorityListenerCount); | |
| 3112 | 3113 | NODE_DEFINE_CONSTANT(target, kSessionFrameErrorListenerCount); | |
| 3113 | 3114 | NODE_DEFINE_CONSTANT(target, kSessionMaxInvalidFrames); | |
| 3115 | + NODE_DEFINE_CONSTANT(target, kSessionMaxRejectedStreams); | ||
| 3114 | 3116 | NODE_DEFINE_CONSTANT(target, kSessionUint8FieldCount); | |
| 3115 | 3117 | ||
| 3116 | 3118 | NODE_DEFINE_CONSTANT(target, kSessionHasRemoteSettingsListeners); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -680,6 +680,7 @@ typedef struct { | |||
| 680 | 680 | uint8_t priority_listener_count; | |
| 681 | 681 | uint8_t frame_error_listener_count; | |
| 682 | 682 | uint32_t max_invalid_frames = 1000; | |
| 683 | + uint32_t max_rejected_streams = 100; | ||
| 683 | 684 | } SessionJSFields; | |
| 684 | 685 | ||
| 685 | 686 | // Indices for js_fields_, which serves as a way to communicate data with JS | |
@@ -693,6 +694,7 @@ enum SessionUint8Fields { | |||
| 693 | 694 | kSessionFrameErrorListenerCount = | |
| 694 | 695 | offsetof(SessionJSFields, frame_error_listener_count), | |
| 695 | 696 | kSessionMaxInvalidFrames = offsetof(SessionJSFields, max_invalid_frames), | |
| 697 | + kSessionMaxRejectedStreams = offsetof(SessionJSFields, max_rejected_streams), | ||
| 696 | 698 | kSessionUint8FieldCount = sizeof(SessionJSFields) | |
| 697 | 699 | }; | |
| 698 | 700 | ||
@@ -1028,7 +1030,7 @@ class Http2Session : public AsyncWrap, public StreamListener { | |||
| 1028 | 1030 | // limit will result in the session being destroyed, as an indication of a | |
| 1029 | 1031 | // misbehaving peer. This counter is reset once new streams are being | |
| 1030 | 1032 | // accepted again. | |
| 1031 | - int32_t rejected_stream_count_ = 0; | ||
| 1033 | + uint32_t rejected_stream_count_ = 0; | ||
| 1032 | 1034 | // Also use the invalid frame count as a measure for rejecting input frames. | |
| 1033 | 1035 | uint32_t invalid_frame_count_ = 0; | |
| 1034 | 1036 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -52,6 +52,22 @@ Object.entries({ | |||
| 52 | 52 | }, | |
| 53 | 53 | }, | |
| 54 | 54 | ], | |
| 55 | + maxSessionRejectedStreams: [ | ||
| 56 | + { | ||
| 57 | + val: -1, | ||
| 58 | + err: { | ||
| 59 | + name: 'RangeError', | ||
| 60 | + code: 'ERR_OUT_OF_RANGE', | ||
| 61 | + }, | ||
| 62 | + }, | ||
| 63 | + { | ||
| 64 | + val: Number.NEGATIVE_INFINITY, | ||
| 65 | + err: { | ||
| 66 | + name: 'RangeError', | ||
| 67 | + code: 'ERR_OUT_OF_RANGE', | ||
| 68 | + }, | ||
| 69 | + }, | ||
| 70 | + ], | ||
| 55 | 71 | }).forEach(([opt, tests]) => { | |
| 56 | 72 | tests.forEach(({ val, err }) => { | |
| 57 | 73 | assert.throws( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -52,6 +52,22 @@ Object.entries({ | |||
| 52 | 52 | }, | |
| 53 | 53 | }, | |
| 54 | 54 | ], | |
| 55 | + maxSessionRejectedStreams: [ | ||
| 56 | + { | ||
| 57 | + val: -1, | ||
| 58 | + err: { | ||
| 59 | + name: 'RangeError', | ||
| 60 | + code: 'ERR_OUT_OF_RANGE', | ||
| 61 | + }, | ||
| 62 | + }, | ||
| 63 | + { | ||
| 64 | + val: Number.NEGATIVE_INFINITY, | ||
| 65 | + err: { | ||
| 66 | + name: 'RangeError', | ||
| 67 | + code: 'ERR_OUT_OF_RANGE', | ||
| 68 | + }, | ||
| 69 | + }, | ||
| 70 | + ] | ||
| 55 | 71 | }).forEach(([opt, tests]) => { | |
| 56 | 72 | tests.forEach(({ val, err }) => { | |
| 57 | 73 | assert.throws( | |
| Back | FazBrowse Home | New Git URL |
0 commit comments