AI endpoints anyone can call
An endpoint that forwards prompts to an AI provider can run up your bill when strangers can call it.
What it is
Two patterns appear. The page calls an AI provider directly from the browser, which needs a key in the page. Or your own endpoint takes a prompt from any visitor and forwards it to a provider with your key.
Why it matters
Every call costs money, and a script can make thousands of calls an hour. A provider key in the browser lets anyone call the provider on your account. An open endpoint on your server gives the same result through your own address. Tenty rates the finding by cost.
How Tenty checks it
Tenty reads this from the page and the script files every visitor receives. The check runs on every scan, and the finding names the place where the value appears. Tenty finds calls to provider addresses in your scripts and routes whose names look like chat, completion or generate endpoints.
How to fix it
- Call the provider from your server and keep the key there.
- Put sign in in front of the endpoint, and set a limit per user and per day.
- Set a monthly spend cap with the provider.
- When the browser has to call a provider, hand it a short lived token from your server.
How to reproduce
curl -sS -X POST 'https://YOUR-APP/api/chat' -H 'Content-Type: application/json' -d '{"prompt":"hello"}'Use the route from the finding. An answer from the model means any visitor can use it.