Implementing STIX/TAXII Feed Integration
Overview
STIX (Structured Threat Information eXpression) and TAXII (Trusted Automated eXchange of Intelligence Information) are OASIS open standards for representing and transporting cyber threat intelligence. This skill covers implementing a STIX/TAXII 2.1 feed consumer and producer using Python, configuring TAXII server discovery, collection management, polling for new intelligence, parsing STIX 2.1 objects, and integrating feeds into SIEM and TIP platforms.
When to Use
- When deploying or configuring implementing stix taxii feed integration capabilities in your environment
- When establishing security controls aligned to compliance requirements
- When building or improving security architecture for this domain
- When conducting security assessments that require this implementation
Prerequisites
- Python 3.9+ with
taxii2-client, stix2, cti-taxii-client libraries
- Understanding of STIX 2.1 data model (SDOs, SCOs, SROs)
- Understanding of TAXII 2.1 protocol (discovery, API roots, collections)
- Network access to TAXII servers (MITRE ATT&CK TAXII, Anomali STAXX)
- Optional: medallion for running a local TAXII 2.1 server
Key Concepts
TAXII 2.1 Architecture
TAXII defines a RESTful API with three service types:
- Discovery: Returns information about available API roots
- API Root: Contains collections and serves as the main interaction point
- Collection: A logical grouping of STIX objects accessible via GET/POST
STIX 2.1 Object Model
STIX objects are categorized as:
- SDOs (STIX Domain Objects): Indicator, Malware, Threat Actor, Campaign, Attack Pattern, Tool, Infrastructure, Vulnerability, Identity, Location, Note, Opinion, Report, Grouping
- SCOs (STIX Cyber Observables): IPv4-Addr, Domain-Name, URL, File, Email-Addr, Process, Network-Traffic, Artifact
- SROs (STIX Relationship Objects): Relationship, Sighting
- Meta Objects: Marking Definition (TLP), Language Content, Extension Definition
STIX Bundle
A Bundle is a collection of STIX objects transmitted together. Bundles have a unique ID and contain an array of objects. TAXII collections serve bundles in response to GET requests.
Workflow
Step 1: TAXII Server Discovery
from taxii2client.v21 import Server, Collection, as_pages
# Connect to MITRE ATT&CK TAXII server
server = Server("https://cti-taxii.mitre.org/taxii2/", user="", password="")
print(f"Title: {server.title}")
print(f"Description: {server.description}")
# List API roots
for api_root in server.api_roots:
print(f"\nAPI Root: {api_root.title}")
print(f" URL: {api_root.url}")
# List collections
for collection in api_root.collections:
print(f" Collection: {collection.title} (ID: {collection.id})")
print(f" Can Read: {collection.can_read}")
print(f" Can Write: {collection.can_write}")
Step 2: Fetch STIX Objects from Collection
from taxii2client.v21 import Collection, as_pages
import json
# Connect to Enterprise ATT&CK collection
ENTERPRISE_ATTACK_ID = "95ecc380-afe9-11e4-9b6c-751b66dd541e"
collection = Collection(
f"https://cti-taxii.mitre.org/stix/collections/{ENTERPRISE_ATTACK_ID}/",
user="",
password="",
)
print(f"Collection: {collection.title}")
# Fetch all objects (paginated)
all_objects = []
for envelope in as_pages(collection.get_objects, per_request=50):
objects = envelope.get("objects", [])
all_objects.extend(objects)
print(f" Fetched {len(objects)} objects (total: {len(all_objects)})")
print(f"\nTotal objects retrieved: {len(all_objects)}")
# Categorize by type
type_counts = {}
for obj in all_objects:
obj_type = obj.get("type", "unknown")
type_counts[obj_type] = type_counts.get(obj_type, 0) + 1
for obj_type, count in sorted(type_counts.items()):
print(f" {obj_type}: {count}")
Step 3: Parse STIX 2.1 Objects with stix2 Library
from stix2 import parse, Filter, MemoryStore
# Load objects into a MemoryStore for querying
store = MemoryStore(stix_data=all_objects)
# Query for all indicators
indicators = store.query([Filter("type", "=", "indicator")])
print(f"Indicators: {len(indicators)}")
for ind in indicators[:5]:
print(f" {ind.name}: {ind.pattern}")
# Query for malware
malware_list = store.query([Filter("type", "=", "malware")])
print(f"\nMalware families: {len(malware_list)}")
# Query for threat actors
actors = store.query([Filter("type", "=", "intrusion-set")])
print(f"Threat actors: {len(actors)}")
# Find relationships for a specific object
def get_related(store, source_id):
relationships = store.query([
Filter("type", "=", "relationship"),
Filter("source_ref", "=", source_id),
])
return relationships
# Example: Get all techniques used by APT28
apt28 = store.query([
Filter("type", "=", "intrusion-set"),
Filter("name", "=", "APT28"),
])
if apt28:
rels = get_related(store, apt28[0].id)
for rel in rels:
target = store.get(rel.target_ref)
if target:
print(f" {rel.relationship_type} -> {target.name} ({target.type})")
Step 4: Implement Custom TAXII Consumer
from taxii2client.v21 import Collection, as_pages
from stix2 import parse, Bundle
from datetime import datetime, timedelta
import json
class TAXIIConsumer:
"""Consume STIX/TAXII 2.1 feeds and extract IOCs."""
def __init__(self, collection_url, user="", password=""):
self.collection = Collection(collection_url, user=user, password=password)
self.last_poll = None
def poll_new_objects(self, added_after=None):
"""Poll for objects added after a specific timestamp."""
if added_after is None:
added_after = (
self.last_poll or
(datetime.utcnow() - timedelta(days=1)).strftime(
"%Y-%m-%dT%H:%M:%S.000Z"
)
)
all_objects = []
kwargs = {"added_after": added_after}
for envelope in as_pages(
self.collection.get_objects, per_request=100, **kwargs
):
objects = envelope.get("objects", [])
all_objects.extend(objects)
self.last_poll = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S.000Z")
return all_objects
def extract_indicators(self, objects):
"""Extract actionable indicators from STIX objects."""
indicators = []
for obj in objects:
if obj.get("type") == "indicator":
indicators.append({
"id": obj.get("id"),
"name": obj.get("name", ""),
"pattern": obj.get("pattern", ""),
"pattern_type": obj.get("pattern_type", ""),
"valid_from": obj.get("valid_from", ""),
"valid_until": obj.get("valid_until", ""),
"indicator_types": obj.get("indicator_types", []),
"confidence": obj.get("confidence", 0),
"labels": obj.get("labels", []),
})
return indicators
def extract_observables(self, objects):
"""Extract STIX Cyber Observables."""
observables = []
observable_types = {
"ipv4-addr", "ipv6-addr", "domain-name", "url",
"file", "email-addr", "network-traffic",
}
for obj in objects:
if obj.get("type") in observable_types:
observables.append({
"type": obj["type"],
"value": obj.get("value", ""),
"id": obj.get("id"),
})
return observables
# Usage
consumer = TAXIIConsumer(
f"https://cti-taxii.mitre.org/stix/collections/{ENTERPRISE_ATTACK_ID}/"
)
new_objects = consumer.poll_new_objects()
indicators = consumer.extract_indicators(new_objects)
print(f"New indicators: {len(indicators)}")
Step 5: Set Up Local TAXII Server with Medallion
# medallion configuration (medallion.conf)
TAXII_CONFIG = {
"backend": {
"module_class": "MemoryBackend",
},
"users": {
"admin": "admin_password",
"readonly": "readonly_password",
},
"taxii": {
"max_content_length": 10485760,
},
}
# Run medallion server:
# pip install medallion
# python -m medallion --config medallion.conf --port 5000
# Add objects to local TAXII server
import requests
def push_to_taxii(server_url, collection_id, stix_bundle, user, password):
"""Push STIX bundle to a TAXII 2.1 collection."""
url = f"{server_url}/collections/{collection_id}/objects/"
headers = {
"Content-Type": "application/stix+json;version=2.1",
"Accept": "application/taxii+json;version=2.1",
}
response = requests.post(
url,
json=stix_bundle,
headers=headers,
auth=(user, password),
timeout=30,
)
return response.json()
Validation Criteria
- TAXII server discovery returns valid API roots and collections
- STIX objects fetched and parsed correctly from TAXII collections
- Indicators extracted with valid STIX patterns
- Pagination handled correctly for large collections
- Consumer tracks polling state for incremental updates
- Local TAXII server accepts and serves STIX bundles
References
1---2name: implementing-stix-taxii-feed-integration-23description: Implements a STIX 2.1/TAXII 2.1 threat-intelligence feed consumer and4 producer in Python, covering TAXII server discovery, collection polling, parsing5 STIX bundles with the stix2 library, and standing up a local TAXII server with Medallion.6 Use when integrating a STIX/TAXII CTI feed into a SIEM or TIP, writing a TAXII client7 to poll for new indicators, or setting up TAXII collections for indicator exchange.8domain: cybersecurity9subdomain: threat-intelligence10tags:11- threat-intelligence12- cti13- ioc14- mitre-attack15- stix16- taxii17- feed-integration18- oasis19version: '1.0'20author: mahipal21license: Apache-2.022nist_csf:23- ID.RA-0124- ID.RA-0525- DE.CM-0126- DE.AE-0227mitre_attack:28- T159129- T159230- T159331- T158932metadata:33 source: https://skillmd.com/skills/26zl/implementing-stix-taxii-feed-integration-234---3536# Implementing STIX/TAXII Feed Integration3738## Overview3940STIX (Structured Threat Information eXpression) and TAXII (Trusted Automated eXchange of Intelligence Information) are OASIS open standards for representing and transporting cyber threat intelligence. This skill covers implementing a STIX/TAXII 2.1 feed consumer and producer using Python, configuring TAXII server discovery, collection management, polling for new intelligence, parsing STIX 2.1 objects, and integrating feeds into SIEM and TIP platforms.414243## When to Use4445- When deploying or configuring implementing stix taxii feed integration capabilities in your environment46- When establishing security controls aligned to compliance requirements47- When building or improving security architecture for this domain48- When conducting security assessments that require this implementation4950## Prerequisites5152- Python 3.9+ with `taxii2-client`, `stix2`, `cti-taxii-client` libraries53- Understanding of STIX 2.1 data model (SDOs, SCOs, SROs)54- Understanding of TAXII 2.1 protocol (discovery, API roots, collections)55- Network access to TAXII servers (MITRE ATT&CK TAXII, Anomali STAXX)56- Optional: medallion for running a local TAXII 2.1 server5758## Key Concepts5960### TAXII 2.1 Architecture6162TAXII defines a RESTful API with three service types:63- **Discovery**: Returns information about available API roots64- **API Root**: Contains collections and serves as the main interaction point65- **Collection**: A logical grouping of STIX objects accessible via GET/POST6667### STIX 2.1 Object Model6869STIX objects are categorized as:70- **SDOs (STIX Domain Objects)**: Indicator, Malware, Threat Actor, Campaign, Attack Pattern, Tool, Infrastructure, Vulnerability, Identity, Location, Note, Opinion, Report, Grouping71- **SCOs (STIX Cyber Observables)**: IPv4-Addr, Domain-Name, URL, File, Email-Addr, Process, Network-Traffic, Artifact72- **SROs (STIX Relationship Objects)**: Relationship, Sighting73- **Meta Objects**: Marking Definition (TLP), Language Content, Extension Definition7475### STIX Bundle7677A Bundle is a collection of STIX objects transmitted together. Bundles have a unique ID and contain an array of objects. TAXII collections serve bundles in response to GET requests.7879## Workflow8081### Step 1: TAXII Server Discovery8283```python84from taxii2client.v21 import Server, Collection, as_pages8586# Connect to MITRE ATT&CK TAXII server87server = Server("https://cti-taxii.mitre.org/taxii2/", user="", password="")8889print(f"Title: {server.title}")90print(f"Description: {server.description}")9192# List API roots93for api_root in server.api_roots:94 print(f"\nAPI Root: {api_root.title}")95 print(f" URL: {api_root.url}")9697 # List collections98 for collection in api_root.collections:99 print(f" Collection: {collection.title} (ID: {collection.id})")100 print(f" Can Read: {collection.can_read}")101 print(f" Can Write: {collection.can_write}")102```103104### Step 2: Fetch STIX Objects from Collection105106```python107from taxii2client.v21 import Collection, as_pages108import json109110# Connect to Enterprise ATT&CK collection111ENTERPRISE_ATTACK_ID = "95ecc380-afe9-11e4-9b6c-751b66dd541e"112collection = Collection(113 f"https://cti-taxii.mitre.org/stix/collections/{ENTERPRISE_ATTACK_ID}/",114 user="",115 password="",116)117118print(f"Collection: {collection.title}")119120# Fetch all objects (paginated)121all_objects = []122for envelope in as_pages(collection.get_objects, per_request=50):123 objects = envelope.get("objects", [])124 all_objects.extend(objects)125 print(f" Fetched {len(objects)} objects (total: {len(all_objects)})")126127print(f"\nTotal objects retrieved: {len(all_objects)}")128129# Categorize by type130type_counts = {}131for obj in all_objects:132 obj_type = obj.get("type", "unknown")133 type_counts[obj_type] = type_counts.get(obj_type, 0) + 1134135for obj_type, count in sorted(type_counts.items()):136 print(f" {obj_type}: {count}")137```138139### Step 3: Parse STIX 2.1 Objects with stix2 Library140141```python142from stix2 import parse, Filter, MemoryStore143144# Load objects into a MemoryStore for querying145store = MemoryStore(stix_data=all_objects)146147# Query for all indicators148indicators = store.query([Filter("type", "=", "indicator")])149print(f"Indicators: {len(indicators)}")150151for ind in indicators[:5]:152 print(f" {ind.name}: {ind.pattern}")153154# Query for malware155malware_list = store.query([Filter("type", "=", "malware")])156print(f"\nMalware families: {len(malware_list)}")157158# Query for threat actors159actors = store.query([Filter("type", "=", "intrusion-set")])160print(f"Threat actors: {len(actors)}")161162# Find relationships for a specific object163def get_related(store, source_id):164 relationships = store.query([165 Filter("type", "=", "relationship"),166 Filter("source_ref", "=", source_id),167 ])168 return relationships169170# Example: Get all techniques used by APT28171apt28 = store.query([172 Filter("type", "=", "intrusion-set"),173 Filter("name", "=", "APT28"),174])175if apt28:176 rels = get_related(store, apt28[0].id)177 for rel in rels:178 target = store.get(rel.target_ref)179 if target:180 print(f" {rel.relationship_type} -> {target.name} ({target.type})")181```182183### Step 4: Implement Custom TAXII Consumer184185```python186from taxii2client.v21 import Collection, as_pages187from stix2 import parse, Bundle188from datetime import datetime, timedelta189import json190191class TAXIIConsumer:192 """Consume STIX/TAXII 2.1 feeds and extract IOCs."""193194 def __init__(self, collection_url, user="", password=""):195 self.collection = Collection(collection_url, user=user, password=password)196 self.last_poll = None197198 def poll_new_objects(self, added_after=None):199 """Poll for objects added after a specific timestamp."""200 if added_after is None:201 added_after = (202 self.last_poll or203 (datetime.utcnow() - timedelta(days=1)).strftime(204 "%Y-%m-%dT%H:%M:%S.000Z"205 )206 )207208 all_objects = []209 kwargs = {"added_after": added_after}210211 for envelope in as_pages(212 self.collection.get_objects, per_request=100, **kwargs213 ):214 objects = envelope.get("objects", [])215 all_objects.extend(objects)216217 self.last_poll = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S.000Z")218 return all_objects219220 def extract_indicators(self, objects):221 """Extract actionable indicators from STIX objects."""222 indicators = []223 for obj in objects:224 if obj.get("type") == "indicator":225 indicators.append({226 "id": obj.get("id"),227 "name": obj.get("name", ""),228 "pattern": obj.get("pattern", ""),229 "pattern_type": obj.get("pattern_type", ""),230 "valid_from": obj.get("valid_from", ""),231 "valid_until": obj.get("valid_until", ""),232 "indicator_types": obj.get("indicator_types", []),233 "confidence": obj.get("confidence", 0),234 "labels": obj.get("labels", []),235 })236 return indicators237238 def extract_observables(self, objects):239 """Extract STIX Cyber Observables."""240 observables = []241 observable_types = {242 "ipv4-addr", "ipv6-addr", "domain-name", "url",243 "file", "email-addr", "network-traffic",244 }245 for obj in objects:246 if obj.get("type") in observable_types:247 observables.append({248 "type": obj["type"],249 "value": obj.get("value", ""),250 "id": obj.get("id"),251 })252 return observables253254255# Usage256consumer = TAXIIConsumer(257 f"https://cti-taxii.mitre.org/stix/collections/{ENTERPRISE_ATTACK_ID}/"258)259new_objects = consumer.poll_new_objects()260indicators = consumer.extract_indicators(new_objects)261print(f"New indicators: {len(indicators)}")262```263264### Step 5: Set Up Local TAXII Server with Medallion265266```python267# medallion configuration (medallion.conf)268TAXII_CONFIG = {269 "backend": {270 "module_class": "MemoryBackend",271 },272 "users": {273 "admin": "admin_password",274 "readonly": "readonly_password",275 },276 "taxii": {277 "max_content_length": 10485760,278 },279}280281# Run medallion server:282# pip install medallion283# python -m medallion --config medallion.conf --port 5000284285# Add objects to local TAXII server286import requests287288def push_to_taxii(server_url, collection_id, stix_bundle, user, password):289 """Push STIX bundle to a TAXII 2.1 collection."""290 url = f"{server_url}/collections/{collection_id}/objects/"291 headers = {292 "Content-Type": "application/stix+json;version=2.1",293 "Accept": "application/taxii+json;version=2.1",294 }295 response = requests.post(296 url,297 json=stix_bundle,298 headers=headers,299 auth=(user, password),300 timeout=30,301 )302 return response.json()303```304305## Validation Criteria306307- TAXII server discovery returns valid API roots and collections308- STIX objects fetched and parsed correctly from TAXII collections309- Indicators extracted with valid STIX patterns310- Pagination handled correctly for large collections311- Consumer tracks polling state for incremental updates312- Local TAXII server accepts and serves STIX bundles313314## References315316- [STIX 2.1 Specification](https://docs.oasis-open.org/cti/stix/v2.1/stix-v2.1.html)317- [TAXII 2.1 Specification](https://docs.oasis-open.org/cti/taxii/v2.1/taxii-v2.1.html)318- [taxii2-client PyPI](https://pypi.org/project/taxii2-client/)319- [stix2 Python Library](https://stix2.readthedocs.io/)320- [MITRE ATT&CK TAXII Server](https://cti-taxii.mitre.org/taxii2/)321- [Medallion TAXII Server](https://github.com/oasis-open/cti-taxii-server)