Summary
The Next.js API routes (like /api/issues/feed/route.ts) parse req.json() directly without runtime validation. Furthermore, there is no rate limiting on endpoints that wrap the GitHub API, leaving the system vulnerable to abuse and exhaustion of rate limits.
Motivation
Adding robust Zod runtime validation and an Upstash/Redis rate limiting layer constitutes core backend security hardening and reliability improvements, satisfying L3 security criteria.
Changes Required
- Integrate
zod for request payload validation.
- Integrate
@upstash/ratelimit and @vercel/kv for distributed rate limiting.
- Refactor the
/api/issues/feed POST route to validate the languages and page parameters via Zod.
- Apply a fixed-window rate limiter to reject excessive requests with 429 status codes.
Summary
The Next.js API routes (like
/api/issues/feed/route.ts) parsereq.json()directly without runtime validation. Furthermore, there is no rate limiting on endpoints that wrap the GitHub API, leaving the system vulnerable to abuse and exhaustion of rate limits.Motivation
Adding robust Zod runtime validation and an Upstash/Redis rate limiting layer constitutes core backend security hardening and reliability improvements, satisfying L3 security criteria.
Changes Required
zodfor request payload validation.@upstash/ratelimitand@vercel/kvfor distributed rate limiting./api/issues/feedPOST route to validate thelanguagesandpageparameters via Zod.