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-enrichment3description: 'Automates the enrichment of raw indicators of compromise with multi-source4 threat intelligence context using SOAR platforms, Python pipelines, or TIP playbooks5 to reduce analyst triage time and standardize enrichment outputs. Use when building6 automated enrichment workflows integrated with SIEM alerts, email submission pipelines,7 or bulk IOC processing from threat feeds. Activates for requests involving SOAR8 enrichment, Cortex XSOAR, Splunk SOAR, TheHive, Python enrichment pipelines, or9 automated IOC processing.1011 '12domain: cybersecurity13subdomain: threat-intelligence14tags:15- SOAR16- enrichment17- IOC18- Cortex-XSOAR19- Splunk-SOAR20- VirusTotal21- automation22- CTI23- NIST-CSF24version: 1.0.025author: team-cybersecurity26license: Apache-2.027nist_csf:28- ID.RA-0129- ID.RA-0530- DE.CM-0131- DE.AE-0232mitre_attack:33- T1071.00134- T1583.00135- T1588.00136- T1590.00537- T159638metadata:39 source: https://skillmd.com/skills/mukul975/automating-ioc-enrichment40---4142# Automating IOC Enrichment4344## When to Use4546Use this skill when:47- Building a SOAR playbook that automatically enriches SIEM alerts with threat intelligence context before routing to analysts48- Creating a Python pipeline for bulk IOC enrichment from phishing email submissions49- Reducing analyst mean time to triage (MTTT) by pre-populating alert context with VT, Shodan, and MISP data5051**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.5253## Prerequisites5455- SOAR platform (Cortex XSOAR, Splunk SOAR, Tines, or n8n) or Python 3.9+ environment56- API keys: VirusTotal, AbuseIPDB, Shodan, and at minimum one TIP (MISP or OpenCTI)57- SIEM integration endpoint for alert consumption58- Rate limit budgets documented per API (VT: 4/min free, 500/min enterprise)5960## Workflow6162### Step 1: Design Enrichment Pipeline Architecture6364Define the enrichment flow for each IOC type:65```66SIEM Alert → Extract IOCs → Classify Type → Route to enrichment functions67 IP Address → AbuseIPDB + Shodan + VirusTotal IP + MISP68 Domain → VirusTotal Domain + PassiveTotal + Shodan + MISP69 URL → URLScan.io + VirusTotal URL + Google Safe Browse70 File Hash → VirusTotal Files + MalwareBazaar + MISP71→ Aggregate results → Calculate confidence score → Update alert → Notify analyst72```7374### Step 2: Implement Python Enrichment Functions7576```python77import requests78import time79from dataclasses import dataclass, field80from typing import Optional8182RATE_LIMIT_DELAY = 0.25 # 4 requests/second for VT free tier8384@dataclass85class EnrichmentResult:86 ioc_value: str87 ioc_type: str88 vt_malicious: int = 089 vt_total: int = 090 abuse_confidence: int = 091 shodan_ports: list = field(default_factory=list)92 misp_events: list = field(default_factory=list)93 confidence_score: int = 09495def enrich_ip(ip: str, vt_key: str, abuse_key: str, shodan_key: str) -> EnrichmentResult:96 result = EnrichmentResult(ip, "ip")9798 # VirusTotal IP lookup99 vt_resp = requests.get(100 f"https://www.virustotal.com/api/v3/ip_addresses/{ip}",101 headers={"x-apikey": vt_key}102 )103 if vt_resp.status_code == 200:104 stats = vt_resp.json()["data"]["attributes"]["last_analysis_stats"]105 result.vt_malicious = stats.get("malicious", 0)106 result.vt_total = sum(stats.values())107108 time.sleep(RATE_LIMIT_DELAY)109110 # AbuseIPDB111 abuse_resp = requests.get(112 "https://api.abuseipdb.com/api/v2/check",113 headers={"Key": abuse_key, "Accept": "application/json"},114 params={"ipAddress": ip, "maxAgeInDays": 90}115 )116 if abuse_resp.status_code == 200:117 result.abuse_confidence = abuse_resp.json()["data"]["abuseConfidenceScore"]118119 # Calculate composite confidence score120 result.confidence_score = min(121 (result.vt_malicious / max(result.vt_total, 1)) * 60 +122 (result.abuse_confidence / 100) * 40, 100123 )124125 return result126127def enrich_hash(sha256: str, vt_key: str) -> EnrichmentResult:128 result = EnrichmentResult(sha256, "sha256")129 vt_resp = requests.get(130 f"https://www.virustotal.com/api/v3/files/{sha256}",131 headers={"x-apikey": vt_key}132 )133 if vt_resp.status_code == 200:134 stats = vt_resp.json()["data"]["attributes"]["last_analysis_stats"]135 result.vt_malicious = stats.get("malicious", 0)136 result.vt_total = sum(stats.values())137 result.confidence_score = int((result.vt_malicious / max(result.vt_total, 1)) * 100)138 return result139```140141### Step 3: Build SOAR Playbook (Cortex XSOAR)142143In Cortex XSOAR, create an enrichment playbook:1441. **Trigger**: Alert created in SIEM (via webhook or polling)1452. **Extract IOCs**: Use "Extract Indicators" task with regex patterns for IP, domain, URL, hash1463. **Parallel enrichment**: Fan-out to multiple enrichment tasks simultaneously1474. **VT Enrichment**: Call `!vt-file-scan` or `!vt-ip-scan` commands1485. **AbuseIPDB check**: Call `!abuseipdb-check-ip` command1496. **MISP Lookup**: Call `!misp-search` for cross-referencing1507. **Score aggregation**: Python transform task computing composite score1518. **Conditional routing**: If score ≥70 → High Priority queue; if 40–69 → Medium; <40 → Auto-close with note1529. **Alert enrichment**: Write enrichment results to alert context for analyst view153154### Step 4: Handle Rate Limiting and Failures155156```python157import time158from functools import wraps159160def rate_limited(max_per_second):161 min_interval = 1.0 / max_per_second162 def decorator(func):163 last_called = [0.0]164 @wraps(func)165 def wrapper(*args, **kwargs):166 elapsed = time.time() - last_called[0]167 wait = min_interval - elapsed168 if wait > 0:169 time.sleep(wait)170 result = func(*args, **kwargs)171 last_called[0] = time.time()172 return result173 return wrapper174 return decorator175176def retry_on_429(max_retries=3):177 def decorator(func):178 @wraps(func)179 def wrapper(*args, **kwargs):180 for attempt in range(max_retries):181 response = func(*args, **kwargs)182 if response.status_code == 429:183 retry_after = int(response.headers.get("Retry-After", 60))184 time.sleep(retry_after)185 else:186 return response187 return wrapper188 return decorator189```190191### Step 5: Metrics and Tuning192193Track pipeline performance weekly:194- **Enrichment latency**: Target <30 seconds from alert trigger to enriched output195- **API success rate**: Target >99% (identify rate limit or outage events)196- **True positive rate**: Track analyst overrides of automated confidence scores197- **Cost**: Track API call volume against budget (VT Enterprise: $X per 1M lookups)198199## Key Concepts200201| Term | Definition |202|------|-----------|203| **SOAR** | Security Orchestration, Automation, and Response — platform for automating security workflows and integrating disparate tools |204| **Enrichment Playbook** | Automated workflow sequence that adds contextual intelligence to raw security events |205| **Rate Limiting** | API provider restrictions on request frequency (e.g., VT free: 4 requests/minute); pipelines must respect these limits |206| **Composite Confidence Score** | Single score aggregating signals from multiple enrichment sources using weighted formula |207| **Fan-out Pattern** | Parallel execution of multiple enrichment queries simultaneously to minimize total enrichment latency |208209## Tools & Systems210211- **Cortex XSOAR (Palo Alto)**: Enterprise SOAR with 700+ marketplace integrations including VT, MISP, Shodan, and AbuseIPDB212- **Splunk SOAR (Phantom)**: SOAR platform with Python-based playbooks; native Splunk SIEM integration213- **Tines**: No-code SOAR platform with webhook-driven automation; cost-effective for smaller teams214- **TheHive + Cortex**: Open-source IR/enrichment platform with observable enrichment via Cortex analyzers215216## Common Pitfalls217218- **Blocking on enrichment latency**: If enrichment takes >5 minutes, analysts start working unenriched alerts, defeating the purpose. Set timeout limits and provide partial results.219- **No caching**: Querying the same IOC 50 times generates unnecessary API costs. Cache enrichment results for 24 hours by default.220- **Ignoring API failures silently**: Failed enrichment calls should be logged and trigger fallback logic, not silently produce empty results that appear as clean IOCs.221- **Automating blocks on enrichment score alone**: Composite scores contain false positives; require human confirmation for blocking decisions against shared infrastructure.