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
3description: STIX (Structured Threat Information eXpression) and TAXII (Trusted Automated
4 eXchange of Intelligence Information) are OASIS open standards for representing
5 and transporting cyber threat intelligence.
6domain: cybersecurity
7subdomain: threat-intelligence
8tags:
9- threat-intelligence
10- cti
11- ioc
12- mitre-attack
13- stix
14- taxii
15- feed-integration
16- oasis
17version: '1.0'
18author: mahipal
19license: Apache-2.0
20nist_csf:
21- ID.RA-01
22- ID.RA-05
23- DE.CM-01
24- DE.AE-02
25mitre_attack:
26- T1591
27- T1592
28- T1593
29- T1589
30source: https://github.com/mukul975/Anthropic-Cybersecurity-Skills
31source_commit: 04450304b12645cb2b974ab96d28c0664758a88d
32note: "Vendored verbatim from an external Apache-2.0 security-skill library, pinned by commit. Exceeds the internal 300-line skill guideline (agent-code-constraints.md) -- kept as-is because this is vendored reference material (forensics/threat-intel procedure), not Yana AI-authored content, and trimming would damage technical accuracy."
33metadata:
34 source: https://skillmd.com/skills/yanacuti1121/implementing-stix-taxii-feed-integration
35---
36
37# Implementing STIX/TAXII Feed Integration
38
39## Overview
40
41STIX (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.
42
43
44## When to Use
45
46- When deploying or configuring implementing stix taxii feed integration capabilities in your environment
47- When establishing security controls aligned to compliance requirements
48- When building or improving security architecture for this domain
49- When conducting security assessments that require this implementation
50
51## Prerequisites
52
53- Python 3.9+ with `taxii2-client`, `stix2`, `cti-taxii-client` libraries
54- Understanding of STIX 2.1 data model (SDOs, SCOs, SROs)
55- Understanding of TAXII 2.1 protocol (discovery, API roots, collections)
56- Network access to TAXII servers (MITRE ATT&CK TAXII, Anomali STAXX)
57- Optional: medallion for running a local TAXII 2.1 server
58
59## Key Concepts
60
61### TAXII 2.1 Architecture
62
63TAXII defines a RESTful API with three service types:
64- **Discovery**: Returns information about available API roots
65- **API Root**: Contains collections and serves as the main interaction point
66- **Collection**: A logical grouping of STIX objects accessible via GET/POST
67
68### STIX 2.1 Object Model
69
70STIX objects are categorized as:
71- **SDOs (STIX Domain Objects)**: Indicator, Malware, Threat Actor, Campaign, Attack Pattern, Tool, Infrastructure, Vulnerability, Identity, Location, Note, Opinion, Report, Grouping
72- **SCOs (STIX Cyber Observables)**: IPv4-Addr, Domain-Name, URL, File, Email-Addr, Process, Network-Traffic, Artifact
73- **SROs (STIX Relationship Objects)**: Relationship, Sighting
74- **Meta Objects**: Marking Definition (TLP), Language Content, Extension Definition
75
76### STIX Bundle
77
78A 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.
79
80## Workflow
81
82### Step 1: TAXII Server Discovery
83
84```python
85from taxii2client.v21 import Server, Collection, as_pages
86
87# Connect to MITRE ATT&CK TAXII server
88server = Server("https://cti-taxii.mitre.org/taxii2/", user="", password="")
89
90print(f"Title: {server.title}")
91print(f"Description: {server.description}")
92
93# List API roots
94for api_root in server.api_roots:
95 print(f"\nAPI Root: {api_root.title}")
96 print(f" URL: {api_root.url}")
97
98 # List collections
99 for collection in api_root.collections:
100 print(f" Collection: {collection.title} (ID: {collection.id})")
101 print(f" Can Read: {collection.can_read}")
102 print(f" Can Write: {collection.can_write}")
103```
104
105### Step 2: Fetch STIX Objects from Collection
106
107```python
108from taxii2client.v21 import Collection, as_pages
109import json
110
111# Connect to Enterprise ATT&CK collection
112ENTERPRISE_ATTACK_ID = "95ecc380-afe9-11e4-9b6c-751b66dd541e"
113collection = Collection(
114 f"https://cti-taxii.mitre.org/stix/collections/{ENTERPRISE_ATTACK_ID}/",
115 user="",
116 password="",
117)
118
119print(f"Collection: {collection.title}")
120
121# Fetch all objects (paginated)
122all_objects = []
123for envelope in as_pages(collection.get_objects, per_request=50):
124 objects = envelope.get("objects", [])
125 all_objects.extend(objects)
126 print(f" Fetched {len(objects)} objects (total: {len(all_objects)})")
127
128print(f"\nTotal objects retrieved: {len(all_objects)}")
129
130# Categorize by type
131type_counts = {}
132for obj in all_objects:
133 obj_type = obj.get("type", "unknown")
134 type_counts[obj_type] = type_counts.get(obj_type, 0) + 1
135
136for obj_type, count in sorted(type_counts.items()):
137 print(f" {obj_type}: {count}")
138```
139
140### Step 3: Parse STIX 2.1 Objects with stix2 Library
141
142```python
143from stix2 import parse, Filter, MemoryStore
144
145# Load objects into a MemoryStore for querying
146store = MemoryStore(stix_data=all_objects)
147
148# Query for all indicators
149indicators = store.query([Filter("type", "=", "indicator")])
150print(f"Indicators: {len(indicators)}")
151
152for ind in indicators[:5]:
153 print(f" {ind.name}: {ind.pattern}")
154
155# Query for malware
156malware_list = store.query([Filter("type", "=", "malware")])
157print(f"\nMalware families: {len(malware_list)}")
158
159# Query for threat actors
160actors = store.query([Filter("type", "=", "intrusion-set")])
161print(f"Threat actors: {len(actors)}")
162
163# Find relationships for a specific object
164def get_related(store, source_id):
165 relationships = store.query([
166 Filter("type", "=", "relationship"),
167 Filter("source_ref", "=", source_id),
168 ])
169 return relationships
170
171# Example: Get all techniques used by APT28
172apt28 = store.query([
173 Filter("type", "=", "intrusion-set"),
174 Filter("name", "=", "APT28"),
175])
176if apt28:
177 rels = get_related(store, apt28[0].id)
178 for rel in rels:
179 target = store.get(rel.target_ref)
180 if target:
181 print(f" {rel.relationship_type} -> {target.name} ({target.type})")
182```
183
184### Step 4: Implement Custom TAXII Consumer
185
186```python
187from taxii2client.v21 import Collection, as_pages
188from stix2 import parse, Bundle
189from datetime import datetime, timedelta
190import json
191
192class TAXIIConsumer:
193 """Consume STIX/TAXII 2.1 feeds and extract IOCs."""
194
195 def __init__(self, collection_url, user="", password=""):
196 self.collection = Collection(collection_url, user=user, password=password)
197 self.last_poll = None
198
199 def poll_new_objects(self, added_after=None):
200 """Poll for objects added after a specific timestamp."""
201 if added_after is None:
202 added_after = (
203 self.last_poll or
204 (datetime.utcnow() - timedelta(days=1)).strftime(
205 "%Y-%m-%dT%H:%M:%S.000Z"
206 )
207 )
208
209 all_objects = []
210 kwargs = {"added_after": added_after}
211
212 for envelope in as_pages(
213 self.collection.get_objects, per_request=100, **kwargs
214 ):
215 objects = envelope.get("objects", [])
216 all_objects.extend(objects)
217
218 self.last_poll = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S.000Z")
219 return all_objects
220
221 def extract_indicators(self, objects):
222 """Extract actionable indicators from STIX objects."""
223 indicators = []
224 for obj in objects:
225 if obj.get("type") == "indicator":
226 indicators.append({
227 "id": obj.get("id"),
228 "name": obj.get("name", ""),
229 "pattern": obj.get("pattern", ""),
230 "pattern_type": obj.get("pattern_type", ""),
231 "valid_from": obj.get("valid_from", ""),
232 "valid_until": obj.get("valid_until", ""),
233 "indicator_types": obj.get("indicator_types", []),
234 "confidence": obj.get("confidence", 0),
235 "labels": obj.get("labels", []),
236 })
237 return indicators
238
239 def extract_observables(self, objects):
240 """Extract STIX Cyber Observables."""
241 observables = []
242 observable_types = {
243 "ipv4-addr", "ipv6-addr", "domain-name", "url",
244 "file", "email-addr", "network-traffic",
245 }
246 for obj in objects:
247 if obj.get("type") in observable_types:
248 observables.append({
249 "type": obj["type"],
250 "value": obj.get("value", ""),
251 "id": obj.get("id"),
252 })
253 return observables
254
255
256# Usage
257consumer = TAXIIConsumer(
258 f"https://cti-taxii.mitre.org/stix/collections/{ENTERPRISE_ATTACK_ID}/"
259)
260new_objects = consumer.poll_new_objects()
261indicators = consumer.extract_indicators(new_objects)
262print(f"New indicators: {len(indicators)}")
263```
264
265### Step 5: Set Up Local TAXII Server with Medallion
266
267```python
268# medallion configuration (medallion.conf)
269TAXII_CONFIG = {
270 "backend": {
271 "module_class": "MemoryBackend",
272 },
273 "users": {
274 "admin": "admin_password",
275 "readonly": "readonly_password",
276 },
277 "taxii": {
278 "max_content_length": 10485760,
279 },
280}
281
282# Run medallion server:
283# pip install medallion
284# python -m medallion --config medallion.conf --port 5000
285
286# Add objects to local TAXII server
287import requests
288
289def push_to_taxii(server_url, collection_id, stix_bundle, user, password):
290 """Push STIX bundle to a TAXII 2.1 collection."""
291 url = f"{server_url}/collections/{collection_id}/objects/"
292 headers = {
293 "Content-Type": "application/stix+json;version=2.1",
294 "Accept": "application/taxii+json;version=2.1",
295 }
296 response = requests.post(
297 url,
298 json=stix_bundle,
299 headers=headers,
300 auth=(user, password),
301 timeout=30,
302 )
303 return response.json()
304```
305
306## Validation Criteria
307
308- TAXII server discovery returns valid API roots and collections
309- STIX objects fetched and parsed correctly from TAXII collections
310- Indicators extracted with valid STIX patterns
311- Pagination handled correctly for large collections
312- Consumer tracks polling state for incremental updates
313- Local TAXII server accepts and serves STIX bundles
314
315## References
316
317- [STIX 2.1 Specification](https://docs.oasis-open.org/cti/stix/v2.1/stix-v2.1.html)
318- [TAXII 2.1 Specification](https://docs.oasis-open.org/cti/taxii/v2.1/taxii-v2.1.html)
319- [taxii2-client PyPI](https://pypi.org/project/taxii2-client/)
320- [stix2 Python Library](https://stix2.readthedocs.io/)
321- [MITRE ATT&CK TAXII Server](https://cti-taxii.mitre.org/taxii2/)
322- [Medallion TAXII Server](https://github.com/oasis-open/cti-taxii-server)