Overview
The MITRE ATT&CK API provides functions to fetch MITRE ATT&CK framework data, process threat models to map threats to relevant techniques, and select the most relevant attack patterns for specific application contexts.Configuration Constants
Application Type Categories
Functions
fetch_mitre_attack_data()
Fetch MITRE ATT&CK framework data based on application type. Automatically loads the appropriate dataset(s) for mobile, enterprise, or ICS applications.Type of application. Must be one of the values from MOBILE_APP_TYPES, ENTERPRISE_APP_TYPES, or ICS_APP_TYPES constants.
The loaded STIX data containing MITRE ATT&CK objects, or None if there was an error.Structure:
type: STIX bundle typeid: Bundle identifierobjects: Array of STIX objects including attack-patterns, tactics, mitigations, etc.
- Mobile apps: Loads both
mobile-attack.jsonandenterprise-attack.json - Enterprise apps: Loads
enterprise-attack.json - ICS apps: Loads both
ics-attack.jsonandenterprise-attack.json - Unknown types: Defaults to
enterprise-attack.json
FileNotFoundError: Raised when required MITRE ATT&CK data files are not foundjson.JSONDecodeError: Raised when JSON files have invalid format- Handled by
error_handler.handle_exception()for all exceptions
process_mitre_attack_data()
Process MITRE ATT&CK data to map threats from a threat model to the most relevant attack techniques using AI-powered selection.The STIX data containing MITRE ATT&CK attack patterns, obtained from
fetch_mitre_attack_data()List of threats from the threat model. Each threat must contain:
MITRE ATT&CK Keywords: List of keywords for matching attack patternsThreat Type: String (e.g., “Spoofing”, “Tampering”)Scenario: String describing the threat
Application context for technique selection. Should contain:
app_type: Application typeindustry_sector: Industry sectorauthentication: Authentication methodsinternet_facing: Whether internet-facingsensitive_data: Types of sensitive dataapp_input: Application description
OpenAI API key for AI-powered technique selection
List of processed threat-to-technique mappings. Each entry contains:
threat: The original threat objectmitre_techniques: Array with the most relevant technique containing:name: Technique namedescription: Technique descriptionid: STIX attack pattern IDtechnique_id: MITRE ATT&CK technique ID (e.g., “T1078”)
ValueError: Raised for invalid STIX data structure or missing application details- Returns empty techniques array for individual threat processing errors
- All exceptions handled by
error_handler.handle_exception()
map_attack_pattern_to_technique()
Map STIX attack pattern IDs to MITRE ATT&CK technique IDs (e.g., “T1078”).The STIX data containing attack patterns and their external references
Dictionary mapping attack pattern IDs to MITRE ATT&CK technique IDs.Format:
{"attack-pattern--uuid": "T1234"}- Iterates through all STIX objects
- Filters for
attack-patterntype objects - Searches external references for
mitre-attacksource - Extracts the
external_idfield (technique ID) - Creates a mapping dictionary
- Returns empty dictionary if STIX data is invalid
- Handled by
error_handler.handle_exception()for processing errors
get_relevant_techniques()
Use OpenAI to select the most relevant MITRE ATT&CK technique from a list of candidates.Formatted prompt created by
create_mitre_prompt() containing threat details and candidate techniquesOpenAI API key for authentication
List containing a single attack pattern ID (the most relevant one), or a fallback ID if no match found.Format:
["attack-pattern--xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"]- Cleans markdown code blocks from response
- Parses JSON array
- Returns exactly one technique ID
- Returns fallback ID
["attack-pattern--00000000-0000-0000-0000-000000000000"]if no match
gpt-4o (hardcoded in the function)
Helper Functions
create_mitre_prompt()
Create a detailed prompt for AI-powered technique selection.Application context details including app_type, industry_sector, authentication, etc.
Single threat object from threat model
Top 25 candidate techniques identified by keyword matching
Formatted prompt for sending to OpenAI API
Data Files Location
The module expects MITRE ATT&CK data files in the following location:Error Handling
All functions use centralized error handling viaerror_handler.handle_exception() for consistent logging and error reporting.