Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
$ als gewone gebruiker# als root (of met sudo)
The quick answer
Step by step
- Get permission — scan only sites you own or have written permission to test. Tell the team and the hosting/WAF owner before an active scan.
- Baseline scan (quick answer): ZAP spiders the site for about a minute and only looks at the answers — no attacks. Safe for production at low traffic times.
- Read the report — each finding has a risk, the URLs and a fix. Common first findings and their fixes:
| Finding | Fix |
|---|---|
| Content Security Policy header not set | Add a CSP (start with report-only). |
| Missing Anti-clickjacking header | X-Frame-Options: DENY or CSP frame-ancestors. |
| Cookie without Secure / HttpOnly / SameSite | Set the flags in the app/framework. |
| Strict-Transport-Security header not set | Add HSTS after HTTPS works everywhere. |
| Server leaks version information | server_tokens off; in Nginx. |
- Full scan on a test system — active attacks (SQL injection, XSS tries):
docker run --rm -v "$PWD":/zap/wrk:rw -t ghcr.io/zaproxy/zaproxy:stable zap-full-scan.py -t https://staging.shop.example.com -m 10 -r full.htmlIt creates junk data and load — never on production.
- APIs — scan from the OpenAPI definition:
docker run --rm -v "$PWD":/zap/wrk:rw -t ghcr.io/zaproxy/zaproxy:stable zap-api-scan.py -t https://staging-api.shop.example.com/openapi.json -f openapi -r api.html- In CI — run the baseline against the staging deploy, keep accepted findings in a rules file (
-c zap-rules.tsvwithIGNORE/WARN/FAILper rule ID), and fail the pipeline only onFAILrules.
Check that it worked
The report opens and lists findings with URLs; after your fixes (headers, cookie flags) the next baseline scan no longer shows them, and the exit code is 0 (or only accepted warnings).
Common problems
| Problem | Cause | Fix |
|---|---|---|
Permission denied writing the report | The container user can not write the mounted folder. | chmod 777 on that folder (a temp folder only), or -u matching your UID. |
| Very few URLs scanned | Login pages, or a JavaScript-only site. | Use the Ajax spider (-j) or an authenticated scan with the Automation Framework. |
| The WAF blocks the scan | It looks like an attack. | Allow the scanner IP on staging; scan behind the WAF. |
| Full scan filled the DB with junk | Active scan on a real system. | Only on test systems with test data. |
| CI fails on known, accepted findings | No rules file. | -c zap-rules.tsv with IGNORE/WARN for accepted IDs. |
| HTTPS errors | Internal CA. | Add the CA to the container or scan the internal name with a trusted cert. |
Go further
- Command pages: zap, docker, curl.
- Next how-tos: Redirect HTTP to HTTPS in Nginx, Check the TLS settings of a website, Create a CI pipeline in GitHub Actions.
- Full guide: OWASP ZAP. At work: ZAP in the supply chain.
- Practise: Lab: put Nginx in front of an app with security headers.
1Which ZAP scan is safe for production, and why?
The baseline scan — it is passive: it only reads the answers and does not attack.
2Where should a ZAP full scan run?
Only on a test/staging system with test data — it sends real attacks.