Skip to content

MCP: DCR rate limiting + auth.db lifecycle (purge expired rows, janitor, body size limits) #52

Description

@manucompiles

Follow-up from code review on the MCP server feature (#50).

The MCP server's OAuth endpoints (/register, /authorize, /token) are publicly reachable via Cloudflare Tunnel. The Zod field-length caps landed inline in #50; the remaining DoS surface is in this issue.

  • No rate limit on /register, /authorize, /token. An attacker could spam any of these to fill auth.db on the phone or burn cycles. Either coarse per-IP token bucket via Hono middleware, or a Cloudflare WAF rule at the edge.
  • No cleanup of unused DCR clients. Each POST /register creates a row; if the client never completes an OAuth flow, the row sticks forever. Add a janitor that deletes clients with no associated tokens older than 24h.
  • No purge of expired rows in access_tokens / auth_codes. Indexes on expires_at exist but unused. Add a startup-time DELETE WHERE expires_at < ? (and re-run every 24h).
  • No body-size limit on POST endpoints. A multi-GB POST to /token or /register would be fully buffered. Add hono/body-limit middleware (16 KB for OAuth, 256 KB for /mcp).

Source: review of feature/mcp-server-#50.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions