‹ Resources

attacks · 5 min read

API injection: when your endpoint leaks its own data

An AI-backed endpoint carries context: the system prompt, the records it looked up, sometimes upstream keys. The right request can make it hand that back.

The shape of it

You put a model behind an API. A request comes in, your code fetches some context (the user's account, a few records, a system prompt with your business rules) and the model answers. The context is right there in the model's window.

The attack

A request phrased as a formatting or debugging instruction tries to make the model print what it was given instead of answering the question. Done well it returns the system prompt, the records in context, or values your code passed through. The endpoint leaks its own API data.

Why models comply

The model cannot tell your instructions from the request's. They arrive through the same channel. Training reduces how often it complies; it does not make the channel separate.

What to do

- Authorise data access outside the model, per caller. The model should never be the thing deciding who sees a record. - Keep upstream keys and environment values out of the prompt entirely. - Filter outputs for prompt fingerprints and key-shaped strings before they leave. - Test the real request shape. Model Inject's API Injection check sends probes through your endpoint exactly as a caller would and judges whether your own data comes back.

API injection: when your endpoint leaks its own data · Model Inject