Skip to content

Add HTTP server timeouts to mitigate slowloris/slow-read DoS#1895

Open
xmtp-coder-agent wants to merge 1 commit intoxmtp:mainfrom
xmtp-coder-agent:fix/issue-1888
Open

Add HTTP server timeouts to mitigate slowloris/slow-read DoS#1895
xmtp-coder-agent wants to merge 1 commit intoxmtp:mainfrom
xmtp-coder-agent:fix/issue-1888

Conversation

@xmtp-coder-agent
Copy link
Copy Markdown
Collaborator

@xmtp-coder-agent xmtp-coder-agent commented Mar 26, 2026

Resolves #1888

Summary

  • Adds ReadHeaderTimeout (10s), ReadTimeout (30s), and WriteTimeout (5m) to the API http.Server to mitigate slowloris and slow-read denial-of-service attacks
  • Removes the TODO comment about needing more timeouts

Timeout Rationale

Timeout Value Why
ReadHeaderTimeout 10s Prevents slowloris attacks that trickle request headers — 10s is generous for any legitimate client
ReadTimeout 30s Bounds total time to read the full request (headers + body) — covers large publish payloads
WriteTimeout 5m Matches IdleTimeout — must be long enough for server-streaming RPCs like SubscribeEnvelopes

Test Plan

  • go build ./pkg/api/... compiles cleanly
  • go vet ./pkg/api/... passes
  • CI tests pass (existing tests are unaffected — only timeout config changed)

🤖 Generated with Claude Code

Note

Add HTTP server timeouts to mitigate slowloris/slow-read DoS attacks

Sets ReadHeaderTimeout (10s), ReadTimeout (30s), and WriteTimeout (5m) on the http.Server in api.NewAPIServer. These timeouts protect against slowloris and slow-read denial-of-service attacks by bounding how long the server waits on a client. Behavioral Change: all API requests are now subject to these timeouts, where previously none were enforced.

Macroscope summarized a54a5fc.

Mitigates slowloris and slow-read DoS attacks by configuring missing
timeouts on the http.Server: ReadHeaderTimeout (10s), ReadTimeout (30s),
and WriteTimeout (5m). Removes the TODO comment about needing more
timeouts.

Resolves xmtp#1888

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@xmtp-coder-agent xmtp-coder-agent requested a review from a team as a code owner March 26, 2026 16:21
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.

Missing ReadHeaderTimeout/ReadTimeout/WriteTimeout in API HTTP server causes DoS via slowloris/slow-read

1 participant