# CVE-to-TTP Mapper Module This module implements CVE-to-TTP (Tactics, Techniques, and Procedures) mapping and inference using two complementary approaches: 1. **CWE-based Mapping**: Uses the existing CWE→CAPEC→TTP mappings generated by the data collection pipeline 2. **TIE Inference**: Uses the [Technique Inference Engine](https://github.com/center-for-threat-informed-defense/technique-inference-engine) to infer TTPs from CVE descriptions ## Prerequisites 1. **Run the data collection pipeline first** to generate CWE-CAPEC-MITRE mappings: ```bash python -m src.collectors.main_collector --download python -m src.collectors.main_collector --convert ``` 2. **Install NumPy** (optional, for TIE inference): ```bash pip install numpy ``` 3. **Download MITRE ATT&CK data** (required for TIE inference): ```bash # 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 ```python 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 ```bash # 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 ```bash # Run the test suite python src/mapper/test_simple_mapper.py ``` ### 4. Batch Processing ```bash # Process CVE data and generate mappings python src/mapper/run_cve_ttp_mapping.py ``` ## How It Works ### CWE-based Mapping (Direct) 1. Extracts CWE IDs from CVE data 2. Uses pre-computed CWE→CAPEC→TTP mappings 3. Returns all TTPs associated with the CVE's weaknesses ### TIE Inference (ML-based) 1. Extracts keywords from CVE description that indicate techniques 2. Uses pre-trained TIE model to infer related techniques 3. 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 ```json { "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