# DefectDojo Security Management

> Application security vulnerability management and orchestration platform.

- Category: Security & Networking
- Difficulty: advanced
- Components: defectdojo, nginx, postgresql, rabbitmq, celery
- Tags: defectdojo, security, vulnerability, devsecops, scanning
- Source: https://docker.recipes/security/defectdojo-security

## Overview

DefectDojo is an enterprise-grade application security vulnerability management and orchestration platform that consolidates security testing tools and findings into a centralized dashboard. Originally developed by Rackspace and now maintained by the OWASP Foundation, DefectDojo ingests results from over 100 security scanners including SAST, DAST, SCA, and infrastructure tools, providing unified vulnerability tracking, risk assessment, and remediation workflows for development and security teams.

This stack combines DefectDojo's Django-based web application with a robust backend infrastructure designed for production workloads. PostgreSQL serves as the primary database for storing vulnerability findings, product metadata, and user configurations, while RabbitMQ handles message queuing for asynchronous tasks like scan imports and report generation. Celery workers process background jobs including parser execution, metric calculations, and notification delivery, with a separate beat scheduler managing recurring tasks like SLA monitoring and engagement status updates. NGINX provides reverse proxy capabilities with SSL termination and static file serving optimized for DefectDojo's web interface.

Security teams at organizations implementing DevSecOps practices will find this configuration particularly valuable for centralizing vulnerability management across multiple tools and teams. The architecture supports high-volume scan ingestion common in CI/CD pipelines while maintaining data integrity through PostgreSQL's ACID compliance and reliable task processing via RabbitMQ's persistent queues, making it suitable for enterprises requiring comprehensive security posture tracking and compliance reporting.

## Features

- Multi-scanner integration supporting 100+ security tools including Bandit, SonarQube, OWASP ZAP, Nessus, and Burp Suite
- PostgreSQL-backed vulnerability deduplication using configurable hash algorithms across finding title, file path, and line number
- RabbitMQ-powered asynchronous scan processing enabling high-volume import queues without blocking the web interface
- Celery-distributed task execution for parser workflows, JIRA synchronization, and scheduled engagement reporting
- NGINX reverse proxy with custom DefectDojo optimizations for handling large scan file uploads and static asset delivery
- Built-in SLA tracking with Celery beat scheduler monitoring remediation timelines and generating compliance reports
- RESTful API with Django REST framework enabling CI/CD integration and custom automation workflows
- Role-based access control with product-level permissions supporting multi-tenant security program management

## Use cases

- Enterprise security teams consolidating SAST, DAST, and SCA findings from multiple CI/CD pipelines into unified dashboards
- DevSecOps organizations requiring automated vulnerability tracking with JIRA integration and developer notification workflows
- Compliance-driven environments needing centralized security metrics for SOC2, PCI-DSS, or regulatory audit reporting
- Security consulting firms managing vulnerability assessments across multiple client engagements with isolated product spaces
- Development teams implementing shift-left security practices with automated scan imports from Jenkins, GitLab CI, or GitHub Actions
- Penetration testing teams requiring structured finding management with custom severity ratings and remediation tracking
- Organizations migrating from spreadsheet-based vulnerability management to automated tracking with historical trending

## Prerequisites

- Minimum 4GB RAM allocation with 2GB specifically for PostgreSQL data processing and DefectDojo application server
- Docker host with at least 20GB available storage for PostgreSQL data, RabbitMQ queues, and DefectDojo media uploads
- Network access to ports 8080 (HTTP) and 8443 (HTTPS) for DefectDojo web interface and API endpoints
- Understanding of security scanner output formats (JSON, XML, CSV) for proper parser configuration and finding import
- Basic knowledge of DefectDojo product hierarchy concepts including Organizations, Products, and Engagements for initial setup

## docker-compose.yml

```yaml
services:
  postgres:
    image: postgres:15-alpine
    environment:
      - POSTGRES_USER=defectdojo
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - POSTGRES_DB=defectdojo
    volumes:
      - postgres_data:/var/lib/postgresql/data
    networks:
      - dojo_net

  rabbitmq:
    image: rabbitmq:3-management-alpine
    environment:
      - RABBITMQ_DEFAULT_USER=defectdojo
      - RABBITMQ_DEFAULT_PASS=${RABBITMQ_PASSWORD}
    volumes:
      - rabbitmq_data:/var/lib/rabbitmq
    networks:
      - dojo_net

  defectdojo:
    image: defectdojo/defectdojo-django:latest
    environment:
      - DD_DATABASE_URL=postgresql://defectdojo:${POSTGRES_PASSWORD}@postgres:5432/defectdojo
      - DD_CELERY_BROKER_URL=amqp://defectdojo:${RABBITMQ_PASSWORD}@rabbitmq:5672//
      - DD_SECRET_KEY=${DD_SECRET_KEY}
      - DD_CREDENTIAL_AES_256_KEY=${DD_AES_KEY}
    volumes:
      - defectdojo_media:/app/media
    depends_on:
      - postgres
      - rabbitmq
    networks:
      - dojo_net

  celeryworker:
    image: defectdojo/defectdojo-django:latest
    command: celery -A dojo worker -l info
    environment:
      - DD_DATABASE_URL=postgresql://defectdojo:${POSTGRES_PASSWORD}@postgres:5432/defectdojo
      - DD_CELERY_BROKER_URL=amqp://defectdojo:${RABBITMQ_PASSWORD}@rabbitmq:5672//
      - DD_SECRET_KEY=${DD_SECRET_KEY}
    depends_on:
      - defectdojo
    networks:
      - dojo_net

  celerybeat:
    image: defectdojo/defectdojo-django:latest
    command: celery -A dojo beat -l info
    environment:
      - DD_DATABASE_URL=postgresql://defectdojo:${POSTGRES_PASSWORD}@postgres:5432/defectdojo
      - DD_CELERY_BROKER_URL=amqp://defectdojo:${RABBITMQ_PASSWORD}@rabbitmq:5672//
      - DD_SECRET_KEY=${DD_SECRET_KEY}
    depends_on:
      - defectdojo
    networks:
      - dojo_net

  nginx:
    image: defectdojo/defectdojo-nginx:latest
    ports:
      - "8080:8080"
      - "8443:8443"
    depends_on:
      - defectdojo
    networks:
      - dojo_net

volumes:
  postgres_data:
  rabbitmq_data:
  defectdojo_media:

networks:
  dojo_net:
```

## .env

```bash
# DefectDojo
POSTGRES_PASSWORD=secure_postgres_password
RABBITMQ_PASSWORD=secure_rabbitmq_password
DD_SECRET_KEY=your_secret_key_at_least_50_chars
DD_AES_KEY=your_32_char_aes_key_here_32ch

# DefectDojo at http://localhost:8080
# Default: admin/admin (change immediately)
```

## Usage notes

- DefectDojo at http://localhost:8080
- Default credentials: admin/admin
- Import SAST/DAST scan results
- Track vulnerability lifecycle
- CI/CD integration available

## Troubleshooting

- Celery workers stuck on large scan imports: Increase RabbitMQ memory limits and configure task-time-limit in celery settings to prevent worker timeout
- PostgreSQL connection errors during high scan volume: Tune max_connections and shared_buffers in PostgreSQL configuration, ensure connection pooling is enabled
- DefectDojo parser failures with 'Unable to process scan' errors: Verify scan file format matches expected parser input, check celery worker logs for specific parsing exceptions
- NGINX 413 'Request Entity Too Large' on scan uploads: Increase client_max_body_size in NGINX configuration and Django FILE_UPLOAD_MAX_MEMORY_SIZE setting
- RabbitMQ disk space warnings causing task failures: Configure RabbitMQ disk free limit and enable queue length limits to prevent unbounded growth during high import periods
- DefectDojo duplicate findings not being merged: Review deduplication configuration in System Settings, ensure hash_code algorithm matches your scanner output consistency

