-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix(rpc): add read, write and idle configurable timeouts to gateway #13327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
fix(rpc): add read, write and idle configurable timeouts to gateway #13327
Conversation
Note: Need a sensible write timeout. 10s maybe. |
I think we'll want a changelog item here. |
Done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds configurable HTTP timeouts to the gateway RPC handler to fix a security vulnerability. The changes introduce five new timeout parameters (read header, read, write, idle timeouts and max header bytes) that can be configured via command-line flags.
- Adds five new timeout constants and corresponding configuration options
- Implements CLI flags for configuring the timeout values
- Updates the CHANGELOG to document the fix
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
gateway/node.go | Adds timeout constants, struct fields, and configuration options for HTTP timeouts |
cmd/lotus-gateway/main.go | Implements CLI flags for the new timeout configurations |
CHANGELOG.md | Documents the security fix in the changelog |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Usage: "Maximum duration for reading the entire request, including the body. Use 0 to disable", | ||
Value: gateway.ReadTimeout, | ||
}, | ||
&cli.DurationFlag{ |
Copilot
AI
Sep 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CLI flag is missing the --read-header-timeout option that corresponds to the ReadHeaderTimeout constant. This timeout is configurable in the code but not exposed via CLI, creating an inconsistency in the configuration interface.
&cli.DurationFlag{ | |
&cli.DurationFlag{ | |
Name: "read-header-timeout", | |
Usage: "Amount of time allowed to read request headers. Use 0 to disable", | |
Value: gateway.ReadHeaderTimeout, | |
}, | |
&cli.DurationFlag{ |
Copilot uses AI. Check for mistakes.
Related Issues
Old PR https://github.com/filecoin-project/lotus/pull/13283/files.
Adding configurable read, write and idle timeouts in gateway handler. Fixes this bug.
Proposed Changes
Adding additional timeouts for gateway rpc handler.
Mainly these are the constants (Subject to change):
readHeaderTimeout = 10 * time.Second
readTimeout = 60 * time.Second
writeTimeout = 0
idleTimeout = 60 * time.Second
maxHeaderBytes = 1 << 20
Additional Info
Related slack discussion: https://filecoinproject.slack.com/archives/C05P37R9KQD/p1756354215245379
Checklist
Before you mark the PR ready for review, please make sure that: