-
Notifications
You must be signed in to change notification settings - Fork 0
Add request body limits, per-endpoint timeouts, and rate limiting #18
Copy link
Copy link
Open
Description
Summary
The HTTP layer accepts requests of any size with no timeout and no rate limiting. This is a DoS surface.
Current state
internal/api/httpapi/server.go— nohttp.MaxBytesReaderon request bodiescmd/asb-api/main.go— nohttp.Server.ReadTimeout/WriteTimeout/IdleTimeout- No rate limiting per tenant, per session, or per IP
- No CORS headers (relevant if a browser extension or frontend hits the API directly)
Required work
- Add
http.MaxBytesReaderto all handlers — 1MB default, configurable - Set server timeouts: ReadTimeout (10s), WriteTimeout (30s), IdleTimeout (120s) — configurable
- Add per-endpoint timeout context: grant requests and proxy execution may need longer than session creation
- Implement rate limiting middleware:
- Per-tenant token bucket for grant requests
- Per-handle rate limit for proxy execution (in addition to budget)
- Global rate limit as a safety valve
- Add CORS middleware if browser-origin requests are expected
- Validate
Content-Type: application/jsonon all JSON endpoints
Files
cmd/asb-api/main.go— server timeoutsinternal/api/httpapi/server.go— body limits, content-type validation, rate limiting middleware
Priority
Medium — important for any internet-exposed deployment.
🤖 Generated with Claude Code
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels