The Reality Check: Critical Flaws Escaping into Staging
Six months ago, our team failed an internal security audit. We were deploying to production twice a day with clean unit test runs and green SonarQube SAST gates. On paper, our delivery was flawless. In practice, our security team found an authentication bypass in our session service and two open redirects in our API gateway. Both had lived in staging for three weeks undetected.
Static code analysis simply could not catch these flaws. SAST inspects source syntax, but it cannot evaluate runtime JWT verification, broken Nginx reverse-proxy rewrites, or stateful token expiry. We relied on quarterly penetration tests instead. By the time those 80-page PDF audit reports landed in Jira, our codebase had shifted across 150 pull requests. Patching required massive context switching, ruined sprint commitments, and sparked endless finger-pointing between teams.
Why Standard Pipeline Testing Failed Us
Our post-mortem surfaced three systemic bottlenecks in our delivery pipeline:
- Runtime blind spots: Static analyzers do not boot your web servers, wire up Postgres instances, or test Redis sessions. Configuration mistakes, CORS misconfigurations, and environment variable leaks only reveal themselves while the stack is running.
- Triage overload and duplicate alerts: Raw DAST tools dump massive JSON payloads per run. With 35 microservices deploying multiple times a day, engineers drowned in repetitive alerts. We lacked a central place to deduplicate findings or verify when a developer’s fix actually worked.
- Pipeline stalls: A full active security crawl against a staging replica takes three to five hours. Running heavy attacks on every pull request broke our 15-minute deployment target, tempting engineers to skip security checks entirely.
Evaluating Three DAST Architectures
We spent four weeks stress-testing three separate architectures across our staging clusters.
Option 1: Commercial Cloud Scanners
Enterprise SaaS security platforms offer polished dashboards and turnkey reporting. However, they clashed with our private network design. Our staging environments run in isolated VPC subnets behind AWS ALB listeners. Punching holes through security groups or maintaining dedicated IP allowlists created operational overhead. Worse, vendor quotes came in at $42,000 annually for 40 targets—far too expensive for early-stage feature branching.
Option 2: Standalone OWASP ZAP in CI Runners
Next, we ran the official OWASP ZAP container directly inside GitHub Actions workflows. The scans ran fast—under two minutes per run. But vulnerability management quickly fell apart. Every merge triggered duplicate alerts, nobody marked resolved findings, and weekly triage devolved into painful spreadsheet reconciliations.
Option 3: OWASP ZAP Coupled with DefectDojo (Our Choice)
Pairing OWASP ZAP with OWASP DefectDojo solved both runtime discovery and tracking. ZAP acts as the headless testing engine inside our CI runner, while DefectDojo serves as the centralized vulnerability register. DefectDojo ingests ZAP’s scan reports through a REST API, automatically deduplicates repeat findings across builds, tracks remediation SLAs, and ties each vulnerability directly to git commits and Jira tickets.
Production Architecture: Implementing ZAP and DefectDojo
Here is the exact architecture we deployed and currently maintain across our core repositories.
1. Deploying the DefectDojo Instance
We run DefectDojo on Amazon EKS using the official Helm chart, backed by an external PostgreSQL RDS instance. For local testing or smaller setups, Docker Compose gets you running in minutes. Once running, generate an API v2 key from your user profile to authenticate pipeline uploads.
# Clone the official repository
git clone https://github.com/DefectDojo/django-DefectDojo.git
cd django-DefectDojo
# Build containers and boot in background
./dc-build.sh
./dc-up-d.sh
# Retrieve initial admin credentials from the initializer service
docker compose logs initializer | grep "Admin password:"
2. Running Headless ZAP in GitHub Actions
Never run full, payload-heavy active scans inside pull request builds. Instead, use a two-tiered model: a lightweight ZAP Baseline Scan on PR merges to catch missing security headers and passive leakage in under 90 seconds, and a scheduled deep active scan every Sunday night.
Here is our GitHub Actions workflow. It spins up the application container, polls until the health check passes, and executes the baseline scan against the local host network:
name: DAST Security Pipeline
on:
push:
branches: [ staging, main ]
jobs:
dast-scan:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Start Application Container
run: |
docker compose up -d app
# Poll the service until healthy instead of using an arbitrary sleep
timeout 60s bash -c 'until curl -fsS http://localhost:8080/health; do sleep 2; done'
- name: Run OWASP ZAP Baseline Scan
uses: zaproxy/[email protected]
with:
target: 'http://localhost:8080'
rules_file_name: '.zap/rules.tsv'
cmd_options: '-a -j --network=host'
continue-on-error: true
- name: Archive ZAP Output
uses: actions/upload-artifact@v4
with:
name: zap-report
path: zap_report.json
3. Automated Ingestion to DefectDojo via Python
Instead of relying on fragile third-party wrapper actions, we use a dedicated Python script to ship reports to DefectDojo. It automatically resolves the engagement ID, uploads the JSON report, deduplicates findings, and closes out issues that developers fixed in the current commit.
#!/usr/bin/env python3
import os
import sys
from datetime import date
import requests
DEFECTDOJO_URL = os.environ.get("DEFECTDOJO_URL", "https://defectdojo.internal.net")
API_TOKEN = os.environ.get("DEFECTDOJO_TOKEN")
ENGAGEMENT_ID = os.environ.get("DEFECTDOJO_ENGAGEMENT_ID", "1")
REPORT_PATH = "zap_report.json"
if not API_TOKEN:
print("Error: DEFECTDOJO_TOKEN environment variable is missing.")
sys.exit(1)
headers = {"Authorization": f"Token {API_TOKEN}"}
with open(REPORT_PATH, "rb") as fp:
files = {"file": (REPORT_PATH, fp, "application/json")}
data = {
"active": True,
"verified": False,
"scan_type": "ZAP Scan",
"engagement": ENGAGEMENT_ID,
"scan_date": str(date.today()),
"deduplication_on_engagement": True,
"close_old_findings": True,
"auto_create_context": True
}
response = requests.post(
f"{DEFECTDOJO_URL}/api/v2/import-scan/",
headers=headers,
data=data,
files=files,
timeout=45
)
if response.status_code == 201:
print("Report imported successfully. Active findings deduplicated.")
else:
print(f"Upload failed ({response.status_code}): {response.text}")
sys.exit(1)
4. Defining Pragmatic Quality Gates
Do not break builds on Low or Informational alerts. If every missing X-Content-Type-Options header stops a hotfix from shipping, developers will simply disable the scanner. We configure DefectDojo webhooks to ping our security Slack channel for all findings, but we only break CI builds when High or Critical vulnerabilities appear without an approved risk exception.
Results After Six Months in Production
Automating our DAST pipeline fundamentally changed our security posture:
- Faster turnaround: Our mean time to remediate (MTTR) runtime flaws dropped from 42 days down to 36 hours. Developers fix issues while the code context is fresh in their minds.
- Zero alert fatigue: DefectDojo’s engagement deduplication eliminated over 1,400 redundant alerts across our 35 services in the first quarter alone.
- Audit readiness: We replaced messy spreadsheet audits with real-time compliance dashboards. Our security team can verify the security posture of any release branch in under thirty seconds.
Treating ZAP as the execution sensor and DefectDojo as the source of truth gives us continuous verification without grinding our delivery pipeline to a halt.
