Attack Trees
AegisShield generates comprehensive attack trees that visualize hierarchical relationships between threats, sub-threats, and attack vectors using Mermaid diagram syntax.Overview
The attack tree module (attack_tree.py) creates structured visual representations of how an attacker might compromise your system, organizing threats into a tree structure based on the STRIDE methodology.
Mermaid Syntax
Industry-standard graph visualization
STRIDE Structure
Organized by 6 threat categories
Multi-Level
Threats → Sub-threats → Attack vectors
Attack Tree Structure
Attack trees are organized hierarchically:The root node represents compromise of Confidentiality, Integrity, and Availability (CIA triad).
Core Functions
get_attack_tree()
Generates an attack tree using OpenAI’s API.OpenAI API key
OpenAI model to use
Formatted attack tree prompt
str - Mermaid diagram code (cleaned of markdown fences)
attack_tree.py:65-213
create_attack_tree_prompt()
Creates a comprehensive prompt with application details and threat intelligence.Application type
Authentication methods
Internet exposure
Data sensitivity level
MITRE ATT&CK mappings
NVD CVE data
AlienVault OTX data
Application description
Prompt creation from attack_tree.py:17-61
Mermaid Syntax Rules
AegisShield generates Mermaid diagrams following specific syntax rules:Node Types
Node Types
- Square brackets
[]: Standard nodes - Round parentheses
(): Rounded nodes - Double quotes
": Required for labels with special characters
Special Characters
Special Characters
Critical Rule: Round brackets
() are special characters in Mermaid. Always wrap labels containing parentheses in double quotes.Subgraphs
Subgraphs
Group related threats for better readability:
Arrows
Arrows
-->: Standard arrow-.->: Dotted arrow==>: Thick arrow
System Prompt
The AI uses a detailed system prompt (fromattack_tree.py:99-193):
Key instructions
Output Processing
The module automatically cleans the output:Regex cleaning from attack_tree.py:205-207
- Opening
```mermaidfence - Closing
```fence - Leading/trailing whitespace
Example Output
A typical attack tree for a web application:Integration with Threat Intelligence
Attack trees incorporate:- STRIDE threats: From threat model
- MITRE ATT&CK techniques: Referenced by ID (e.g., T1190)
- NVD CVEs: Referenced by ID (e.g., CVE-2024-1234)
- AlienVault OTX: Industry-specific threats
Rendering Options
- Streamlit
- Markdown
Use Cases
Security Reviews
Visual representation helps security teams quickly understand attack paths and prioritize defenses.
Developer Training
Teach developers about potential attack vectors and secure coding practices.
Executive Presentations
Non-technical stakeholders can grasp security threats through visual diagrams.
Compliance Documentation
Include attack trees in security documentation for audits and assessments.
Complete Workflow
End-to-end attack tree generation
Best Practices
Detailed Descriptions
Detailed Descriptions
Provide comprehensive application descriptions. More detail leads to more accurate and specific attack trees.
Include Threat Intelligence
Include Threat Intelligence
Always include MITRE, NVD, and OTX data in the prompt. Real-world intelligence produces realistic attack paths.
Review and Refine
Review and Refine
Generated attack trees may need manual refinement for your specific environment. Use them as a starting point.
Update Regularly
Update Regularly
Regenerate attack trees when:
- Architecture changes
- New vulnerabilities are disclosed
- Threat landscape evolves
- New features are added
Related Features
- Threat Modeling - Generate STRIDE threats
- MITRE ATT&CK - Map to attack techniques
- Risk Assessment - DREAD scoring
- PDF Reports - Export attack trees to PDF