OWASP ZAP Basic Usage
Step-by-step guide for common testing scenarios using OWASP ZAP
This guide provides step-by-step instructions for common testing scenarios using OWASP ZAP. Whether you're new to ZAP or need a refresher, these workflows will help you get started quickly.
Installation and Setup
Desktop Installation
Download ZAP
- Go to the OWASP ZAP download page
- Select the appropriate package for your operating system
- Download the installer
Install ZAP
Windows:
- Run the downloaded
.exe
file - Follow the installation wizard
- Accept the license agreement
- Choose installation location
- Complete the installation
macOS:
- Open the downloaded
.dmg
file - Drag ZAP to the Applications folder
- Right-click the app and select "Open" (first time only)
Linux:
- Make the downloaded file executable:
chmod +x ZAP_*.sh
- Run the installer:
./ZAP_*.sh
- Follow the installation wizard
Initial Configuration
- Launch ZAP
- On first run, you'll see the initial configuration dialog
- Choose between Standard or Safe mode
- Accept or modify the default configurations
- Click Start to begin using ZAP
Quick Start Guide
Launch ZAP
- Start ZAP from your applications menu or command line
- Wait for ZAP to initialize
- The Quick Start tab should be displayed by default
Automated Scan
- In the Quick Start tab, enter the URL you want to scan (e.g.,
https://example.com
) - Click Attack
- ZAP will:
- Spider the site to discover content
- Perform an active scan to find vulnerabilities
- Display results in the Alerts tab
Review Results
- Go to the Alerts tab
- Review the discovered vulnerabilities
- Click on each alert to see:
- Description of the vulnerability
- Evidence found
- Solution recommendations
- References for further reading
Note:
The Quick Start scan is useful for a basic assessment but has limitations. For thorough testing, follow the manual testing workflow below.
Manual Testing Workflow
1. Configure Browser and Proxy
Automated Browser Setup
Launch Browser from ZAP
- In ZAP, go to Tools > Launch Browser
- Select your preferred browser
- ZAP will launch the browser with the correct proxy settings
Install SSL Certificate
- In the launched browser, navigate to http://zap/
- Click Download ZAP Root CA Certificate
- Follow the browser-specific instructions to install the certificate
Verify Connection
- Visit a HTTPS website (e.g., https://example.com)
- Check that the connection is secure without warnings
- Verify that the traffic appears in ZAP's History tab
2. Define Target and Scope
Create a New Context
- Right-click on Sites in the tree view
- Select New Context
- Enter a name for your context (e.g., "Test Application")
Define Context Scope
- In the context dialog, select Include in Context
- Click Add to add URL patterns
- Enter the base URL of your target (e.g.,
https://example.com/.*
) - Click OK
Optional: Add exclusion patterns for areas to avoid testing:
- Select Exclude from Context
- Click Add to add exclusion patterns
- Enter patterns for areas to exclude (e.g.,
https://example.com/logout.*
)
Set as Default Context
- Right-click on your new context in the Sites tree
- Select Set as Default Context
3. Explore the Application
Manual Browsing
- Using your proxied browser, navigate through the application
- Log in if the application requires authentication
- Access all important functionality
- Submit forms with valid data
- ZAP will record all traffic in the History tab
Run the Spider
- Right-click on your target in the Sites tree
- Select Attack > Spider
- Configure spider options:
- Max depth: How deep to crawl (e.g., 5)
- Thread count: Number of threads (e.g., 2)
- Check Spider Subtree Only to stay within the selected site
- Click Start Scan
- Monitor progress in the Spider tab
Run the AJAX Spider
For JavaScript-heavy applications:
- Right-click on your target in the Sites tree
- Select Attack > AJAX Spider
- Configure AJAX spider options:
- Select the browser to use
- Set max duration (e.g., 10 minutes)
- Click Start Scan
- Monitor progress in the AJAX Spider tab
4. Analyze Passively
Review Passive Scan Results
- Go to the Alerts tab
- Review issues identified by passive scanning
- These are issues found without sending additional requests
- Focus on information disclosure and configuration issues
Examine the Site Structure
- Explore the Sites tree to understand the application structure
- Look for interesting endpoints, parameters, and functionality
- Identify potential entry points for attacks
Analyze Parameters
- Go to the Params tab
- Review parameters discovered across the application
- Look for sensitive parameters (e.g., IDs, tokens)
- Note parameters that might be vulnerable to injection
5. Active Scanning
Configure Scan Policy
- Go to Tools > Options > Active Scan
- Review the default policy or create a new one
- Adjust scan strength and threshold as needed
- Enable/disable specific scan rules based on your needs
Start Active Scan
- Right-click on your target in the Sites tree
- Select Attack > Active Scan
- Configure scan options:
- Select your scan policy
- Check Recurse to scan all nodes
- Select context if applicable
- Select user if testing authenticated functionality
- Click Start Scan
Monitor Scan Progress
- Go to the Active Scan tab
- Monitor the progress of the scan
- Watch for new alerts appearing in the Alerts tab
- The scan may take several minutes to hours depending on the site size
Note:
Active scanning sends test requests that could potentially modify data or trigger security mechanisms. Always ensure you have proper authorization before active scanning.
6. Manual Testing
Request Interception
Enable Break Points
- Click the green ball icon in the toolbar to enable the break point
- Select where to break:
- Request: Break on requests
- Response: Break on responses
- Both: Break on both requests and responses
Intercept and Modify Requests
- In your browser, perform an action (e.g., submit a form)
- ZAP will intercept the request and show it in the Break tab
- Modify the request as needed:
- Change parameters
- Add/modify headers
- Alter cookies
- Click Submit to forward the modified request
Analyze the Response
- If you enabled response break points, ZAP will show the response
- Review the response content
- Modify the response if needed
- Click Submit to forward the response to the browser
7. Reporting
Generate a Report
- Go to Report > Generate Report
- Select the report format:
- HTML: Human-readable web format
- XML: Structured format for integration
- Markdown: Text-based format
- JSON: Machine-readable format
- Configure report options:
- Include only in-scope items
- Include passive alerts
- Set confidence/risk threshold
- Choose the destination file
- Click Generate Report
Review and Customize
- Open the generated report
- Review the findings
- For HTML reports, you can customize the CSS if needed
- For XML/JSON reports, you can process them with other tools
Export Issues
For specific issues or integration with other tools:
- Go to the Alerts tab
- Select the alerts you want to export
- Right-click and select Export Selected Alerts
- Choose the export format
- Save the exported alerts
Common Testing Scenarios
Testing an Authenticated Application
Set Up Authentication
- Create and configure a context for your target
- Go to the context properties
- Select Authentication
- Choose the authentication method:
- Form-based Authentication: For standard login forms
- HTTP Authentication: For Basic/Digest authentication
- Script-based Authentication: For complex flows
- Configure the authentication parameters
Define Logged-in/out Indicators
- In the Authentication panel, set:
- Logged in indicator: Regex pattern that appears when logged in (e.g., "Logout|Welcome")
- Logged out indicator: Regex pattern that appears when logged out (e.g., "Login|Sign in")
Create Users
- In the context properties, select Users
- Click Add to create a new user
- Enter user details:
- Name: User identifier
- Username/Password: Credentials for authentication
- Enable the user for testing
Configure Forced User Mode
- Select your user in the Users panel
- Click Set as Forced User
- Enable forced user mode by clicking the "person" icon in the toolbar
- ZAP will now authenticate as this user for all requests
Verify Authentication
- Browse the application through ZAP
- Confirm that ZAP maintains the session
- Check that protected resources are accessible
Scan Authenticated Areas
- Run the Spider with your configured user
- Run the Active Scanner with your configured user
- Review findings in the Alerts tab
Testing a REST API
Manual API Testing
Set Up API Context
- Create a new context for your API
- Include the API base URL in the context
- Configure authentication if required
Add API Endpoints
- Use the Request Editor to create requests for each endpoint
- Set appropriate HTTP methods (GET, POST, PUT, DELETE)
- Add required headers:
Content-Type: application/json
Authorization: Bearer token
(if needed)
- Add request body for POST/PUT requests
Test API Endpoints
- Send requests to each endpoint
- Analyze responses
- Look for security issues:
- Missing authentication
- Improper authorization
- Information disclosure
- Injection vulnerabilities
Active Scan API Endpoints
- Right-click on API endpoints in the Sites tree
- Select Attack > Active Scan
- Configure scan options for API testing
- Start the scan
Testing a Single-Page Application (SPA)
Configure Browser
Set up your browser to use ZAP as a proxy, as described earlier
Manual Exploration
- Browse through the SPA manually
- Interact with all features and functionality
- Ensure all AJAX requests are captured by ZAP
Run AJAX Spider
- Right-click on the SPA in the Sites tree
- Select Attack > AJAX Spider
- Configure options:
- Select a modern browser (Chrome or Firefox)
- Set adequate max duration (e.g., 10-15 minutes)
- Configure any required authentication
- Click Start Scan
- The AJAX Spider will interact with the application and discover content
Analyze Client-Side Code
- In the Sites tree, find JavaScript files
- Review JavaScript code for:
- Hardcoded credentials
- API keys
- Insecure configurations
- Client-side validation that can be bypassed
- Use the DOM XSS scanner to find client-side XSS vulnerabilities
Test API Endpoints
- Identify API endpoints used by the SPA
- Test these endpoints directly using the Request Editor
- Look for security issues in the API layer
Active Scan
Run an active scan focusing on:
- API endpoints
- Parameters in AJAX requests
- Client-side vulnerabilities
Troubleshooting
Proxy Connection Issues
Problem: Browser cannot connect through ZAP proxy
Solutions:
-
Verify ZAP is running and the proxy is listening:
- Check Tools > Options > Network > Local Servers/Proxies
- Default address is 127.0.0.1:8080
-
Confirm browser proxy settings:
- Check that the browser is configured to use 127.0.0.1:8080
- Try restarting the browser
-
Check for conflicts:
- Another application might be using port 8080
- Change ZAP's port in Options if needed
-
Test connectivity:
curl -x http://127.0.0.1:8080 http://example.com
Next Steps
Now that you understand the basic usage of OWASP ZAP, explore these topics:
- Scanning Options - Detailed configuration of scanning features
- Reporting - Generating and customizing security reports
- Advanced Techniques - Advanced usage scenarios and features
- Best Practices - Best practices for effective and ethical use of ZAP