Security Automation
A security operations center has one scarce resource: analyst attention. Every alert that needs a human to pivot through three consoles, copy an IP into a reputation service and paste the verdict back into a ticket consumes minutes that the queue cannot return. Automation exists to spend that budget on judgment calls instead of mechanical steps. The hard part is not connecting tools to each other â any integration platform can do that â it is deciding which actions are safe to run without a human, which need approval, and how the system behaves when a threat feed, an API or a DNS resolver answers with garbage at three in the morning.
Automate by reversibility, not by excitement
The useful dividing line is not severity but consequence. Actions that only read data can run on every alert. Actions that change state but are easily undone can run automatically with logging. Actions that are hard to reverse or visible to customers need a human, at least until the playbook has run cleanly for weeks.
| Action class | Example | Automation level | Why |
|---|---|---|---|
| Read-only enrichment | Reputation lookup, asset ownership, past incidents | Fully automatic | Nothing changes if the lookup is wrong |
| Reversible containment | Block an IP at the edge, disable a mailbox rule | Automatic with rollback | A bad verdict costs minutes to undo |
| Disruptive containment | Isolate an endpoint, revoke all sessions | Automatic for critical alerts only | Productivity stops until an analyst releases it |
| Irreversible actions | Delete accounts, wipe a device, terminate a host | Human approval required | A wrong call destroys evidence or data |
| External communication | Notifying customers, regulators, press | Always human | Wording and legal exposure cannot be automated |
Teams that skip this table end up with an automation program nobody trusts: one false positive that quarantines the CEO's laptop sets the program back a quarter, because the fix everyone remembers is turning it off.
Anatomy of a phishing-response playbook
A good playbook is short, idempotent and explicit about its branches. The trigger is a user-reported message, and the sequence extracts indicators, enriches them, decides, acts, and closes the loop with the reporter. Every step declares what it does when the underlying service is unavailable, because a playbook that throws halfway through leaves an incident half-handled and no record of where it stopped.
name: phishing_response
description: Triage and contain user-reported email
trigger:
type: email_reported
source: mail_gateway
concurrency: single # never run twice for the same message
timeout_minutes: 10
steps:
- id: extract
action: extract_iocs
inputs: [body_html, attachments, urls]
on_error: abort_with_note
- id: enrich
action: enrich_indicators
inputs: [iocs]
strategy: parallel
on_timeout: continue # partial enrichment beats a stalled ticket
- id: decide
action: evaluate
rules:
- if: any_indicator_score >= 90
then: block_and_notify
- if: all_indicators_score <= 10
then: close_as_benign
- else: escalate_to_triage
- id: block_and_notify
action: block_sender_and_url
approval: required_if_scope == "external_domain"
rollback: remove_block
- id: close_as_benign
action: reply_to_reporter
message: "Checked: no malicious indicators found. Thanks for reporting."
- id: escalate_to_triage
action: create_case
priority: high
assign_to: tier2_queue
Two details in that file decide whether it survives production. concurrency: single prevents duplicate executions when a gateway retries a webhook, which is the most common cause of repeated blocks. The approval condition on the blocking step keeps internal lookalike domains automatic while anything touching an external sender waits for a person, which is exactly the asymmetry that makes automation acceptable to legal and support teams.
Enrichment without drowning in rate limits
Enrichment is where playbooks quietly fail. Three services queried in series add seconds, one of them is rate-limited to a few hundred calls a day, and a stale answer is worse than no answer because it looks authoritative. The pattern that works caches aggressively, treats every feed as untrusted input, and converts raw verdicts into a single confidence score the decision step can consume.
import time, hashlib, requests
CACHE_TTL = 3600
_cache = {}
def cached_get(url, headers, ttl=CACHE_TTL):
key = hashlib.sha256(url.encode()).hexdigest()
hit = _cache.get(key)
if hit and time.time() - hit[0] < ttl:
return hit[1]
resp = requests.get(url, headers=headers, timeout=5)
resp.raise_for_status()
_cache[key] = (time.time(), resp.json())
return _cache[key][1]
def indicator_score(ioc):
"""Blend vendor verdicts into one 0-100 confidence value."""
scores = []
try:
vt = cached_get(
f"https://virustotal.example/api/v3/search?query={ioc}",
{"x-apikey": VT_KEY},
)
hits = vt["data"][0]["attributes"]["last_analysis_stats"]["malicious"]
scores.append(min(100, hits * 4))
except Exception:
scores.append(None) # vendor down: no signal, not a zero
try:
ab = cached_get(f"https://abuseipdb.example/check?ipAddress={ioc}",
{"Key": ABUSE_KEY})
if ab["data"]["abuseConfidenceScore"] > 60:
scores.append(ab["data"]["abuseConfidenceScore"])
except Exception:
scores.append(None)
known = [s for s in scores if s is not None]
if not known:
return 25, "no vendor responded"
avg = sum(known) / len(known)
return round(avg), f"{len(known)}/{len(scores)} vendors answered"
The line that matters is appending None instead of zero when a vendor fails. Treating a timeout as "clean" silently converts an outage into a decision to let malicious mail through, and that failure mode has shipped into production playbooks at real companies. A missing signal should reduce confidence, not create it.
Guardrails for unattended response
Automation that runs while nobody watches needs boundaries written down, not remembered. Give every playbook a blast-radius budget: how many endpoints it may isolate, how many addresses it may block, and what it must do when it exceeds them â normally stop and escalate rather than continue. Add a global circuit breaker that pauses automated containment if the false-positive rate in the last hour crosses a threshold, because a bad indicator list from a feed is exactly the scenario where your response system becomes the incident.
Dry runs are the cheapest insurance available. Run new playbooks in shadow mode for a week, printing the actions they would take, and have an analyst compare that list against what they would have done manually. Divergence is a design review you get for free.
Connecting the stack you already own
Most teams do not start with a platform; they start with four tools, a scripting host and a ticket system. What makes those connections durable is a thin normalization layer: every integration converts its vendor-specific payload into one internal event shape, so playbook logic never references a vendor field name. When the company swaps its mail gateway two years later, only one adapter changes.
Webhook triggers beat polling for anything time-sensitive, while polling remains correct for state you must reconcile such as open cases. Store integration credentials in a secrets manager and rotate them, because an API token pasted into a playbook definition is a credential living in version control. Finally, make every connector idempotent on an external identifier â a message id, an incident number â so a retried delivery updates the same record instead of creating the duplicate that later confuses your metrics.
def normalize_alert(payload, source):
return {
"event_id": payload.get("message_id") or payload["alert_id"],
"source": source,
"severity": SEVERITY_MAP.get(payload.get("severity", ""), "medium"),
"indicators": payload.get("iocs", []),
"received_at": payload.get("timestamp"),
}
def upsert_case(session, alert):
existing = session.query(Case).filter_by(event_id=alert["event_id"]).first()
if existing:
existing.severity = alert["severity"] # webhook retried: update, not duplicate
return existing
session.add(Case(**alert))
return None
Measuring whether the automation helped
Automated response that reduces ticket count while raising missed detections is a loss. Track a small set of numbers with baselines taken before the playbook shipped.
| Metric | Definition | Baseline to beat |
|---|---|---|
| Time to first action | Trigger to first containment step | Median analyst triage time |
| Touch rate | Percentage of cases needing human edit | 100% before automation |
| Auto-closed accuracy | Sampled auto-closures that were correct | 99% or do not auto-close |
| Rollback rate | Actions reversed within 24 hours | Below 1% per playbook |
| Enrichment availability | Successful vendor responses per run | 95%, alert when lower |
Sample the auto-closed cases rather than trusting the counter: a playbook that closes four hundred tickets wrongly will otherwise be the best-performing system on the dashboard. Review the sample in the same weekly meeting where playbook changes are approved, so accuracy and iteration stay coupled.
đĄDesign for the bad day
Common Mistakes
Automating an irreversible action because it fires rarely
Fix: Gate anything destructive behind approval, and prove reversibility with rollback tests before removing the gate.
Treating a vendor timeout as a clean verdict
Fix: Model missing signals explicitly as no-signal, lower confidence and escalate instead of allowing.
Building playbooks with no execution caps or circuit breaker
Fix: Set per-run blast-radius limits and pause containment automatically when false positives spike.
Measuring success by ticket volume alone
Fix: Sample auto-closed cases for correctness and track rollback rate, or a broken playbook looks like your best performer.
Letting steps fail silently halfway through containment
Fix: Give every step an on_error branch that records where execution stopped and pages a human on partial completion.
Best Practices
- Classify every action by reversibility and encode the automation level in the playbook itself
- Run new playbooks in shadow mode for a week and compare their intended actions against analyst decisions
- Parallelize enrichment with per-vendor timeouts so one slow feed cannot stall the whole response
- Keep human-in-the-loop only where judgment is genuinely required, then widen automation as rollback rates stay flat
- Version playbooks in review like application code, with a changelog tied to incident retrospectives
Key Takeaways
- Automate read-only and reversible work first; destructive actions keep a human gate until trust is proven
- Idempotency, timeouts and error branches are what separate a production playbook from a demo
- Enrichment must distinguish a bad verdict from a missing one, because a timeout is not a clean result
- Blast-radius caps and circuit breakers stop your response tooling from becoming the incident
- Measure accuracy of auto-closures and rollback rate alongside speed, otherwise broken automation looks successful