security: add HTTP server timeouts (ai:gpt-5) #54

Closed
opened 2026-05-23 22:20:58 +02:00 by heiko · 1 comment
Owner

Finding from a whole-codebase security review.

Affected code:

  • cmd/once-server/serve.go:142-148 calls http.ListenAndServeTLS or http.ListenAndServe directly with the default server settings.

Impact:
The default net/http server has no ReadHeaderTimeout, ReadTimeout, WriteTimeout, or IdleTimeout. An unauthenticated client can hold connections open slowly and consume server resources, especially when Once is exposed directly or when a reverse proxy does not fully absorb slow clients.

Suggested fix:

  • Instantiate an http.Server explicitly with conservative timeouts.
  • Make timeout values configurable if needed, but keep safe defaults.
  • Keep compatibility with both direct TLS and HTTP-behind-proxy modes.
  • Add tests or at least configuration coverage for the timeout defaults.
Finding from a whole-codebase security review. Affected code: - cmd/once-server/serve.go:142-148 calls `http.ListenAndServeTLS` or `http.ListenAndServe` directly with the default server settings. Impact: The default `net/http` server has no `ReadHeaderTimeout`, `ReadTimeout`, `WriteTimeout`, or `IdleTimeout`. An unauthenticated client can hold connections open slowly and consume server resources, especially when Once is exposed directly or when a reverse proxy does not fully absorb slow clients. Suggested fix: - Instantiate an `http.Server` explicitly with conservative timeouts. - Make timeout values configurable if needed, but keep safe defaults. - Keep compatibility with both direct TLS and HTTP-behind-proxy modes. - Add tests or at least configuration coverage for the timeout defaults.
Author
Owner

Fixed by commit f407586 (Add configurable HTTP server timeouts).

Implements all four timeouts:

  • ReadHeaderTimeout: 5s
  • ReadTimeout: 30s
  • WriteTimeout: 1m
  • IdleTimeout: 2m

Timeouts are configurable via TOML config. Security review confirmed proper implementation with comprehensive test coverage.

Fixed by commit f407586 (Add configurable HTTP server timeouts). Implements all four timeouts: - ReadHeaderTimeout: 5s - ReadTimeout: 30s - WriteTimeout: 1m - IdleTimeout: 2m Timeouts are configurable via TOML config. Security review confirmed proper implementation with comprehensive test coverage.
heiko closed this issue 2026-05-24 20:15:59 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
IUS/once#54
No description provided.