Finding · affects your reliability
Unauthenticated routes that use your users' stored API keys
If users save their own model API keys in your app, a route that uses them without checking who's calling lets strangers spend your users' money.
Why it matters
Bring-your-own-key apps move the bill to the user, which is why they feel safe. But the keys sit in your database, and any route that picks a key by an id from the request, without a session, can be pointed at someone else's key.
Your invoice doesn't change, so nothing alerts you. The user finds out from their provider's bill.
What it looks like
A route that loads a stored key by an id the caller supplies:
export async function POST(req: Request) {
const { keyId, messages } = await req.json();
const key = await db.apiKey.findUnique({ where: { id: keyId } });
return callModel(key.value, messages); // whose key is this?
}How to fix it
- Require a session on every route that uses a stored key.
- Look keys up by the signed-in user, never by an id from the request alone.
- Encrypt stored keys at rest and never send them back to the browser.
A real example: Chatbot UI
Computed by Skeram’s engine from the published teardown of Chatbot UI, at 1,000 monthly users (critical):
1 unauthenticated route calls models on your users' stored API keys. POST /api/chat/custom runs without a session but uses API keys users saved in the app. Your bill is untouched; theirs isn't — anyone who can address a key's record can spend it, and the user finds out from their provider invoice.
Suggested fix: Require a session and check the stored key belongs to the caller before using it; never select keys by an id taken from the request alone.
Evidence: app/api/chat/custom/route.ts:20-34.
How Skeram detects it
Skeram records whether each model call is paid by your key or a key the user brings, and whether the route requires a session. A user-key call on a route with no session is flagged as critical. Streamlit and Gradio apps that take the key in a text box for one session aren't flagged, because nothing is stored.
When it starts to hurt: Immediately. This is a security finding, not a scale finding.
Every finding cites the file and line it came from, and scanning again after a fix shows it resolved in History. How the analysis works.
Questions
Does this affect my bill?
No, it affects your users' bills, which is worse for trust. Skeram shows it as critical even though your own forecast doesn't move.
Related findings
- Background jobs that run inside requests: Work fired off from a request handler without a queue dies on deploys and crashes, never retries, and competes with live requests for the same server.
- Webhooks processed synchronously: A webhook handler that does its work before responding makes the sender retry under load, which doubles the traffic on an already slow handler.
- Database connection pools on serverless: On serverless hosting every concurrent function instance opens its own pool, so the total quickly exceeds what the database allows.
- A new database connection per request: Opening a fresh database connection on every request spends time and database capacity on setup, and runs into the connection limit long before the database is busy.
Find it in your code
Skeram reads your repo, prices every model call from 100 to 100,000 users, and flags these patterns with the file and line.