Retrieved pages, RAG passages and tool results can contain instructions that conflict with the user’s task. Treat them as untrusted data. Do not rely on a system prompt to make that data harmless, and do not let a model’s proposed tool call become authorization.
OpenAI describes prompt injection as third-party content that misleads a model into an unintended action. Its guidance recommends limiting access and reviewing important actions. OWASP similarly states that language models process instructions and data together, so filters are one layer rather than a complete boundary.
Put controls at the action boundary
The model may suggest a tool call. Your application must decide whether the authenticated user may perform that operation, on that target, with those arguments.
| Stage | Useful control | What it does not prove |
|---|---|---|
| Retrieval | Label source, preserve origin and screen suspicious content | That a benign-looking document is safe |
| Model call | Separate data from trusted instructions in the prompt format | That the model will obey the separation |
| Tool proposal | Validate schema, allowlist fields and check session authority | That the action matches user intent |
| Execution | Use least-privilege credentials and confirmation for consequential actions | That a prior response was harmless |
Consider a support agent that reads a ticket and can issue refunds. A malicious ticket can ask the agent to refund every customer. A safe design has the model propose one refund with an order ID; execution verifies that the signed-in employee may refund that order, checks a maximum amount, and requires a confirmation for the final payment operation. A detector can add evidence, but it is not the only thing preventing the transfer.
Test indirect content, not only chat prompts
OWASP’s prevention guidance calls out web pages, documents, email and tool output as indirect-injection channels. Build tests where harmless marker text appears in each real channel. Measure separately whether the model disclosed the marker, proposed a prohibited tool action, or caused a protected test endpoint to receive data.
Also test normal requests. A block rate without false positives can hide a control that rejects useful work. Include language variants, encoded text and a tool result that looks plausible but is wrong. A passing test suite shows only that your tested paths behaved as expected; it does not prove that injection is solved.
Alectura can inspect configured request parts and tool results for prompt injection, and records coverage so a record does not claim more than was inspected. It is not an MCP or tool gateway: the application still owns tool authorization and execution. Use this boundary when you test a customer policy with the quickstart.
Keep detection evidence separate from permission
Log source type, detector result, proposed operation, authorization decision and policy version. Exclude secrets and unnecessary prompt content. A sudden change in rejection rate can help investigations, but never use a low detector score as permission to run a sensitive operation. A failed or unavailable detector must have a defined fail-open or fail-closed behavior for each tool class.
Review this decision with the owner of every tool, rather than with only the team that owns the model integration. A read-only search tool, a customer-data export and a payment action need different scopes and recovery paths. Keep the model’s role narrow: propose the next step and explain it to the user. Let deterministic application code decide whether that step is allowed.
Give users a safe recovery path
A refusal must not force an employee to bypass the application. Return the rejected tool class and a safe next step without reflecting the untrusted text. For example, a support agent can save a proposed refund for review, while the employee completes the action in the billing system with normal authorization. Track these escalations separately from injection detections. A rising escalation rate can show that a permission rule is too broad or that a legitimate workflow needs a dedicated, least-privilege tool.
