AI application security / 8 min

Prompt injection: treat content as untrusted

Protect AI applications that read webpages, files, email, retrieved records or user-controlled instructions.

Prompt injection occurs when instructions embedded in user or external content alter intended model behaviour. It cannot be solved by a single warning in the system prompt.

Immediate steps

  • Separate untrusted content from trusted instructions and tool-control logic.
  • Do not allow model output to directly execute privileged actions.
  • Validate tool arguments and enforce authorisation outside the model.
  • Test direct, indirect, encoded and multi-step injection scenarios.

Assume retrieved content may be hostile

A webpage, PDF, email, code repository or knowledge-base entry can contain instructions intended for the model rather than the human reader. The content may attempt to reveal data, redirect a workflow or trigger a tool.

Sanitisation helps but is not a complete defence because malicious instructions can be expressed in many forms.

Keep security decisions outside the model

Use application rules for authentication, authorisation, input validation, data access and transaction limits. The model can propose an action, but code should decide whether the action is permitted.

Use allowlists for tools and parameters, narrow retrieval scopes and structured outputs that are validated before use.

Monitor the complete chain

Record the source content, model decision, tool request, policy decision and outcome. Monitoring only the final response can miss manipulation between processing steps.

Create abuse tests and incident playbooks for data exposure, unauthorised tool use and unexpected cross-user access.

Checklist

Further reading

Educational guidance. Adapt this to your policies and incident process. Checklist selections are temporary and are not sent anywhere.