Skip to content

Add Input Validation and Rate Limiting to API Routes #499

Description

@Emmzyemms

Type: Security / Reliability
Priority: 🟠 HIGH

Description:
The /api/upload route validates file type/size but does not validate the number of files per request (a caller could send 1000 files). The job routes accept any string as id with no format validation. Server-side rate limiting is absent from all API routes (the existing rateLimiter.ts only runs client-side).

Acceptance Criteria:

  • /api/upload: cap files.length at a configurable max (e.g. 10); return 400 if exceeded
  • /api/jobs/[id]: validate id format (UUID or alphanumeric, max 64 chars); return 400 on invalid
  • Implement server-side rate limiting middleware using an in-memory or Redis-backed token bucket
  • Rate limit headers (X-RateLimit-Limit, X-RateLimit-Remaining, Retry-After) are returned on 429 responses
  • Add integration tests for each validation edge case

Metadata

Metadata

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions