Skip to content

Commit 202b30f

Browse files
authored
Limit the maximum WebSocket fragments capacity (#644)
* Limit the maximum fragments capacity * Bump `parity-ws` to 0.11.1 * Limit the total size of fragmented websocket payloads
1 parent c3b1042 commit 202b30f

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

ws/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jsonrpc-server-utils = { version = "18.0.0", path = "../server-utils" }
1616
log = "0.4"
1717
parking_lot = "0.11.0"
1818
slab = "0.4"
19-
parity-ws = "0.11"
19+
parity-ws = "0.11.1"
2020

2121
[badges]
2222
travis-ci = { repository = "paritytech/jsonrpc", branch = "master"}

ws/src/server.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,16 @@ impl Server {
7070
config.max_connections = max_connections;
7171
// don't accept super large requests
7272
config.max_fragment_size = max_payload_bytes;
73+
config.max_total_fragments_size = max_payload_bytes;
7374
config.in_buffer_capacity_hard_limit = max_in_buffer_capacity;
7475
config.out_buffer_capacity_hard_limit = max_out_buffer_capacity;
7576
// don't grow non-final fragments (to prevent DOS)
7677
config.fragments_grow = false;
7778
config.fragments_capacity = cmp::max(1, max_payload_bytes / config.fragment_size);
79+
if config.fragments_capacity > 4096 {
80+
config.fragments_capacity = 4096;
81+
config.fragments_grow = true;
82+
}
7883
// accept only handshakes beginning with GET
7984
config.method_strict = true;
8085
// require masking

0 commit comments

Comments
 (0)