AI incidents look different from server incidents: the attacker never
touches a shell, the evidence is in prompts and tool calls, and the
"vulnerability" may be the model's normal behavior under adversarial
input. This skill covers response for AI specific scenarios: scoping
what the model or agent did, collecting prompt and tool logs,
containing without destroying evidence, and recovering to a known good
model and prompt version.
Quick Workflow
- Declare the incident and freeze the AI surface: disable the agent's
tool access or take the endpoint out of rotation.
- Scope the blast radius: which users, sessions, tools, and data the
model touched during the window.
- Collect prompt logs, tool call logs, and retrieval logs for the
window, plus the exact model and prompt versions.
- Identify the attack path: direct injection, poisoned document, or
abused tool, with the exact inputs.
- Contain: revoke leaked keys, rotate secrets found in prompts, and
roll back to the last known good model and prompt.
- Eradicate the cause: remove poisoned documents, fix the access
control, or tighten the tool scope.
- Recover in stages: read only mode first, then tools with approvals,
then full service.
- Write the post incident review with detection gaps and new monitors.
1. Scoping and log collection
Prompts are the crime scene. Collect them before retention windows
expire.
# Pull prompt and tool logs for the incident window (example: JSONL store)
jq -c 'select(.ts >= "2026-10-22T14:00:00Z" and .ts <= "2026-10-22T16:00:00Z")' \
/var/log/llm/prompts.jsonl > /tmp/ir/prompts_window.jsonl
wc -l /tmp/ir/prompts_window.jsonl
# Find sessions with tool calls the user never requested
jq -c 'select(.tool_calls != null and .user_requested_tools == false)' \
/tmp/ir/prompts_window.jsonl | head -20
# List which documents were retrieved in the window (RAG incidents)
jq -r 'select(.retrieved_docs != null) | .retrieved_docs[]' \
/tmp/ir/prompts_window.jsonl | sort | uniq -c | sort -rn | head -20
# Record exact model and prompt versions for reproducibility
cat /etc/ai-service/model_version.txt
git -C /opt/ai-service/prompts log --oneline -5
# Snapshot the current prompt set before rollback
cp -r /opt/ai-service/prompts /tmp/ir/prompts_snapshot_incident
2. Containment and recovery
Contain the agent first, then the model, then the data.
# 1. Revoke the agent's tool credentials immediately
# (example: disable the tool service account)
sudo usermod --lock agent-tools-svc
# or revoke the OAuth grant the agent uses
curl -s -X DELETE 'https://auth.internal/grants/agent-tools-svc' \
-H "Authorization: Bearer $ADMIN_TOKEN"
# 2. Rotate any secret that appeared in prompts or outputs
grep -rhoE "sk-[A-Za-z0-9]{20,}" /tmp/ir/prompts_window.jsonl | sort -u \
> /tmp/ir/leaked_keys.txt
wc -l /tmp/ir/leaked_keys.txt
# rotate each key at its provider, then purge from logs per policy
# 3. Roll back model and prompt to last known good
cat /tmp/ir/last_known_good.txt # maintained by the deploy pipeline
# redeploy that version, then re-enable in stages
Recover in stages and watch the new monitors: first serve with tools
disabled, then enable tools with human approval, then restore full
service only after the post incident review is scheduled.
Edge cases
- Prompt logs are sampled, not complete. Note the sampling rate; the
attack path may have gaps you cannot close.
- The model is hosted by a third party and you have no prompt logs.
Scope from your application logs: what your app sent and received.
- The incident is ongoing abuse (spam, fraud) rather than a breach.
Containment means rate limits and account bans, not forensics.
- Rollback changes model behavior and breaks pinned evaluations.
Re-run the eval suite against the rolled back version before full
recovery.
- Legal holds require keeping prompts that contain personal data.
Coordinate with legal before purging anything.
Escalation
- Attacker still active in sessions: kill sessions server side and
force reauthentication for affected users.
- Poisoned document source unknown: quarantine the whole index and
rebuild from versioned sources.
- Model weights suspected tampered: pull a fresh copy from the official
publisher, verify the hash, and redeploy.
- Third party model misbehaving: open a sev case with the provider with
your logged evidence, and fail over to a secondary provider.
Detection and defender view
Mature AI monitoring watches for prompt injection signatures in inputs,
impossible tool call sequences, retrieval of unusual document sets, and
spikes in refusal rates or token spend. After an incident, add the
attack's exact patterns as detection rules: the poisoned document hash,
the injection phrasing, and the tool call chain. Keep an AI incident
playbook separate from the server playbook, with contact details for
the model provider and pre approved containment actions, because the
first hour of an AI incident is spent deciding what you are even
allowed to turn off.
Key references
- NIST AI 100-2e2025: incident considerations for AI systems.
- OWASP Top 10 for LLM Applications: LLM09 Misuse scenarios.
- MITRE ATLAS: incident scoping for ML systems.
- Related skills: incident-response, incident-playbooks, log-forensics.
1---2name: ai-incident-response3description: "Use when responding to a suspected security incident involving an AI system: a hijacked agent, a poisoned model, leaked prompts, or abusive use of inference infrastructure. Covers scoping, prompt and tool log collection, model rollback, and containment that accounts for non deterministic behavior. Also use when building an IR playbook that covers LLM specific scenarios."4version: 1.0.05domain: ai-security6lifecycle: stable7last_verified: '2026-10-23'8requires: []9extends: []10relates: [incident-response, incident-playbooks, log-forensics]11tools:12 - name: Python13 version: '3.12'14 - name: jq15 version: 1.716metadata:17 source: https://skillmd.com/skills/mizazhaider-ceh/ai-incident-response18---1920AI incidents look different from server incidents: the attacker never21touches a shell, the evidence is in prompts and tool calls, and the22"vulnerability" may be the model's normal behavior under adversarial23input. This skill covers response for AI specific scenarios: scoping24what the model or agent did, collecting prompt and tool logs,25containing without destroying evidence, and recovering to a known good26model and prompt version.2728## Quick Workflow29301. Declare the incident and freeze the AI surface: disable the agent's31 tool access or take the endpoint out of rotation.322. Scope the blast radius: which users, sessions, tools, and data the33 model touched during the window.343. Collect prompt logs, tool call logs, and retrieval logs for the35 window, plus the exact model and prompt versions.364. Identify the attack path: direct injection, poisoned document, or37 abused tool, with the exact inputs.385. Contain: revoke leaked keys, rotate secrets found in prompts, and39 roll back to the last known good model and prompt.406. Eradicate the cause: remove poisoned documents, fix the access41 control, or tighten the tool scope.427. Recover in stages: read only mode first, then tools with approvals,43 then full service.448. Write the post incident review with detection gaps and new monitors.4546## 1. Scoping and log collection4748Prompts are the crime scene. Collect them before retention windows49expire.5051```bash52# Pull prompt and tool logs for the incident window (example: JSONL store)53jq -c 'select(.ts >= "2026-10-22T14:00:00Z" and .ts <= "2026-10-22T16:00:00Z")' \54 /var/log/llm/prompts.jsonl > /tmp/ir/prompts_window.jsonl55wc -l /tmp/ir/prompts_window.jsonl5657# Find sessions with tool calls the user never requested58jq -c 'select(.tool_calls != null and .user_requested_tools == false)' \59 /tmp/ir/prompts_window.jsonl | head -206061# List which documents were retrieved in the window (RAG incidents)62jq -r 'select(.retrieved_docs != null) | .retrieved_docs[]' \63 /tmp/ir/prompts_window.jsonl | sort | uniq -c | sort -rn | head -2064```6566```bash67# Record exact model and prompt versions for reproducibility68cat /etc/ai-service/model_version.txt69git -C /opt/ai-service/prompts log --oneline -570# Snapshot the current prompt set before rollback71cp -r /opt/ai-service/prompts /tmp/ir/prompts_snapshot_incident72```7374## 2. Containment and recovery7576Contain the agent first, then the model, then the data.7778```bash79# 1. Revoke the agent's tool credentials immediately80# (example: disable the tool service account)81sudo usermod --lock agent-tools-svc82# or revoke the OAuth grant the agent uses83curl -s -X DELETE 'https://auth.internal/grants/agent-tools-svc' \84 -H "Authorization: Bearer $ADMIN_TOKEN"8586# 2. Rotate any secret that appeared in prompts or outputs87grep -rhoE "sk-[A-Za-z0-9]{20,}" /tmp/ir/prompts_window.jsonl | sort -u \88 > /tmp/ir/leaked_keys.txt89wc -l /tmp/ir/leaked_keys.txt90# rotate each key at its provider, then purge from logs per policy9192# 3. Roll back model and prompt to last known good93cat /tmp/ir/last_known_good.txt # maintained by the deploy pipeline94# redeploy that version, then re-enable in stages95```9697Recover in stages and watch the new monitors: first serve with tools98disabled, then enable tools with human approval, then restore full99service only after the post incident review is scheduled.100101## Edge cases102103- Prompt logs are sampled, not complete. Note the sampling rate; the104 attack path may have gaps you cannot close.105- The model is hosted by a third party and you have no prompt logs.106 Scope from your application logs: what your app sent and received.107- The incident is ongoing abuse (spam, fraud) rather than a breach.108 Containment means rate limits and account bans, not forensics.109- Rollback changes model behavior and breaks pinned evaluations.110 Re-run the eval suite against the rolled back version before full111 recovery.112- Legal holds require keeping prompts that contain personal data.113 Coordinate with legal before purging anything.114115## Escalation116117- Attacker still active in sessions: kill sessions server side and118 force reauthentication for affected users.119- Poisoned document source unknown: quarantine the whole index and120 rebuild from versioned sources.121- Model weights suspected tampered: pull a fresh copy from the official122 publisher, verify the hash, and redeploy.123- Third party model misbehaving: open a sev case with the provider with124 your logged evidence, and fail over to a secondary provider.125126## Detection and defender view127128Mature AI monitoring watches for prompt injection signatures in inputs,129impossible tool call sequences, retrieval of unusual document sets, and130spikes in refusal rates or token spend. After an incident, add the131attack's exact patterns as detection rules: the poisoned document hash,132the injection phrasing, and the tool call chain. Keep an AI incident133playbook separate from the server playbook, with contact details for134the model provider and pre approved containment actions, because the135first hour of an AI incident is spent deciding what you are even136allowed to turn off.137138## Key references139140- NIST AI 100-2e2025: incident considerations for AI systems.141- OWASP Top 10 for LLM Applications: LLM09 Misuse scenarios.142- MITRE ATLAS: incident scoping for ML systems.143- Related skills: incident-response, incident-playbooks, log-forensics.