What is OWASP ZAP and how do you run a DAST scan?

BeginnerHands-onOWASP ZAP
Answer

Short answer

OWASP ZAP (Zed Attack Proxy) is a free DAST tool — it tests your running application from the outside, like an attacker would, by sending requests and checking the responses for problems such as missing security headers, cross-site scripting (XSS), SQL injection and insecure cookies. In pipelines we usually run a baseline scan against the staging environment after deployment.

SAST vs DAST — simply

SAST (e.g. SonarQube) DAST (e.g. OWASP ZAP)
Looks at Source code The running app, over HTTP
When Before deployment After deployment to a test or staging environment
Finds Bad code patterns Real behaviour: headers, cookies, injection, misconfiguration
Needs the code? Yes No — only a URL

You need both: SAST finds problems in code early; DAST finds problems that only show up when the app is running.

Examples

# Baseline scan: passive, safe, quick (a few minutes) — good for every pipeline run
docker run --rm -v "$PWD:/zap/wrk" -t ghcr.io/zaproxy/zaproxy:stable \
  zap-baseline.py -t https://staging.shop.example.com -r zap-report.html

# Full scan: actively attacks the app — only against test environments, takes longer
docker run --rm -v "$PWD:/zap/wrk" -t ghcr.io/zaproxy/zaproxy:stable \
  zap-full-scan.py -t https://staging.shop.example.com -r zap-full.html

# API scan using an OpenAPI definition
docker run --rm -v "$PWD:/zap/wrk" -t ghcr.io/zaproxy/zaproxy:stable \
  zap-api-scan.py -t https://staging.shop.example.com/openapi.json -f openapi -r zap-api.html

Example findings in the report:

WARN-NEW: Content Security Policy (CSP) Header Not Set [10038] x 4
WARN-NEW: Cookie Without Secure Flag [10011] x 2
WARN-NEW: Strict-Transport-Security Header Not Set [10035] x 4
FAIL-NEW: 0   WARN-NEW: 3   PASS: 52

Exit codes: 0 = no issues, 1 = at least one FAIL, 2 = warnings only — so the pipeline can decide what breaks the build. A -c rules.conf file sets which rules are IGNORE, WARN or FAIL.

Where it fits in the pipeline

build → test → SAST → image scan → deploy to staging → ZAP baseline scan → approve → production

Important: never run a full (active) scan against production. It sends attack traffic and can create junk data or trigger alerts.

What to say in the interview

"OWASP ZAP is a DAST tool that tests the running application from outside. After we deploy to staging, the pipeline runs a ZAP baseline scan in Docker against the staging URL. It reports issues like missing security headers, insecure cookies and XSS, publishes an HTML report, and fails the build based on a rules file. We use SAST tools like SonarQube on the code and ZAP on the running app, because each finds different problems."

Follow-up questions you may get

  • How do you scan pages behind a login? Configure authentication in ZAP (a context with login details or a session token) so it can reach protected pages.
  • How do you fix "CSP header not set"? Add a Content-Security-Policy header in the app or in the Nginx/Ingress config.
All Security Tools questions Roadmap: OWASP ZAP — dynamic testing (DAST)

More on OWASP ZAP