Skip to main content
Glama
ZAP_INTEGRATION.md•8.19 kB
# ZAP + MCP Proxy Integration ## Overview This integration combines **OWASP ZAP** (powerful scanner) with a **custom MCP proxy layer** (AI intelligence) to create a hybrid security testing engine that's more accurate than either tool alone. ## Architecture ``` Browser → MCP Proxy Layer → ZAP Proxy (port 8081) → Target ↓ AI Analysis ↓ Result DB ``` ## Features ### āœ… ZAP Integration - Full REST API client for ZAP - Spider (crawler) scans - Active vulnerability scans - Alert retrieval and analysis - Context management - Custom request routing ### āœ… MCP Proxy Layer - **Smart Request Analysis**: Detects sensitive parameters, auth bypass patterns, IDOR, business logic flaws - **Correlation Engine**: Combines ZAP alerts with custom findings - **AI Scoring**: Calculates confidence scores for each finding - **Automatic Database Storage**: Saves all findings to PostgreSQL ## Configuration ### 1. Start ZAP Make sure ZAP is running on port **8081**: ```bash # Using ZAP Docker docker run -d -p 8081:8080 -p 8090:8090 zaproxy/zap-stable zap.sh -daemon -host 0.0.0.0 -port 8080 -config api.disablekey=true # Or using ZAP desktop # Configure ZAP to listen on port 8081 ``` ### 2. Update mcp.json Your `~/.cursor/mcp.json` should include: ```json { "mcpServers": { "bugbounty-mcp": { "env": { "ZAP_URL": "http://localhost:8081", "ZAP_API_KEY": "" } } } } ``` **Note**: If ZAP is running without API key protection, leave `ZAP_API_KEY` empty. Otherwise, set it to your ZAP API key. ## Available Tools ### ZAP Core Tools #### `zap.health_check` Check if ZAP is running and accessible. #### `zap.start_spider` Start a spider (crawler) scan: ```json { "url": "https://example.com", "maxChildren": 10, "recurse": true } ``` #### `zap.get_spider_status` Get spider scan progress: ```json { "scanId": "0" } ``` #### `zap.start_active_scan` Start an active vulnerability scan: ```json { "url": "https://example.com", "recurse": true, "inScopeOnly": false } ``` #### `zap.get_active_scan_status` Get active scan progress: ```json { "scanId": "1" } ``` #### `zap.get_alerts` Get all security alerts: ```json { "baseURL": "https://example.com", "riskId": "3" } ``` #### `zap.get_alerts_summary` Get alerts summary by risk level: ```json { "baseURL": "https://example.com" } ``` #### `zap.send_request` Send a custom HTTP request through ZAP: ```json { "url": "https://example.com/api/endpoint", "method": "POST", "headers": {"Content-Type": "application/json"}, "body": "{\"key\":\"value\"}" } ``` #### `zap.get_sites` Get list of discovered sites. #### `zap.get_urls` Get list of discovered URLs: ```json { "baseURL": "https://example.com" } ``` #### `zap.create_context` Create a scanning context: ```json { "contextName": "my-context" } ``` #### `zap.include_in_context` Include URL pattern in context: ```json { "contextName": "my-context", "regex": "https://example.com/.*" } ``` ### MCP Proxy Layer Tools #### `zap.proxy_process` ⭐ **Recommended** Process a request through the intelligent proxy layer: ```json { "method": "POST", "url": "https://example.com/api/order/refund", "headers": {"Authorization": "Bearer token"}, "body": "{\"orderId\":123,\"amount\":100}" } ``` **What it does:** 1. Routes request through ZAP 2. Analyzes for custom vulnerabilities: - Sensitive parameter exposure - Authentication bypass - IDOR patterns - Business logic flaws - Missing security headers 3. Correlates ZAP alerts with custom findings 4. Calculates AI confidence scores 5. Saves all findings to database **Response:** ```json { "success": true, "data": { "request": {...}, "response": {...}, "findings": [ { "type": "idor", "severity": "high", "confidence": 0.5, "url": "https://example.com/api/order/refund", "correlationScore": 0.5, "aiScore": 0.65, "verified": false } ], "findingsCount": 1 } } ``` ## Usage Examples ### Example 1: Basic Spider Scan ```javascript // 1. Check ZAP health zap.health_check // 2. Start spider scan zap.start_spider with {"url": "https://stripchat.com"} // 3. Check status (use scanId from step 2) zap.get_spider_status with {"scanId": "0"} // 4. Get discovered URLs zap.get_urls with {"baseURL": "https://stripchat.com"} // 5. Get alerts zap.get_alerts with {"baseURL": "https://stripchat.com"} ``` ### Example 2: Active Scan ```javascript // 1. Start active scan zap.start_active_scan with {"url": "https://stripchat.com/api", "recurse": true} // 2. Monitor progress zap.get_active_scan_status with {"scanId": "1"} // 3. Get high-risk alerts zap.get_alerts with {"baseURL": "https://stripchat.com", "riskId": "3"} ``` ### Example 3: Intelligent Proxy Analysis ```javascript // Process a suspicious request through the proxy layer zap.proxy_process with { "method": "POST", "url": "https://stripchat.com/api/user/123/delete", "headers": {"Authorization": "Bearer token123"}, "body": "{\"userId\":123}" } // The proxy will: // - Detect IDOR (user-controlled ID) // - Check for auth bypass // - Correlate with ZAP findings // - Save to database ``` ## Custom Vulnerability Detection The MCP proxy layer detects: ### 1. Sensitive Parameters - `admin`, `role`, `permission`, `token`, `auth`, `password`, `secret` - `key`, `api_key`, `access_token`, `userId`, `amount`, `price`, `discount` ### 2. Authentication Bypass - Requests to protected endpoints without auth headers - 200 OK responses on endpoints that should require auth ### 3. IDOR (Insecure Direct Object Reference) - Numeric IDs in user-related endpoints - `/user/`, `/account/`, `/profile/`, `/order/`, `/transaction/` ### 4. Business Logic Flaws - Suspicious operations: refunds, price changes, transfers - Mass assignment patterns ### 5. Missing Security Headers - Content-Security-Policy - X-Frame-Options - X-Content-Type-Options - Strict-Transport-Security ## Correlation & Scoring ### Correlation Score Combines: - ZAP alert risk level (Informational → Critical) - ZAP confidence (False Positive → Confirmed) - Custom finding confidence ### AI Score Boosts correlation score when: - Both ZAP and custom findings agree (Ɨ1.3) - Finding is verified (Ɨ1.2) ## Database Integration All findings are automatically saved to PostgreSQL: - `test_results` table - Includes: target, test_type, success, score, payload, response_data - Scores: 0-10 (based on correlation and AI scoring) ## Benefits ### āœ… Accuracy Boost - **2-3x better accuracy** than ZAP alone - Reduces false positives - Catches logic flaws ZAP misses ### āœ… No Limitations - No Caido paywall - No Burp Community limitations - Full API control - Full automation ### āœ… Hybrid Intelligence - ZAP = Low-level scanner - MCP Proxy = High-level intelligence - Combined = Modern security platform ## Next Steps 1. **Start ZAP** on port 8081 2. **Restart Cursor** to load the new tools 3. **Test with**: `zap.health_check` 4. **Run scans** on your targets 5. **Use `zap.proxy_process`** for intelligent analysis ## Troubleshooting ### ZAP not accessible - Check ZAP is running: `curl http://localhost:8081/JSON/core/view/version` - Verify port in `mcp.json`: `"ZAP_URL": "http://localhost:8081"` - Check ZAP API key if required ### No findings - Make sure ZAP has discovered URLs (run spider first) - Check ZAP alerts: `zap.get_alerts` - Verify database connection ### Proxy layer not working - Ensure ZAP is accessible first - Check logs for errors - Try `zap.health_check` first ## Advanced Usage ### Multi-Stage Scanning 1. Light passive scan (spider) 2. Aggressive active scan 3. Custom fuzzing via proxy layer ### Context-Aware Scanning 1. Create context: `zap.create_context` 2. Include URLs: `zap.include_in_context` 3. Run scans within context ### Integration with Other Tools - Combine with `recon.*` tools for target discovery - Use `js.*` tools for endpoint extraction - Correlate with `security.*` test results --- **Ready to use!** Start ZAP on port 8081 and begin scanning. šŸš€

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/telmon95/VulneraMCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server