fix(sei-tendermint): add ReadHeaderTimeout to CometBFT RPC HTTP server (PLT-440)#3607
fix(sei-tendermint): add ReadHeaderTimeout to CometBFT RPC HTTP server (PLT-440)#3607amir-deris wants to merge 3 commits into
Conversation
PR SummaryLow Risk Overview Configuration: New Server wiring: Tests: Reviewed by Cursor Bugbot for commit 310f12a. Bugbot is set up for automated code reviews on this repo. Configure here. |
|
The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 7c228d7. Configure here.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3607 +/- ##
==========================================
- Coverage 59.02% 58.14% -0.88%
==========================================
Files 2215 2141 -74
Lines 182513 173975 -8538
==========================================
- Hits 107720 101155 -6565
+ Misses 65101 63828 -1273
+ Partials 9692 8992 -700
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
…lowloris If the 500ms read deadline fires before the server closes the connection, conn.Read returns a net.Timeout error — previously the test exited with no assertion, silently passing even if ReadHeaderTimeout never fired. Now errors.As detects the timeout case and calls t.Fatal, making the false- pass explicit. EOF or connection-reset remains the expected happy path. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Summary
ReadHeaderTimeoutwas absent from the CometBFT JSON-RPC HTTP server, leaving it vulnerable to slowloris attacks: a client could hold a connection open indefinitely by sending HTTP headers one byte at a time.ReadHeaderTimeoutis now 10s by default, enforced on the main RPC server (:26657) as well as the light-client proxy and inspect RPC paths.timeout-read-headerinRPCConfigand the generatedconfig.tomlso operators can tune it.ValidateBasicrejects negative values, matching the existingtimeout-writevalidation pattern.Completes PLT-440 alongside #3558 (which added
WriteTimeout).Changes
sei-tendermint/rpc/jsonrpc/server/http_server.goReadHeaderTimeoutfield toConfig; default 10s; wired intoServe()andServeTLS()sei-tendermint/config/config.goTimeoutReadHeaderfield toRPCConfig; default 10s;ValidateBasicrejects negative valuessei-tendermint/internal/rpc/core/env.goconf.RPC.TimeoutReadHeader→cfg.ReadHeaderTimeoutsei-tendermint/cmd/tendermint/commands/light.gosei-tendermint/internal/inspect/rpc/rpc.gosei-tendermint/config/toml.gotimeout-read-headertemplate entrysei-tendermint/config/config_test.go"TimeoutReadHeader"toTestRPCConfigValidateBasicfield sweepsei-tendermint/rpc/jsonrpc/server/http_server_test.goTestReadHeaderTimeoutSlowloris: opens a raw TCP connection with incomplete headers and asserts the server closes or 408s within the timeout windowRisk
The 10s default is consistent with the existing
timeout-readdefault and is well above any legitimate header round-trip on Sei.Note on
0ssemantics: settingtimeout-read-header = "0s"does not disable the timeout. Per Go'snet/http, a zeroReadHeaderTimeoutfalls back toReadTimeout— which is fixed at 10s in this stack due to an existing> 0guard inenv.gothat prevents operators from zeroing it out via config. In practice,ReadHeaderTimeoutis always at minimum 10s regardless of whattimeout-read-headeris set to.🤖 Generated with Claude Code