AI Security
Incident Response Playbook for Data‑Exfiltration by AI Agents in Small Companies
TL;DR: Treat an AI‑driven data‑exfiltration event like any other breach: detect the anomalous outbound call, isolate the agent, revoke its credentials, investigate the root cause, and harden the workflow. A concise five‑step playbook—Detect, Contain, Eradicate, Recover, Review—keeps response fast and auditable for small teams.
What does data‑exfiltration by an AI agent look like?
AI agents often have the ability to call external APIs, write files, or execute shell commands. When a mis‑configured prompt or a compromised model is used, the agent may try to send confidential text (e.g., customer contracts, PII) to an attacker‑controlled endpoint, embed it in a DNS query, or upload it to a cloud storage bucket. The key indicators are:
- Outbound HTTP requests to unknown domains.
- Unexpected file writes in temporary directories.
- Shell commands that invoke
curl,wget, orscpwith data payloads.
How can a small team detect suspicious outbound activity?
Detection must be baked into the AI workflow, not bolted on after a breach. Follow these practical steps:
- Enable structured logging. Use JSON logs that capture
agent_id,prompt_hash,api_endpoint,payload_size, andtimestamp. Example snippet for OpenAI Agents SDK:
import logging, json
logger = logging.getLogger("ai_agent")
handler = logging.FileHandler("agent.log")
handler.setFormatter(logging.Formatter('%(message)s'))
logger.addHandler(handler)
def log_api_call(agent_id, endpoint, payload):
entry = {
"agent_id": agent_id,
"api_endpoint": endpoint,
"payload_size": len(payload),
"timestamp": datetime.utcnow().isoformat()
}
logger.info(json.dumps(entry))
- Whitelist approved destinations. Maintain a YAML file of allowed domains (e.g.,
api.salesforce.com,hooks.zapier.com) and reject any request outside the list. - Rate‑limit and alert on spikes. A sudden burst of >10 KB payloads to a new domain should trigger an immediate Slack or PagerDuty alert.
- Leverage network egress monitoring. Cloud providers (AWS VPC Flow Logs, GCP VPC Flow) can surface unexpected IPs. Correlate with agent logs for a full picture.
Step‑by‑step response workflow
When an alert fires, run the following five‑step playbook. Keep a shared incident‑response checklist (Google Sheet, Notion page, or a simple markdown file) so every team member knows the exact commands.
1. Detect & Verify
Confirm the alert by checking the structured log entry. Verify the agent_id, the exact payload, and the destination URL. If the payload contains keywords like "SSN", "credit card", or matches a known document hash, treat it as a confirmed exfiltration attempt.
2. Contain
Immediately isolate the offending agent:
- Stop the container or process (
docker stop ai_agent_42). - Revoke any API keys or service tokens the agent is using (e.g., via the OpenAI dashboard or your secret‑manager).
- Block the destination IP/domain at the firewall level.
3. Eradicate
Search for residual copies of the leaked data:
- Inspect temporary directories (
/tmp,/var/tmp) for files created by the agent. - Check cloud storage buckets for newly created objects with timestamps matching the incident.
- Run a forensic hash scan on the host to ensure no hidden payloads remain.
4. Recover
After the environment is clean, restart a hardened version of the agent:
- Apply the least‑privilege token scopes defined in the NIST AI RMF (e.g., read‑only CRM, no write access to external storage).
- Enable the whitelist‑only network policy again.
- Run a smoke test that simulates a normal request and confirms no outbound traffic to unauthorized endpoints.
5. Review & Harden
Conduct a post‑mortem within 48 hours. Capture answers to the following questions:
- Which prompt or model caused the behavior?
- Were any third‑party libraries out‑of‑date?
- Did the token scope follow the principle of least privilege?
- What detection gaps existed?
Update the incident‑response checklist, tighten the whitelist, and add a unit test that feeds the offending prompt to the agent and asserts that no external call is made.
Tools and templates for small teams
Below is a minimal set of open‑source utilities that fit within a lean budget:
- OWASP GenAI Security Project – provides a checklist for prompt‑injection and data‑leak testing.
- OpenAI Agents SDK – includes built‑in logging hooks you can extend.
- Fail2Ban – can be configured to block repeated outbound connections to unknown hosts.
- Prometheus + Alertmanager – lightweight monitoring for API‑call metrics.
Store the incident‑response checklist in a version‑controlled repo so changes are auditable. AISecAll can help you set up the monitoring stack and tailor the checklist to your specific SaaS integrations.
Need a practical AI security review?
AISecAll reviews prompts, tool permissions, document flows, and agent behavior so small teams can use AI without guessing where the risk sits.