|
| 1 | +--- |
| 2 | +title: Dynamic Application Security Testing (DAST) |
| 3 | +short_title: Dynamic Application Security Testing |
| 4 | +--- |
| 5 | + |
| 6 | +## Introduction |
| 7 | + |
| 8 | +:::{note} Definition |
| 9 | +DAST tests a running Python application to identify security vulnerabilities that only become visible at runtime. |
| 10 | +::: |
| 11 | + |
| 12 | +The purpose of DAST is to simulate real-world attacks and observe how the application behaves under malicious input or unexpected conditions. |
| 13 | + |
| 14 | +### How DAST for Python works |
| 15 | + |
| 16 | +- Sends crafted test inputs to the running application (for example HTTP requests, form data, API calls, or other simulated user interactions). |
| 17 | +- Monitors the application’s responses and behaviour for security issues such as cross-site scripting (XSS), SQL injection, authentication and authorisation flaws, insecure redirects, or denial-of-service conditions under load. |
| 18 | +- Operates as a black-box technique: it does not require access to the source code. |
| 19 | + |
| 20 | +**Example** |
| 21 | +Testing a Python web application (Flask, Django, or FastAPI) by submitting malicious form inputs and crafted HTTP requests to check for XSS, open redirects, or injection vulnerabilities. |
| 22 | + |
| 23 | +## SAST vs DAST for Python applications |
| 24 | + |
| 25 | +SAST is a white-box approach that analyses source code without executing it. It is straightforward to introduce early in the development lifecycle and provides high value for catching issues before they reach runtime. |
| 26 | + |
| 27 | +DAST is a black-box approach that exercises the live application. Mature, language-agnostic tools such as OWASP ZAP, Burp Suite, and Nuclei work effectively against Python web frameworks. Purpose-built Python-only DAST scanners are less common, but the general-purpose tools cover the majority of practical needs. |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | +For any Python application SAST and DAST are complementary and recommended from a security perspective. |
| 32 | + |
| 33 | +| Aspect | SAST (Static Application Security Testing) | DAST (Dynamic Application Security Testing) | |
| 34 | +|-----------------------------|---------------------------------------------------------------------------------|----------------------------------------------------------------------------------| |
| 35 | +| **Approach** | White-box | Black-box: tests the running application by sending inputs and observing behaviour | |
| 36 | +| **When performed** | Early (coding / CI stage) – “shift-left” | Later (running application, staging, or production-like environment) | |
| 37 | +| **What it examines** | Python source (`.py`), dependencies, configuration files | HTTP endpoints, APIs, runtime behaviour of a live Python process | |
| 38 | +| **Typical Python tools** | [Python Code Audit](https://nocomplexity.com/codeaudit/) | OWASP ZAP, Burp Suite, Nuclei, custom scripts against Flask/Django/FastAPI apps | |
| 39 | +| **Vulnerabilities found** | Hard-coded secrets, use of `eval`/`exec`/`pickle`, insecure deserialisation, weak cryptography, SQL-injection patterns in code, dependency CVEs | Runtime injection (SQLi, command injection), XSS, authentication/authorisation flaws, insecure headers, business-logic issues | |
| 40 | +| **False-positive rate** | Higher (static analysis can miss context) | Lower for reachable issues, but may miss unexercised code paths | |
| 41 | +| **Coverage** | Entire codebase, including unexecuted paths | Only exercised code paths and exposed interfaces | |
| 42 | +| **Requires running app?** | No | Yes | |
| 43 | +| **Best suited for** | All Python code(parts), applications, libraries, scripts, CLI tools, and for early detection in CI | Large systems with Python code, Python based Web applications (Django, Flask, FastAPI), APIs, microservices (with Python backend) | |
| 44 | +| **Limitations for Python** | Python dynamic features (`getattr`, metaclasses, runtime code generation) | Limited insight into internal Python logic; less effective for non-HTTP interfaces | |
| 45 | +| **Integration** | Easy in pre-commit hooks | Requires a deployed environment; typically run as part of security testing workflows. | |
| 46 | + |
0 commit comments