Where DAST Fits in Modern Deployment Pipelines
Most engineering teams already run linters, unit test suites, and Static Application Security Testing (SAST) tools like SonarQube or Snyk on pull requests. These tools parse source code files for syntax flaws and insecure function calls. Yet, static scans remain blind to issues that appear only in a live environment: misconfigured reverse proxies, missing response headers, leaky session cookies, and runtime authentication bypasses.
Dynamic Application Security Testing (DAST) fills that gap. Unlike SAST or Software Composition Analysis (SCA), DAST tests a running web application from the outside. It treats your deployed container as a black box, probing endpoints exactly like an external attacker would.
| Testing Approach | Method | What It Catches | Pipeline Stage |
|---|---|---|---|
| SAST | White-box static code inspection | Unsanitized user inputs, hardcoded secrets, dangerous library calls | Pull Request (commit stage) |
| DAST (OWASP ZAP) | Black-box runtime attack simulation | Reflected XSS, permissive CORS headers, broken session cookies, missing HSTS | Ephemeral preview apps / Staging |
| Manual Pentesting | Human security assessment | Complex business logic flaws, multi-step privilege escalation | Quarterly audits / Major milestones |
Manual penetration tests provide deep insights, but they are too slow for teams deploying 10 to 20 times a day. Embedding OWASP ZAP (Zed Attack Proxy) directly into your CI pipeline catches configuration regressions and common runtime vulnerabilities on every pull request before your release reaches customers.
Trade-offs: Running DAST in Continuous Delivery
Adding dynamic scans to automated builds delivers immediate security feedback. Still, pipelines must be tuned carefully to avoid slowing down developers or breaking test environments.
The Advantages
- Catch environment-level misconfigurations: Critical directives like
Content-Security-Policy,Strict-Transport-Security, and missingHttpOnlycookie flags never exist in raw code alone. They only surface when your web server (such as Nginx or Traefik) serves responses alongside the application runtime. - Zero noise from unrouted code: If an unmaintained utility function cannot be triggered over an HTTP route, ZAP ignores it. That spares your team from triaging dead-code alerts.
- Reliable deployment gates: You can automatically fail a workflow when ZAP detects high-severity flaws like SQL injection or reflected cross-site scripting (XSS). This prevents known exploits from landing in main.
The Challenges
- Long scan times: An active spider and aggressive fuzzing run can easily take 2 to 4 hours against an API with 50+ endpoints. That destroys the standard 10-minute CI feedback loop.
- Destructive payload execution: Without safeguards, an active scan against a staging database will write garbage data into tables, trigger mass account registrations, or even execute cascade deletions.
- Session management: Single-page applications backed by OAuth2, PKCE, or short-lived JSON Web Tokens require custom authentication hooks so ZAP can reach protected screens.
The Tiered Scan Strategy
Do not run deep fuzzing attacks on every git push. A balanced setup splits dynamic testing into two complementary tiers:
- PR Pipeline (Baseline Scan): Spin up an ephemeral review environment and run the OWASP ZAP Baseline Scan. It crawls the target for 60 to 90 seconds, inspects responses passively, and checks headers without sending active exploit payloads. The entire check finishes in roughly 2 to 3 minutes, failing only on high-severity rule violations.
- Nightly Pipeline (Full Active Scan): Run ZAP’s active scan engine once every 24 hours against an isolated staging server backed by sanitized seed data. Here, ZAP actively injects test strings into query parameters and form fields, auditing for SQL injection, remote command execution, and blind SSRF.
When spinning up disposable staging environments and test service accounts, I use the password generator at toolcraft.app/en/tools/security/password-generator for server passwords — it runs entirely in the browser, so no data is ever sent over the network. That keeps bootstrap credentials off shared Slack threads or clipboard logs when preparing test runner targets.
Implementation: GitHub Actions with OWASP ZAP
Below is a working GitHub Actions workflow that launches an application container, verifies that it is accepting traffic, runs the ZAP Baseline Scan, and uploads an HTML audit report.
Step 1: Configure Rule Thresholds
Place a configuration file at .zap/rules.tsv in your repository. This maps individual ZAP plugin rule IDs to actions (FAIL, WARN, or IGNORE) so missing low-priority headers do not disrupt builds:
# Rule ID Action Description
10015 IGNORE # Incomplete or No Cache-control and Pragma HTTP Header Set
10020 WARN # Anti-clickjacking Header Not Set
10038 FAIL # Content Security Policy (CSP) Header Not Set
40012 FAIL # Cross Site Scripting (Reflected)
40018 FAIL # SQL Injection
Step 2: Create the GitHub Actions Workflow
Save the following YAML configuration to .github/workflows/dast-security-scan.yml. It starts your container, polls the /health endpoint until it returns an HTTP 200, and hands off the target to ZAP.
name: DAST Security Scan
on:
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
zap-scan:
runs-on: ubuntu-latest
name: Run OWASP ZAP Baseline Scan
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Start Target Application Container
run: |
docker run -d --name target-web-app -p 8080:8080 my-app-image:staging
# Poll the service until ready or fail after 30 seconds
timeout 30 bash -c 'until curl -sf http://localhost:8080/health; do sleep 2; done'
- name: Run ZAP Baseline Scan
uses: zaproxy/[email protected]
with:
target: 'http://localhost:8080'
rules_file_name: '.zap/rules.tsv'
cmd_options: '-a -j'
fail_action: true
- name: Upload Security Report Artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: zap-security-report
path: zap_report.html
Step 3: Scan Authenticated Endpoints
By default, ZAP only spiders routes visible to anonymous visitors. If your application protects user dashboards behind a bearer token, pass a pre-generated staging token using ZAP’s replacer configuration flag via the -z option:
docker run -v $(pwd):/zap/wrk/:rw -t ghcr.io/zaproxy/zaproxy:stable zap-baseline.py \
-t http://target-app.internal:8080 \
-r baseline-report.html \
-z "-config replacer.full_list(0).description=auth \
-config replacer.full_list(0).enabled=true \
-config replacer.full_list(0).matchtype=REQ_HEADER \
-config replacer.full_list(0).matchstr=Authorization \
-config replacer.full_list(0).regex=false \
-config replacer.full_list(0).replacement='Bearer eyJhbGciOi...'"
Step 4: Reviewing Findings and Enforcing Quality Gates
Each pipeline run deposits a zap_report.html file in the GitHub Actions summary panel. Findings are categorized into High, Medium, Low, and Informational tiers alongside the exact request URLs, response headers, and OWASP remediation guidelines.
If a pull request introduces an unescaped input or removes strict cookie flags, the workflow fails automatically and posts the details directly to the pull request. Addressing security defects while the author is still in context takes minutes. Catching them weeks later in production takes days.

