How to Run OWASP ZAP API Scan
In this tutorial, you'll learn about How to Run OWASP ZAP API Scan. We cover key concepts, practical examples, and best practices.
ZAP API scan does not find any endpoints or reports zero alerts. The API definition file was not imported correctly, or the scanner did not parse the API structure.
The Wrong Way
# Running a standard active scan against an API endpoint
zap-active-scan.py -t https://api.example.com/v1/users
Standard scans require the spider to crawl links. APIs do not have HTML links — the spider finds nothing.
The Right Way
Step 1: Import the API definition
# For OpenAPI/Swagger:
# ZAP → Import → "OpenAPI Definition from URL"
# URL: https://api.example.com/openapi.json
# For GraphQL:
# ZAP → Import → "GraphQL Schema"
# Schema URL or introspection endpoint
# For SOAP:
# ZAP → Import → "WSDL from URL"
Step 2: Verify imported endpoints
# After import, check the Sites tree:
# - Each endpoint should appear: GET /users, POST /users, GET /users/{id}
# - Parameters are parsed from the API spec
# - Authentication schemes are noted
Step 3: Configure API authentication
# ZAP → Context → Authentication
# For API keys in headers:
# Context → "HTTP Authentication" → Add header: Authorization: Bearer <token>
# For OAuth2:
# Context → Authentication → OAuth2 → configure client credentials
Step 4: Run the API scan
# ZAP → Active Scan → select the API context
# Ensure "Input Vectors" includes:
# ✓ URL path parameters
# ✓ URL query parameters
# ✓ POST data
# ✓ JSON body parameters
API scan complete — 23 endpoints tested, 156 parameter combinations, 8 alerts found (1 High: SQLi in /users/{id}).
Prevention
- Always start with the OpenAPI specification for REST APIs.
- For APIs without a spec, use ZAP's "Spider (AJAX)" which renders JavaScript SPAs that load API definitions dynamically.
- The API parsing methodology is used in Durga Antivirus Pro's web API firewall — automatically extracting endpoints from OpenAPI specs for targeted protection.
Common Mistakes with zap api scan
- Misunderstanding that
Stringis[Char]with poor performance for large text operations - Using
foldlinstead offoldl'causing stack overflow on large lists - Forgetting
deriving (Show, Eq)on custom data types needed for debugging
These mistakes appear frequently in real-world OWASP code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.
Practice Exercise
Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.
This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.
FAQ
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro