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

Fixes HTTP1 client reads to properly timeout #539

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

matthewbjones
Copy link
Contributor

The initial read(s) for reading in the HTTP request headers from the client did not make use of the read_timeout, and a client could cause a connection to hang forever. This could allow to resource exhaustion attacks, as malicious actors could use up all available socket connections, or memory (since a buffer is allocated for each request)

Also, there was no way to set the read_timeout for an HttpSession prior to this initial read, despite there being a set_read_timeout, so this commit also sets a "sensible default" of 60 seconds, which matches NGINX's default value for client_header_timeout and client_body_timeout.

See discussion at #447

@matthewbjones
Copy link
Contributor Author

Note: All tests pass, when running after fixing broken GitHub Actions (see #538 )

@matthewbjones
Copy link
Contributor Author

To reproduce this issue (for HTTP), do a nc localhost 80 and send nothing, without this fix, it sits there forever waiting for the client to do something.

The initial read(s) for reading in the HTTP request headers
from the client did not make use of the `read_timeout`, and
a client could cause a connection to hang forever.

Also, there was no way to set the `read_timeout` for an
`HttpSession` prior to this initial read, despite there
being a `set_read_timeout`, so this commit also sets a
"sensible default" of 60 seconds, which matches NGINX's
default value for `client_header_timeout` and `client_body_timeout`.
@matthewbjones matthewbjones force-pushed the fix/http1-read-timeouts branch from cac696b to 0d48675 Compare February 28, 2025 18:03
@drcaramelsyrup drcaramelsyrup added the bug Something isn't working label Mar 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants