Geavanceerd
Zoeken inHow-to-gidsen
Zo zoek je
  • Typ de taak in je eigen woorden (poort vinden, firewall openen, schijf vol) of plak een foutmelding tussen aanhalingstekens.
  • Kies "Snel antwoord" om alleen de commando's te zien, of een gebied om in één vakgebied te blijven.
  • "twee woorden" vindt precies die zin.
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken
Probeer:

How-to 120Security · Web

How to scan a website with OWASP ZAP

Before a release — or before a pentest — you want to know the obvious web weaknesses: missing security headers, cookies without Secure, exposed debug pages, simple injection points. OWASP ZAP scans a running website. The baseline scan is passive and safe even for production; the full scan attacks and belongs on a test system only. This how-to runs both with Docker, reads the report, and adds ZAP to CI.

  • 5 Lessen
  • 6 Commando's

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

$ als gewone gebruiker# als root (of met sudo)

120.1

The quick answer

mkdir -p ~/zap && cd ~/zap && chmod 777 .
docker run --rm -v "$PWD":/zap/wrk:rw -t ghcr.io/zaproxy/zaproxy:stable zap-baseline.py -t https://staging.shop.example.com -r baseline.html

Open baseline.html in a browser. Exit code: 0 = no warnings, 1 = failures, 2 = warnings.

120.2

Step by step

  1. 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.
  2. 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.
  3. Read the report — each finding has a risk, the URLs and a fix. Common first findings and their fixes:
FindingFix
Content Security Policy header not setAdd a CSP (start with report-only).
Missing Anti-clickjacking headerX-Frame-Options: DENY or CSP frame-ancestors.
Cookie without Secure / HttpOnly / SameSiteSet the flags in the app/framework.
Strict-Transport-Security header not setAdd HSTS after HTTPS works everywhere.
Server leaks version informationserver_tokens off; in Nginx.
  1. 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.html

It creates junk data and load — never on production.

  1. 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
  1. In CI — run the baseline against the staging deploy, keep accepted findings in a rules file (-c zap-rules.tsv with IGNORE/WARN/FAIL per rule ID), and fail the pipeline only on FAIL rules.

120.3

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).

120.4

Common problems

ProblemCauseFix
Permission denied writing the reportThe 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 scannedLogin pages, or a JavaScript-only site.Use the Ajax spider (-j) or an authenticated scan with the Automation Framework.
The WAF blocks the scanIt looks like an attack.Allow the scanner IP on staging; scan behind the WAF.
Full scan filled the DB with junkActive scan on a real system.Only on test systems with test data.
CI fails on known, accepted findingsNo rules file.-c zap-rules.tsv with IGNORE/WARN for accepted IDs.
HTTPS errorsInternal CA.Add the CA to the container or scan the internal name with a trusted cert.

Commando's in deze les

120.5

Go further

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.

Alle commando's in dit hoofdstuk