Skip to content

islamoc/dfd-threat-model-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

27 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ” DFD Threat Model Generator

AI-powered threat model generation from Data Flow Diagrams using OWASP Threat Model Library

A comprehensive tool that automatically analyzes Data Flow Diagrams (DFDs) and generates detailed threat models using OWASP threat patterns and STRIDE methodology.

License: MIT GitHub Repo

✨ Features

  • Interactive DFD Builder: Visual interface to define your system architecture
  • Automated Threat Detection: Uses OWASP threat patterns to identify vulnerabilities
  • STRIDE Analysis: Comprehensive security threat categorization
  • Multiple Export Formats: JSON and CSV exports for integration with other tools
  • Detailed Reports: Executive summaries and mitigation recommendations
  • Real-time Validation: DFD validation with security warnings
  • Severity Classification: Threats categorized by risk levels (Critical, High, Medium, Low)

πŸš€ Quick Start

Prerequisites

  • Node.js 16+
  • npm or yarn

Installation

# Clone the repository
git clone https://github.com/islamoc/dfd-threat-model-generator.git
cd dfd-threat-model-generator

# Install dependencies
npm install

# Start the server
npm start

The application will be available at http://localhost:3000

πŸ“– Usage

1. Define Your DFD

  • Enter your project name and description
  • Add system elements (Actors, Processes, Data Stores, External Entities)
  • Define data flows between elements
  • Mark flows carrying sensitive data
  • Specify communication protocols

2. Generate Threat Model

  • Click "Generate Threat Model" button
  • The system analyzes your DFD against OWASP threat patterns
  • Threats are automatically identified and categorized

3. Review Results

  • All Threats Tab: Complete list of identified threats
  • By Severity Tab: Threats grouped by risk level
  • By STRIDE Tab: Threats categorized by STRIDE classification
  • Report Tab: Executive summary with recommendations

4. Export & Share

  • Export threat model as JSON for tool integration
  • Export as CSV for spreadsheet analysis
  • Print detailed reports

πŸ—οΈ Architecture

Backend (Node.js/Express)

server.js              # Express API server
src/
  β”œβ”€β”€ threatGenerator.js    # Threat identification and analysis
  β”œβ”€β”€ threatLibrary.js      # OWASP threat patterns database
  └── dfdValidator.js       # DFD validation logic

Frontend (Vanilla JavaScript)

public/
  β”œβ”€β”€ index.html      # UI interface
  └── app.js          # Frontend logic

πŸ“Š Threat Model Data Structure

DFD Object

{
  "id": "dfd_123",
  "name": "E-Commerce Platform",
  "description": "Online shopping system",
  "elements": [
    {
      "id": "elem_1",
      "name": "Web Server",
      "type": "process",
      "trustLevel": "trusted"
    }
  ],
  "dataflows": [
    {
      "id": "df_1",
      "name": "User Login",
      "from": "elem_user",
      "to": "elem_server",
      "protocol": "HTTPS",
      "hasSensitiveData": true,
      "isEncrypted": true
    }
  ]
}

🎯 STRIDE Categories

Threat Model uses STRIDE for threat categorization:

  • Spoofing: Identity spoofing attacks
  • Tampering: Data modification attacks
  • Repudiation: Denial of actions
  • Information Disclosure: Data exposure
  • Denial of Service: System unavailability
  • Elevation of Privilege: Unauthorized access escalation

πŸ“š OWASP Integration

The tool uses threat patterns from:

πŸ”Œ API Endpoints

Health Check

GET /api/health

Threat Library

GET /api/threats/library           # Get library metadata
GET /api/threats/patterns/:type    # Get patterns by element type

DFD Operations

POST /api/dfd/validate             # Validate DFD structure

Threat Generation

POST /api/threats/generate         # Generate threat model from DFD
POST /api/reports/threat-analysis  # Generate detailed report
POST /api/export/json              # Export threat model

πŸ›‘οΈ Security Features

  • Input Validation: All DFD inputs validated against schema
  • CORS Protection: Cross-Origin Resource Sharing configured
  • Threat Mitigation: Recommended mitigations for each threat
  • Trust Boundaries: Support for defining security boundaries
  • Encryption Detection: Identifies unencrypted data flows

πŸ’‘ Example Threat Detection

The system identifies threats such as:

  • Man-in-the-Middle Attacks: On unencrypted HTTP flows
  • SQL Injection: In database interactions
  • Privilege Escalation: In process-based components
  • Data Exposure: On sensitive unencrypted dataflows
  • Broken Authentication: In actor interactions
  • Business Logic Bypass: In process components

πŸ“‹ Supported Element Types

  • Actor/User: External users or actors
  • Process: Business logic components
  • Data Store: Databases or file systems
  • External Entity: Third-party systems

πŸ§ͺ Testing

# Run tests (when implemented)
npm test

πŸ“¦ Dependencies

  • express: Web framework
  • cors: Cross-origin resource sharing
  • uuid: Unique ID generation
  • jsonschema: Schema validation

🀝 Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ› Bug Reports

Found a bug? Please open an issue with:

  • Description of the problem
  • Steps to reproduce
  • Expected vs actual behavior
  • System information

πŸ“„ License

MIT License - see LICENSE file for details

πŸ‘¨β€πŸ’Ό Author

Mennouchi Islam Azeddine

πŸ™ Acknowledgments

πŸ“ž Support

  • Issues: GitHub Issues
  • Discussions: GitHub Discussions
  • Documentation: See /docs folder

πŸ—ΊοΈ Roadmap

  • Integration with Threat Dragon
  • AI-powered threat suggestions
  • Custom threat library management
  • Real-time collaboration
  • Risk scoring engine
  • Compliance mapping (GDPR, HIPAA, etc.)
  • Docker containerization
  • GraphQL API

πŸ“Š Statistics

  • Threat Patterns: 20+ OWASP patterns
  • Element Types: 6 supported types
  • Export Formats: JSON, CSV, PDF (planned)
  • Risk Levels: 4 severity classifications

Made with ❀️ for the security community

About

AI-powered DFD to threat model generator using OWASP Threat Model Library dataset with interactive UI

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors