Automating IOC Enrichment
When to Use
Use this skill when:
- Building a SOAR playbook that automatically enriches SIEM alerts with threat intelligence context before routing to analysts
- Creating a Python pipeline for bulk IOC enrichment from phishing email submissions
- Reducing analyst mean time to triage (MTTT) by pre-populating alert context with VT, Shodan, and MISP data
Do not use this skill for fully automated blocking decisions without human review — enrichment automation should inform decisions, not execute blocks autonomously for high-impact actions.
Prerequisites
- SOAR platform (Cortex XSOAR, Splunk SOAR, Tines, or n8n) or Python 3.9+ environment
- API keys: VirusTotal, AbuseIPDB, Shodan, and at minimum one TIP (MISP or OpenCTI)
- SIEM integration endpoint for alert consumption
- Rate limit budgets documented per API (VT: 4/min free, 500/min enterprise)
Workflow
Step 1: Design Enrichment Pipeline Architecture
Define the enrichment flow for each IOC type:
SIEM Alert → Extract IOCs → Classify Type → Route to enrichment functions
IP Address → AbuseIPDB + Shodan + VirusTotal IP + MISP
Domain → VirusTotal Domain + PassiveTotal + Shodan + MISP
URL → URLScan.io + VirusTotal URL + Google Safe Browse
File Hash → VirusTotal Files + MalwareBazaar + MISP
→ Aggregate results → Calculate confidence score → Update alert → Notify analyst
Step 2: Implement Python Enrichment Functions
import requests
import time
from dataclasses import dataclass, field
from typing import Optional
RATE_LIMIT_DELAY = 0.25 # 4 requests/second for VT free tier
@dataclass
class EnrichmentResult:
ioc_value: str
ioc_type: str
vt_malicious: int = 0
vt_total: int = 0
abuse_confidence: int = 0
shodan_ports: list = field(default_factory=list)
misp_events: list = field(default_factory=list)
confidence_score: int = 0
def enrich_ip(ip: str, vt_key: str, abuse_key: str, shodan_key: str) -> EnrichmentResult:
result = EnrichmentResult(ip, "ip")
# VirusTotal IP lookup
vt_resp = requests.get(
f"https://www.virustotal.com/api/v3/ip_addresses/{ip}",
headers={"x-apikey": vt_key}
)
if vt_resp.status_code == 200:
stats = vt_resp.json()["data"]["attributes"]["last_analysis_stats"]
result.vt_malicious = stats.get("malicious", 0)
result.vt_total = sum(stats.values())
time.sleep(RATE_LIMIT_DELAY)
# AbuseIPDB
abuse_resp = requests.get(
"https://api.abuseipdb.com/api/v2/check",
headers={"Key": abuse_key, "Accept": "application/json"},
params={"ipAddress": ip, "maxAgeInDays": 90}
)
if abuse_resp.status_code == 200:
result.abuse_confidence = abuse_resp.json()["data"]["abuseConfidenceScore"]
# Calculate composite confidence score
result.confidence_score = min(
(result.vt_malicious / max(result.vt_total, 1)) * 60 +
(result.abuse_confidence / 100) * 40, 100
)
return result
def enrich_hash(sha256: str, vt_key: str) -> EnrichmentResult:
result = EnrichmentResult(sha256, "sha256")
vt_resp = requests.get(
f"https://www.virustotal.com/api/v3/files/{sha256}",
headers={"x-apikey": vt_key}
)
if vt_resp.status_code == 200:
stats = vt_resp.json()["data"]["attributes"]["last_analysis_stats"]
result.vt_malicious = stats.get("malicious", 0)
result.vt_total = sum(stats.values())
result.confidence_score = int((result.vt_malicious / max(result.vt_total, 1)) * 100)
return result
Step 3: Build SOAR Playbook (Cortex XSOAR)
In Cortex XSOAR, create an enrichment playbook:
- Trigger: Alert created in SIEM (via webhook or polling)
- Extract IOCs: Use "Extract Indicators" task with regex patterns for IP, domain, URL, hash
- Parallel enrichment: Fan-out to multiple enrichment tasks simultaneously
- VT Enrichment: Call
!vt-file-scan or !vt-ip-scan commands
- AbuseIPDB check: Call
!abuseipdb-check-ip command
- MISP Lookup: Call
!misp-search for cross-referencing
- Score aggregation: Python transform task computing composite score
- Conditional routing: If score ≥70 → High Priority queue; if 40–69 → Medium; <40 → Auto-close with note
- Alert enrichment: Write enrichment results to alert context for analyst view
Step 4: Handle Rate Limiting and Failures
import time
from functools import wraps
def rate_limited(max_per_second):
min_interval = 1.0 / max_per_second
def decorator(func):
last_called = [0.0]
@wraps(func)
def wrapper(*args, **kwargs):
elapsed = time.time() - last_called[0]
wait = min_interval - elapsed
if wait > 0:
time.sleep(wait)
result = func(*args, **kwargs)
last_called[0] = time.time()
return result
return wrapper
return decorator
def retry_on_429(max_retries=3):
def decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
for attempt in range(max_retries):
response = func(*args, **kwargs)
if response.status_code == 429:
retry_after = int(response.headers.get("Retry-After", 60))
time.sleep(retry_after)
else:
return response
return wrapper
return decorator
Step 5: Metrics and Tuning
Track pipeline performance weekly:
- Enrichment latency: Target <30 seconds from alert trigger to enriched output
- API success rate: Target >99% (identify rate limit or outage events)
- True positive rate: Track analyst overrides of automated confidence scores
- Cost: Track API call volume against budget (VT Enterprise: $X per 1M lookups)
Key Concepts
| Term |
Definition |
| SOAR |
Security Orchestration, Automation, and Response — platform for automating security workflows and integrating disparate tools |
| Enrichment Playbook |
Automated workflow sequence that adds contextual intelligence to raw security events |
| Rate Limiting |
API provider restrictions on request frequency (e.g., VT free: 4 requests/minute); pipelines must respect these limits |
| Composite Confidence Score |
Single score aggregating signals from multiple enrichment sources using weighted formula |
| Fan-out Pattern |
Parallel execution of multiple enrichment queries simultaneously to minimize total enrichment latency |
Tools & Systems
- Cortex XSOAR (Palo Alto): Enterprise SOAR with 700+ marketplace integrations including VT, MISP, Shodan, and AbuseIPDB
- Splunk SOAR (Phantom): SOAR platform with Python-based playbooks; native Splunk SIEM integration
- Tines: No-code SOAR platform with webhook-driven automation; cost-effective for smaller teams
- TheHive + Cortex: Open-source IR/enrichment platform with observable enrichment via Cortex analyzers
Common Pitfalls
- Blocking on enrichment latency: If enrichment takes >5 minutes, analysts start working unenriched alerts, defeating the purpose. Set timeout limits and provide partial results.
- No caching: Querying the same IOC 50 times generates unnecessary API costs. Cache enrichment results for 24 hours by default.
- Ignoring API failures silently: Failed enrichment calls should be logged and trigger fallback logic, not silently produce empty results that appear as clean IOCs.
- Automating blocks on enrichment score alone: Composite scores contain false positives; require human confirmation for blocking decisions against shared infrastructure.
1---
2name: automating-ioc-enrichment
3description: 'Automates the enrichment of raw indicators of compromise with multi-source
4 threat intelligence context using SOAR platforms, Python pipelines, or TIP playbooks
5 to reduce analyst triage time and standardize enrichment outputs. Use when building
6 automated enrichment workflows integrated with SIEM alerts, email submission pipelines,
7 or bulk IOC processing from threat feeds. Activates for requests involving SOAR
8 enrichment, Cortex XSOAR, Splunk SOAR, TheHive, Python enrichment pipelines, or
9 automated IOC processing.
10
11 '
12domain: cybersecurity
13subdomain: threat-intelligence
14tags:
15- SOAR
16- enrichment
17- IOC
18- Cortex-XSOAR
19- Splunk-SOAR
20- VirusTotal
21- automation
22- CTI
23- NIST-CSF
24version: 1.0.0
25author: team-cybersecurity
26license: Apache-2.0
27nist_csf:
28- ID.RA-01
29- ID.RA-05
30- DE.CM-01
31- DE.AE-02
32mitre_attack:
33- T1071.001
34- T1583.001
35- T1588.001
36- T1590.005
37- T1596
38source: https://github.com/mukul975/Anthropic-Cybersecurity-Skills
39source_commit: 04450304b12645cb2b974ab96d28c0664758a88d
40metadata:
41 source: https://skillmd.com/skills/yanacuti1121/automating-ioc-enrichment
42---
43
44# Automating IOC Enrichment
45
46## When to Use
47
48Use this skill when:
49- Building a SOAR playbook that automatically enriches SIEM alerts with threat intelligence context before routing to analysts
50- Creating a Python pipeline for bulk IOC enrichment from phishing email submissions
51- Reducing analyst mean time to triage (MTTT) by pre-populating alert context with VT, Shodan, and MISP data
52
53**Do not use** this skill for fully automated blocking decisions without human review — enrichment automation should inform decisions, not execute blocks autonomously for high-impact actions.
54
55## Prerequisites
56
57- SOAR platform (Cortex XSOAR, Splunk SOAR, Tines, or n8n) or Python 3.9+ environment
58- API keys: VirusTotal, AbuseIPDB, Shodan, and at minimum one TIP (MISP or OpenCTI)
59- SIEM integration endpoint for alert consumption
60- Rate limit budgets documented per API (VT: 4/min free, 500/min enterprise)
61
62## Workflow
63
64### Step 1: Design Enrichment Pipeline Architecture
65
66Define the enrichment flow for each IOC type:
67```
68SIEM Alert → Extract IOCs → Classify Type → Route to enrichment functions
69 IP Address → AbuseIPDB + Shodan + VirusTotal IP + MISP
70 Domain → VirusTotal Domain + PassiveTotal + Shodan + MISP
71 URL → URLScan.io + VirusTotal URL + Google Safe Browse
72 File Hash → VirusTotal Files + MalwareBazaar + MISP
73→ Aggregate results → Calculate confidence score → Update alert → Notify analyst
74```
75
76### Step 2: Implement Python Enrichment Functions
77
78```python
79import requests
80import time
81from dataclasses import dataclass, field
82from typing import Optional
83
84RATE_LIMIT_DELAY = 0.25 # 4 requests/second for VT free tier
85
86@dataclass
87class EnrichmentResult:
88 ioc_value: str
89 ioc_type: str
90 vt_malicious: int = 0
91 vt_total: int = 0
92 abuse_confidence: int = 0
93 shodan_ports: list = field(default_factory=list)
94 misp_events: list = field(default_factory=list)
95 confidence_score: int = 0
96
97def enrich_ip(ip: str, vt_key: str, abuse_key: str, shodan_key: str) -> EnrichmentResult:
98 result = EnrichmentResult(ip, "ip")
99
100 # VirusTotal IP lookup
101 vt_resp = requests.get(
102 f"https://www.virustotal.com/api/v3/ip_addresses/{ip}",
103 headers={"x-apikey": vt_key}
104 )
105 if vt_resp.status_code == 200:
106 stats = vt_resp.json()["data"]["attributes"]["last_analysis_stats"]
107 result.vt_malicious = stats.get("malicious", 0)
108 result.vt_total = sum(stats.values())
109
110 time.sleep(RATE_LIMIT_DELAY)
111
112 # AbuseIPDB
113 abuse_resp = requests.get(
114 "https://api.abuseipdb.com/api/v2/check",
115 headers={"Key": abuse_key, "Accept": "application/json"},
116 params={"ipAddress": ip, "maxAgeInDays": 90}
117 )
118 if abuse_resp.status_code == 200:
119 result.abuse_confidence = abuse_resp.json()["data"]["abuseConfidenceScore"]
120
121 # Calculate composite confidence score
122 result.confidence_score = min(
123 (result.vt_malicious / max(result.vt_total, 1)) * 60 +
124 (result.abuse_confidence / 100) * 40, 100
125 )
126
127 return result
128
129def enrich_hash(sha256: str, vt_key: str) -> EnrichmentResult:
130 result = EnrichmentResult(sha256, "sha256")
131 vt_resp = requests.get(
132 f"https://www.virustotal.com/api/v3/files/{sha256}",
133 headers={"x-apikey": vt_key}
134 )
135 if vt_resp.status_code == 200:
136 stats = vt_resp.json()["data"]["attributes"]["last_analysis_stats"]
137 result.vt_malicious = stats.get("malicious", 0)
138 result.vt_total = sum(stats.values())
139 result.confidence_score = int((result.vt_malicious / max(result.vt_total, 1)) * 100)
140 return result
141```
142
143### Step 3: Build SOAR Playbook (Cortex XSOAR)
144
145In Cortex XSOAR, create an enrichment playbook:
1461. **Trigger**: Alert created in SIEM (via webhook or polling)
1472. **Extract IOCs**: Use "Extract Indicators" task with regex patterns for IP, domain, URL, hash
1483. **Parallel enrichment**: Fan-out to multiple enrichment tasks simultaneously
1494. **VT Enrichment**: Call `!vt-file-scan` or `!vt-ip-scan` commands
1505. **AbuseIPDB check**: Call `!abuseipdb-check-ip` command
1516. **MISP Lookup**: Call `!misp-search` for cross-referencing
1527. **Score aggregation**: Python transform task computing composite score
1538. **Conditional routing**: If score ≥70 → High Priority queue; if 40–69 → Medium; <40 → Auto-close with note
1549. **Alert enrichment**: Write enrichment results to alert context for analyst view
155
156### Step 4: Handle Rate Limiting and Failures
157
158```python
159import time
160from functools import wraps
161
162def rate_limited(max_per_second):
163 min_interval = 1.0 / max_per_second
164 def decorator(func):
165 last_called = [0.0]
166 @wraps(func)
167 def wrapper(*args, **kwargs):
168 elapsed = time.time() - last_called[0]
169 wait = min_interval - elapsed
170 if wait > 0:
171 time.sleep(wait)
172 result = func(*args, **kwargs)
173 last_called[0] = time.time()
174 return result
175 return wrapper
176 return decorator
177
178def retry_on_429(max_retries=3):
179 def decorator(func):
180 @wraps(func)
181 def wrapper(*args, **kwargs):
182 for attempt in range(max_retries):
183 response = func(*args, **kwargs)
184 if response.status_code == 429:
185 retry_after = int(response.headers.get("Retry-After", 60))
186 time.sleep(retry_after)
187 else:
188 return response
189 return wrapper
190 return decorator
191```
192
193### Step 5: Metrics and Tuning
194
195Track pipeline performance weekly:
196- **Enrichment latency**: Target <30 seconds from alert trigger to enriched output
197- **API success rate**: Target >99% (identify rate limit or outage events)
198- **True positive rate**: Track analyst overrides of automated confidence scores
199- **Cost**: Track API call volume against budget (VT Enterprise: $X per 1M lookups)
200
201## Key Concepts
202
203| Term | Definition |
204|------|-----------|
205| **SOAR** | Security Orchestration, Automation, and Response — platform for automating security workflows and integrating disparate tools |
206| **Enrichment Playbook** | Automated workflow sequence that adds contextual intelligence to raw security events |
207| **Rate Limiting** | API provider restrictions on request frequency (e.g., VT free: 4 requests/minute); pipelines must respect these limits |
208| **Composite Confidence Score** | Single score aggregating signals from multiple enrichment sources using weighted formula |
209| **Fan-out Pattern** | Parallel execution of multiple enrichment queries simultaneously to minimize total enrichment latency |
210
211## Tools & Systems
212
213- **Cortex XSOAR (Palo Alto)**: Enterprise SOAR with 700+ marketplace integrations including VT, MISP, Shodan, and AbuseIPDB
214- **Splunk SOAR (Phantom)**: SOAR platform with Python-based playbooks; native Splunk SIEM integration
215- **Tines**: No-code SOAR platform with webhook-driven automation; cost-effective for smaller teams
216- **TheHive + Cortex**: Open-source IR/enrichment platform with observable enrichment via Cortex analyzers
217
218## Common Pitfalls
219
220- **Blocking on enrichment latency**: If enrichment takes >5 minutes, analysts start working unenriched alerts, defeating the purpose. Set timeout limits and provide partial results.
221- **No caching**: Querying the same IOC 50 times generates unnecessary API costs. Cache enrichment results for 24 hours by default.
222- **Ignoring API failures silently**: Failed enrichment calls should be logged and trigger fallback logic, not silently produce empty results that appear as clean IOCs.
223- **Automating blocks on enrichment score alone**: Composite scores contain false positives; require human confirmation for blocking decisions against shared infrastructure.