Skip to main content

Prompt Injection Incident Response: A Practical Playbook

· By Natalie Walls

Prompt injection incident response follows the usual security steps, prepare, detect, contain, recover and learn, with two twists: the "attacker's code" is plain text sitting in a document or web page, and the model's behavior can't be replayed exactly. So you need the right logs before anything goes wrong, and a fast way to cut off the model's tools when it does.

This playbook draws on the Coalition for Secure AI's AI Incident Response framework and Microsoft's guidance on investigating prompt abuse.

Before an incident: prepare

Log what you'll need to investigate

CoSAI points out that model outputs aren't deterministic, so you can't rerun a prompt later and expect the same result. You have to capture the original. Its suggested logging fields include:

FieldWhy it matters
timestamp, session or trace IDRebuild the sequence of events
user or machine identityWho triggered it
prompt text and completion textWhat went in and what came out
model name and versionBehavior changes between versions
retrieved documentsWhere an indirect injection came from
tool callsWhat the model actually did

Retrieved documents and tool calls are what answer "which web page made the agent do that?" CoSAI also recommends logging MCP message activity if you use MCP.

Build a kill switch

Decide in advance how to take an agent offline, disable a single tool, or roll back to a previous model or prompt. CoSAI lists all three as containment options. Test them, so the first time isn't during an incident.

Detect: what to watch for

Microsoft says teams "cannot solely rely on the intended behavior of AI tools" and should monitor how they're used. Signals worth alerting on:

  • Instruction-like text in content the model reads, such as documents, URL fragments or emails.
  • Prompts asking to ignore previous instructions or to print full sensitive contents.
  • The model accessing sensitive files or taking actions the user didn't ask for.
  • Links or images in output pointing at unfamiliar domains, a route used in several documented incidents. See Markdown Image Exfiltration.
  • Summaries that are oddly slanted or leave out key facts.

A detector can help raise alerts, but treat it as one signal among several.

Contain: stop the damage

Work through these in order, scaled to how bad it looks:

  1. Preserve evidence first. CoSAI recommends taking forensic copies before containment changes anything, and keeping a chain of custody. Save the system prompt, user prompts, parameters, raw outputs and the suspect document.
  2. Cut off actions. Disable the tools involved, or take the agent offline entirely.
  3. Quarantine the source. CoSAI's sample playbook routes by where the injection came from: quarantine the session if it came from user input, filter or rescore retrieved content if it came from the web, and disable the agent if its configuration was tampered with.
  4. Rotate secrets. Revoke any keys or tokens the model could reach, and anything that may have leaked.
  5. Tighten access. Microsoft suggests using access policies to restrict which tools and devices can reach internal resources, and data loss prevention rules so the AI can't read or act on sensitive files without authorization.

Investigate: work out what happened

Answer these questions from your logs:

  • Entry point: which input carried the instructions? A user message, an uploaded file, a web page, a tool response?
  • Scope: which sessions and users read that same content?
  • Actions: which tool calls ran, and with what arguments?
  • Data: what could the model see, and did any of it leave through a link, image, email or API call?
  • Root cause: which missing control let it work? Too many permissions, no human approval, unchecked output?

Microsoft's guidance ends this stage by documenting the incident and assessing whether any data was lost.

Recover

CoSAI's recovery steps are root cause analysis, patching or retraining, rotating credentials, and validating before you redeploy. For prompt injection, patching usually means a design change rather than a prompt tweak: removing a tool, adding an approval step, blocking external images, or separating untrusted content.

Before turning the agent back on, turn the incident into a test. Rebuild the attack path with a harmless canary in place of the real payload and confirm the fix holds. Then add it to your automated CI tests so it can't come back unnoticed.

Learn

Hold a blameless review and feed the lessons into your playbooks, as CoSAI recommends, and update your threat model.

One page checklist

  • Prompts, outputs, retrieved documents and tool calls are logged
  • Each agent and tool has a tested off switch
  • Evidence is copied before anything changes
  • Tools disabled, source quarantined, secrets rotated
  • Entry point, scope, actions and data loss documented
  • Fix verified with a canary test, then added to CI

Start with prevention: run our canary payloads against your app today so you find the gaps before an attacker does.