CVE-to-TTP Mapper Module
This module implements CVE-to-TTP (Tactics, Techniques, and Procedures) mapping and inference using two complementary approaches:
- CWE-based Mapping: Uses the existing CWE→CAPEC→TTP mappings generated by the data collection pipeline
- TIE Inference: Uses the Technique Inference Engine to infer TTPs from CVE descriptions
Prerequisites
Run the data collection pipeline first to generate CWE-CAPEC-MITRE mappings:
python -m src.collectors.main_collector --download python -m src.collectors.main_collector --convertInstall NumPy (optional, for TIE inference):
pip install numpyDownload MITRE ATT&CK data (required for TIE inference):
# Run the setup script to download missing data python src/mapper/setup_mapper.py # Or download manually: wget https://raw.githubusercontent.com/mitre-attack/attack-stix-data/master/enterprise-attack/enterprise-attack.json -O src/mapper/tie_models/enterprise-attack.json
Usage
1. As a Python Module
from src.mapper.cve_ttp_mapper import CVEtoTTPMapper
from src.mapper.mapper_config import MapperConfig
# Initialize mapper
config = MapperConfig()
mapper = CVEtoTTPMapper(config)
# Map a single CVE
cve_data = {
"id": "CVE-2021-44228",
"description": "Apache Log4j2 JNDI injection vulnerability...",
"cwe_ids": ["CWE-502", "CWE-20"]
}
result = mapper.map_cve_to_ttps(cve_data)
print(f"Found TTPs: {result['ttps']}")
2. Command-Line Interface
# Map a single CVE
python -m src.mapper.mapper_cli single CVE-2021-44228 \
--description "Remote code execution vulnerability" \
--cwe CWE-502 --cwe CWE-20
# Process a CVE file
python -m src.mapper.mapper_cli file path/to/cve_data.json \
--output path/to/mappings.json
# Batch process multiple files
python -m src.mapper.mapper_cli batch path/to/cve_directory \
--pattern "*.json" \
--output path/to/output_dir
3. Test the Module
# Run the test suite
python src/mapper/test_simple_mapper.py
4. Batch Processing
# Process CVE data and generate mappings
python src/mapper/run_cve_ttp_mapping.py
How It Works
CWE-based Mapping (Direct)
- Extracts CWE IDs from CVE data
- Uses pre-computed CWE→CAPEC→TTP mappings
- Returns all TTPs associated with the CVE's weaknesses
TIE Inference (ML-based)
- Extracts keywords from CVE description that indicate techniques
- Uses pre-trained TIE model to infer related techniques
- Returns predicted TTPs with confidence scores
Combined Approach
The mapper combines both methods:
- First applies CWE-based mapping for direct associations
- Then uses TIE to infer additional TTPs from the description
- Deduplicates and returns comprehensive results
Output Format
{
"cve_id": "CVE-2021-44228",
"ttps": ["T1190", "T1059", "T1203"],
"methods_used": ["CWE-to-CAPEC-to-TTP", "TIE-inference"],
"total_ttps_found": 3,
"details": {
"cwe_mapping": {
"method": "CWE-to-CAPEC-to-TTP",
"mappings": [
{
"cwe": "CWE-502",
"capecs": ["CAPEC-586"],
"ttps": ["T1203"]
}
]
},
"tie_inference": {
"method": "tie_inference",
"keyword_ttps": ["T1190"],
"inferred_ttps": ["T1059"],
"confidence_scores": {
"T1059": 0.85
}
}
},
"mapping_timestamp": "2024-01-01T12:00:00"
}
Configuration
Edit mapper_config.py to customize:
- TIE confidence threshold
- Maximum predictions per CVE
- Input/output paths