Skip to content
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

fix(rpc): set const ReadHeaderTimeout to dymint RPC server #671

Conversation

mtsitrin
Copy link
Contributor

  • setting client timeout to mitigate HTTP based DoS attacks

Close #652

For Author:

  • Targeted PR against correct branch
  • included the correct type prefix in the PR title
  • Linked to Github issue with discussion and accepted design
  • Targets only one github issue
  • Wrote unit and integration tests
  • All CI checks have passed
  • Added relevant godoc comments

For Reviewer:

  • confirmed the correct type prefix in the PR title
  • Reviewers assigned
  • confirmed all author checklist items have been addressed

After reviewer approval:

  • In case targets main branch, PR should be squashed and merged.
  • In case PR targets a release branch, PR should be rebased.

@mtsitrin mtsitrin requested a review from a team as a code owner April 15, 2024 06:55
@mtsitrin mtsitrin linked an issue Apr 15, 2024 that may be closed by this pull request
@mtsitrin mtsitrin requested review from zale144 and danwt April 15, 2024 10:29
rpc/server.go Show resolved Hide resolved
@danwt danwt changed the title fix: set const ReadHeaderTimeout to dymint RPC server fix(rpc): set const ReadHeaderTimeout to dymint RPC server Apr 16, 2024
@mtsitrin mtsitrin requested a review from danwt April 16, 2024 11:22
@mtsitrin
Copy link
Contributor Author

I've added ReadHeaderTimeout to mitigate network based slow attack (which can happen before the execution of timeouthandler)

@danwt
Copy link
Contributor

danwt commented Apr 16, 2024

timeout: we still want https://pkg.go.dev/net/http#TimeoutHandler and server.ReadTimeout right?

// ReadTimeout is the maximum duration for reading the entire
// request, including the body. A zero or negative value means
// there will be no timeout.
//
// Because ReadTimeout does not let Handlers make per-request
// decisions on each request body's acceptable deadline or
// upload rate, most users will prefer to use
// ReadHeaderTimeout. It is valid to use them both.
ReadTimeout time.Duration

?

@mtsitrin
Copy link
Contributor Author

AFAICT, we want server with ReadHeaderTimeout defined and http.TimeoutHandler as the handler.

Comment on lines +46 to +47
// ReadHeaderTimeout is the timeout for reading the request headers.
ReadHeaderTimeout = 5 * time.Second
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// ReadHeaderTimeout is the timeout for reading the request headers.
ReadHeaderTimeout = 5 * time.Second
// readHeaderTimeout is the timeout for reading the request headers.
readHeaderTimeout = 5 * time.Second

@zale144
Copy link
Contributor

zale144 commented Apr 16, 2024

@danwt I think this is about the timeout for reading headers, to prevent someone from sending a ridiculously large header that would take forever to read. But I am not sure if http.TimeoutHandler would cover that.

@mtsitrin mtsitrin merged commit 4c05a1d into main Apr 17, 2024
4 checks passed
@mtsitrin mtsitrin deleted the mtsitrin/652-http-server-misconfiguration-allows-slowloris-dos-attacks branch April 17, 2024 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HTTP server misconfiguration allows Slowloris DoS attacks
3 participants