‹ Resources

fundamentals · 6 min read

What a leaked model key actually exposes

A model API key is treated like a password, but it behaves like a filesystem credential. Here is what someone holding it can reach before they ever send a prompt.

The assumption

Teams store a model API key the way they store any secret, and reason about it the way they reason about a password: if it leaks, someone can run up a bill. That is the smallest part of the risk.

What the key can see

Most provider keys are not scoped to "send prompts". They can list and often download the resources attached to the account: uploaded files, fine-tuning datasets, stored assistants and their system prompts, vector stores and the documents inside them, batch jobs and their inputs. An admin-scoped key can go further and list projects, members and other keys.

None of that requires prompting a model. It is a few authenticated GET requests. A leaked key is not a meter someone can spin; it is a window into the data you attached to the account.

Why it happens

Keys get over-scoped because the narrow ones are inconvenient. One key ends up in the application, the data pipeline and a notebook, and it accumulates reach. The same key that answers chat requests can read the knowledge base behind them.

What to do

- Separate inference keys from data-plane keys. The key your app uses to send prompts should not be able to list files. - Use per-project keys and rotate them. Short-lived is better than clever. - Never ship an admin or organisation key to application code. - Test it. Model Inject's Key Exposure check enumerates exactly what a given key can reach, so you find the over-scoped one before an attacker does.