Skip to content

Conversation

parthshah1
Copy link
Contributor

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:

@github-project-automation github-project-automation bot moved this to 📌 Triage in FilOz Sep 8, 2025
@parthshah1
Copy link
Contributor Author

Note: Need a sensible write timeout. 10s maybe.

@BigLep
Copy link
Member

BigLep commented Sep 8, 2025

I think we'll want a changelog item here.

@parthshah1
Copy link
Contributor Author

I think we'll want a changelog item here.

Done.

@rjan90 rjan90 moved this from 📌 Triage to 🔎 Awaiting Review in FilOz Sep 11, 2025
@BigLep BigLep requested review from Copilot and rvagg September 23, 2025 14:27
Copy link
Contributor

@Copilot Copilot AI left a 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{
Copy link

Copilot AI Sep 23, 2025

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.

Suggested change
&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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🔎 Awaiting Review

Development

Successfully merging this pull request may close these issues.

2 participants