feat(preconf): harden HTTP server limits#3119
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## tls-preconf-server-hardening #3119 +/- ##
================================================================
+ Coverage 60.01% 60.22% +0.21%
================================================================
Files 384 384
Lines 20055 20079 +24
================================================================
+ Hits 12036 12093 +57
+ Misses 7028 6986 -42
- Partials 991 1000 +9
🚀 New features to boost your workflow:
|
calbera
left a comment
There was a problem hiding this comment.
lgtm but can we add e2e tests for the scenarios you mentioned were previously possible (but shouldn't be anymore)?
previously accepted unbounded request bodies, had no read/write/idle timeouts, and no cap on concurrent connections
There was a problem hiding this comment.
agree on testing. Also MaxHeaderBytes (DefaultMaxHeaderBytes = 1 << 20 // 1 MB) and MaxResponseHeaderBytes (default at 10 MB) are not set so the the effective per-request memory may be underestimated, not game changing since connections are already limited but maybe you want to consider setting them.
This PR hardens the preconf HTTP server and validator client against DoS and OOM, The sequencer is internet-facing, so it previously accepted unbounded request bodies, had no read/write/idle timeouts, and no cap on concurrent connections, leaving it open to OOM, Slowloris, and connection-exhaustion attacks.
More specifically, the main changes are:
MaxBytesReader(2 KB) ->413on oversized bodies.netutil.LimitListener(256).max-response-size, to prevent a malicious sequencer OOMing a validator. Picked 16 MiB which should cover the worst-case valid block, full hex-encoded transactions (~6 MiB) + 6 blobs (~1.5 MiB) with ~2× headroom.