SEC-021
AI endpoint shows no sign of auth or rate limiting
Last reviewed
An AI endpoint that answers without auth or rate limits lets anyone use your model calls on your bill, or flood them until you hit your provider limit. Require a session, limit requests per user and per IP, cap input size, and set a monthly spending cap in your AI provider’s dashboard.
In apps built with AI tools
Chat and generate features are often wired to an open /api/chat route during prototyping and launched unchanged.
What it checks
AI-looking API routes referenced by the site’s JavaScript, probed with a single anonymous GET.
Why it matters
An open AI endpoint can be scripted by anyone to run up your model bill or extract your system prompt.
Recommended fix
Require auth or a per-IP rate limit on AI routes, cap tokens per request, and set a monthly spend limit with the provider.
How to verify
Send 30 quick anonymous requests to the route and confirm later ones get 401 or 429.
Example fix prompt
Please fix this production issue in my app.
Issue SEC-021: AI endpoint shows no sign of auth or rate limiting
Site: https://your-app.example
First confirm the issue in the code or live config. If it is not present, say so and change nothing.
Task: Harden the AI API route(s) in the evidence: require a signed-in user or apply a per-IP rate limit (for example 20 requests per 10 minutes), validate and size-limit the input, cap max output tokens, and return 429 with a Retry-After header when the limit is hit.
Constraints: make the smallest change that fixes this, keep the current design and behaviour, never paste secret values into code or chat, and tell me which files you changed.
Done when: Send 30 quick anonymous requests to the route and confirm later ones get 401 or 429.Questions
- Is a provider spending cap enough?
- It limits the damage but not the abuse. Auth and per-user rate limits stop it; the cap is your backstop.