CCyberwiki

Dynamic application security testing

DAST
TypeSecurity testing method
Also known asDAST, web application vulnerability scanning
ExaminesThe running application, through its HTTP interface
Needs source codeNo
Example toolsZAP, Burp Suite, Nuclei
Related methodsSAST, SCA, Penetration testing, Fuzzing

A DAST tool tests a web application while it runs: it sends requests, reads the responses and looks in them for security flaws. The scanners normally work from outside the application, probing for cross-site scripting, SQL injection, command injection, path traversal and insecure server configuration.1 They judge the application by how it behaves in use, so they need no detailed knowledge of its source code.2 NISTIR 8397, NIST's 2021 list of minimum techniques for verifying software, puts web application scanners next to black-box test cases and Fuzzing.3

How a scan works

ZAP by Checkmarx, a free and open-source tool for testing web applications, is built as an intercepting proxy: it sits between the tester's browser and the application, reads each message that passes, can change it, and forwards it.4 An automated scan in ZAP has three stages: a crawler explores the site, each page it finds is scanned passively, and the active scanner then attacks the pages, functions and parameters that were discovered.4

Crawling

The scanner tests only what it has found, so the crawl sets the coverage. ZAP offers three spiders. The traditional spider reads links out of the HTML of each response; it is fast, but not always effective on applications that build their pages with JavaScript. The Client spider drives a real browser and follows the links that appear, which is slower and reaches most modern applications. The older AJAX spider is no longer recommended in most cases.4 Pages behind a sign-in stay out of reach unless the scanner is configured to log in.5 A spider fills forms with default data, so a form that needs a valid email address returns an error and the pages after it stay unseen; ZAP's guide recommends also exploring by hand in a browser routed through ZAP.4

Passive scanning

Passive scan rules read the HTTP and WebSocket messages that pass through or are sent by the scanner, without sending anything new.6 Because nothing is added to the traffic, the mode is safe to run.4 Passive rules catch what is visible in a normal response: a missing X-Frame-Options header, a cookie without the HttpOnly flag, mixed content on an HTTPS page, a suspicious comment in the HTML.7

Active scanning

Active scanning sends known attacks to the targets to find vulnerabilities that passive rules miss. ZAP's documentation calls this an attack on the target and says it must not be run against applications the tester does not own.8 A scan can damage the site's functions and data.4 A scan policy sets which attack rules run. ZAP ships a script, AddZapHeader.js, that adds a header such as X-ZAP-Initiator to every request, so that the traffic can be told apart and allowed through a web application firewall.8

Results

ZAP reports each finding as an alert: a potential vulnerability tied to one request. ZAP sets the risk automatically, as Informational, Low, Medium or High, and a confidence of Low, Medium or High. The confidence levels False Positive and Confirmed exist, but ZAP never assigns them itself; a person sets them by hand or through an alert filter.9 Table 1 shows the main fields of an alert for an invented active-scan finding on example.com.

Table 1. Fields of a ZAP alert, with example values
FieldMeaningExample
NameThe rule that raised the alertSQL Injection
URLThe request that showed the problemhttps://example.com/api/orders?id=1
ParameterThe input that was attackedid
AttackThe payload sent; empty for passive alerts1 OR 1=1
EvidenceThe text in the request or response that supports the findingA database error message
Risk, ConfidenceSeverity and certaintyHigh, Medium
CWE IDThe weakness type89

Each alert also carries a suggested solution, which is generic because the scanner has no access to the source code.9 The Common Weakness Enumeration number links the finding to the catalogue of weakness types.

Running a scan

ZAP publishes two ready-made scan scripts in its Docker image. The baseline scan crawls for one minute by default, waits for the passive rules to finish and sends no attacks, so it takes a few minutes at most and suits continuous integration, even against production sites:7

docker run -t ghcr.io/zaproxy/zaproxy:stable zap-baseline.py -t https://www.example.com

The output lists each rule as PASS, WARN or FAIL with its number, for example WARN: X-Frame-Options Header Not Set [10020], followed by a count line such as FAIL: 0 WARN: 4 IGNORE: 0 PASS: 22. A configuration file passed with -c moves chosen rules to INFO, IGNORE or FAIL, and the script exits with code 1 when at least one rule fails.7 The full scan crawls with no time limit and then runs the complete active scan. It sends real attacks and can run for a long time.10

The DevSecOps Verification Standard grades a team's use of DAST: at level 1 scans run by hand, at level 2 every build starts a scan, and at level 3 findings also go to a central issue tracker and the tool's effectiveness is reviewed on a schedule.2

Limits

Active scanning finds only certain kinds of vulnerability. Logical flaws such as broken access control escape every automated scanner, and ZAP's own documentation tells its users to add manual Penetration testing.8 The crawl sets a second bound: a page that is not linked, sits behind a login, or follows a form the crawler cannot complete is never tested.4 The accuracy of different DAST tools can be compared with the OWASP Benchmark project.1

Relation to other tests

Because DAST runs the application, each finding comes tied to a request; SAST reads the source code without running it, and SCA looks at the third-party packages the application depends on. A penetration test brings in a person to probe the logic that scanners miss. Some products bundle SAST, DAST and SCA in one tool.1 Template scanners such as Nuclei send requests defined in templates, each template modelling one security check.2

In SecFlash

SecFlash runs ZAP against an app and shows its findings on the Security page. Results of the attack test include SF-SEC-601 when ZAP changed a database query, SF-SEC-605 for path traversal, SF-SEC-607 for command injection and SF-SEC-619 when the cloud metadata address answered. Header and form findings from ZAP include SF-SEC-611 for a form without an anti-CSRF token, SF-SEC-621 for a missing Content-Security-Policy header, SF-SEC-624 for missing HSTS and SF-SEC-628 for a cookie without HttpOnly. SF-SEC-699 covers any other ZAP rule, and SF-SEC-307 reports a matched Nuclei template.

See also

References

  1. a b c "Vulnerability Scanning Tools". OWASP Community. OWASP Foundation.
  2. a b c "DSOVS-TEST-002 (DAST)". OWASP DevSecOps Verification Standard. OWASP Foundation.
  3. back Black, Paul; Guttman, Barbara; Okun, Vadim (October 2021). "Guidelines on Minimum Standards for Developer Verification of Software". NISTIR 8397. NIST.
  4. a b c d e f g "Getting Started". ZAP documentation. ZAP by Checkmarx.
  5. back "Authentication Decision Tree". ZAP documentation. ZAP by Checkmarx.
  6. back "Passive Scan". ZAP Desktop User Guide. ZAP by Checkmarx.
  7. a b c "ZAP - Baseline Scan". ZAP Docker documentation. ZAP by Checkmarx.
  8. a b c "Active Scan". ZAP Desktop User Guide. ZAP by Checkmarx.
  9. a b "Alerts". ZAP Desktop User Guide. ZAP by Checkmarx.
  10. back "ZAP - Full Scan". ZAP Docker documentation. ZAP by Checkmarx.