๐ก๏ธ OWASP ZAP - Complete Web Security Scanner Guide
OWASP Zed Attack Proxy (ZAP) is a free, open-source penetration testing tool for finding vulnerabilities in web applications.
๐ What is OWASP ZAP?
OWASP ZAP (Zed Attack Proxy) is one of the worldโs most popular free security tools and is actively maintained by hundreds of international volunteers. It can help you automatically find security vulnerabilities in your web applications while you are developing and testing your applications.
Key Features:
- โ
Intercepting Proxy - See and modify all traffic between browser and application
- โ
Active & Passive Scanning - Automated vulnerability detection
- โ
Spider/Crawler - Discovers all pages and functionality
- โ
Fuzzer - Tests inputs for unexpected responses
- โ
REST API - Automate security testing in CI/CD pipelines
๐ Installation & Setup
Method 1: Kali Linux (Pre-installed)
# ZAP is pre-installed on Kali Linux
zaproxy
# or
owasp-zap
Method 2: Download from Official Site
- Visit https://www.zaproxy.org/download/
- Download for your OS (Windows, macOS, Linux)
- Install following the platform-specific instructions
Method 3: Docker Installation
# Pull the latest ZAP Docker image
docker pull owasp/zap2docker-stable
# Run ZAP in headless mode
docker run -t owasp/zap2docker-stable zap-baseline.py -t http://target-site.com
๐ฏ Getting Started - Your First Scan
1. Launch ZAP
# Start ZAP with GUI
zaproxy
# Start ZAP headless (command line only)
zap.sh -cmd -port 8080
2. Basic Automated Scan
- Launch ZAP and click โStartโ
- Enter target URL in the โQuick Startโ tab
- Choose attack mode:
- Safe Mode: Only passive scanning
- Protected Mode: Limited to defined scope
- Standard Mode: Full features, manual control
- Attack Mode: Aggressive testing (use carefully!)
- Click โAttackโ to start automated scanning
๐ง Core Features & Workflow
1. Proxy Configuration
ZAP acts as a proxy between your browser and the target application:
# Default ZAP proxy settings
Proxy: 127.0.0.1:8080
Browser Setup:
- Configure browser proxy settings
- Navigate to
http://zap/
to download ZAP certificate
- Install certificate in browser for HTTPS interception
2. Spidering (Crawling)
Discover all application pages and functionality:
# Command line spider
zap-cli spider http://target-site.com
# Or use GUI: Tools > Spider
3. Active Scanning
Actively test for vulnerabilities:
# Command line active scan
zap-cli active-scan http://target-site.com
# Monitor scan progress
zap-cli status
4. Passive Scanning
Analyze requests/responses for issues without sending additional requests:
- Runs automatically as you browse
- Identifies issues like missing security headers
- No risk of damaging target application
๐ก Advanced Techniques
1. Authentication Testing
Test applications requiring login:
Form-based Authentication:
- Navigate to Context > Add Context
- Set Include in Context patterns
- Configure Authentication method
- Set up Session Management
- Create Users for testing
2. Custom Fuzzing
Test specific parameters with custom payloads:
# Access Fuzzer through right-click on request
# Set payload positions with $ markers
# Choose from built-in wordlists or custom
3. API Testing
Test REST APIs and web services:
- Import API definition (OpenAPI/Swagger)
- Configure authentication (API keys, tokens)
- Run automated scans on endpoints
- Review results for API-specific vulnerabilities
4. Scripting & Automation
Automate ZAP with scripts:
// Example ZAP script (JavaScript)
function scan(msg) {
// Custom scanning logic
var uri = msg.getRequestHeader().getURI().toString();
if (uri.contains("admin")) {
// Flag potential admin interface
return;
}
}
๐ Understanding Results
Vulnerability Severity Levels:
- ๐ด High: Critical security issues requiring immediate attention
- ๐ก Medium: Significant security concerns
- ๐ต Low: Minor security issues or best practice violations
- โน๏ธ Informational: No direct security impact
Common Vulnerability Types ZAP Detects:
- SQL Injection - Database query manipulation
- Cross-Site Scripting (XSS) - Malicious script injection
- Cross-Site Request Forgery (CSRF) - Unauthorized command transmission
- Path Traversal - Unauthorized file access
- Security Headers Missing - Missing protective HTTP headers
๐ ๏ธ Integration with CI/CD
Baseline Scan in Pipeline
# Jenkins/GitLab CI example
docker run -t owasp/zap2docker-stable zap-baseline.py \
-t https://your-app.com \
-g gen.conf \
-r baseline-report.html
Full Scan Automation
#!/usr/bin/env python3
from zapv2 import ZAPv2
# Connect to ZAP
zap = ZAPv2(proxies={'http': 'http://127.0.0.1:8080'})
# Spider the target
target = 'https://your-app.com'
zap.spider.scan(target)
# Wait for spider to complete
while int(zap.spider.status()) < 100:
print(f'Spider progress: {zap.spider.status()}%')
time.sleep(2)
# Start active scan
zap.ascan.scan(target)
# Generate report
with open('zap-report.html', 'w') as f:
f.write(zap.core.htmlreport())
๐ Learning Path
Beginner Level (Week 1-2):
Advanced Level (Week 7-12):
๐ Recommended Resources
Official Documentation:
Practice Environments:
- DVWA - Damn Vulnerable Web Application
- WebGoat - OWASP learning environment
- Mutillidae - Vulnerable web app
Video Training:
๐ Common Use Cases
1. Development Testing
# Quick scan during development
zap-baseline.py -t http://localhost:3000 -g gen.conf
2. Penetration Testing
- Comprehensive vulnerability assessment
- Manual testing with intercepting proxy
- Custom payload fuzzing
- Authentication bypass testing
3. Bug Bounty Hunting
- Initial reconnaissance and scanning
- Finding low-hanging fruit vulnerabilities
- Validating potential security issues
- Generating professional reports
4. Compliance Testing
- OWASP Top 10 vulnerability assessment
- Security header compliance checking
- SSL/TLS configuration testing
- Input validation testing
โ ๏ธ Best Practices & Warnings
โ
DO:
- Always get written permission before testing
- Start with passive scanning on production systems
- Use safe mode when learning
- Keep ZAP updated to latest version
- Review all findings manually
โ DONโT:
- Run active scans on production without permission
- Use attack mode on systems you donโt own
- Ignore rate limiting and respectful testing
- Trust automated results without manual verification
๐ Troubleshooting
Common Issues:
- Certificate Warnings: Install ZAP certificate in browser
- Slow Scanning: Adjust scan policy and thread count
- False Positives: Review findings manually
- Memory Issues: Increase JVM heap size
# Increase memory allocation
export JAVA_OPTS="-Xmx4g"
zaproxy
๐ก Pro Tip
ZAP is most effective when combined with manual testing. Use automated scans to find obvious issues, then dive deeper with manual techniques using the intercepting proxy and fuzzer features.
OWASP ZAP is maintained by volunteers and is completely free. Consider contributing to the project or donating to support continued development.