★AI-PROXY-OPEN
Open AI proxy (denial of wallet)
- Severity
- High
- Confidence
- High
- Stack
- AI
- Runs
- On by default
What the CLI looks for
A route or function that sends a prompt taken from the request body to OpenAI, Anthropic or Gemini, with no user check and no limit.
Why it matters
Anyone who finds the endpoint can use your API key for their own prompts. Nothing breaks: the cost simply shows up on your bill at the end of the month.
How to fix it
Require an authenticated user, rate-limit per user, cap the number of tokens and keep the prompt template on the server.
const { data: { user } } = await supabase.auth.getUser();
if (!user) return new Response("Unauthorized", { status: 401 });
if (!(await withinDailyLimit(user.id))) return new Response("Too many requests", { status: 429 });
const completion = await openai.chat.completions.create({
model,
max_tokens: 500,
messages: [
{ role: "system", content: SYSTEM_PROMPT },
{ role: "user", content: input.slice(0, 2000) },
],
});