feat: implement MCP server fuzzing and integration E2E tests#490
Conversation
…Workers environment
…low client-side resolution
…uffering and task termination
…ection in stdio MCP helper
… profile for E2E fuzzer
…ectly in OWASPTop10
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
…PI Specs settings
…ent TypeError crashes
…loadSwaggerUrl validation
…ead of process.exit
…k to BuildRunnerConfig spec parsing
… goroutine bugs found in code review
- mcp/client.go: Use security.NewSSRFProtectedClient for SSEClient and HTTPClient (was raw &http.Client{})
- mcp/client.go: Replace bufio.Scanner with json.NewDecoder in readStdoutLoop to eliminate 64KB line limit deadlock
- mcp/client.go: Validate SSE endpoint redirect host matches original server (prevent SSRF via malicious endpoint event)
- mcp/client.go: Add allowPrivateIPs param to NewSSEClient and NewHTTPClient
- agent.go, cli.go: Fix defer cancel() inside goroutines — use explicit mcpCancel() calls
- runner.go: Pass config.Security.AllowPrivateIPs to MCP client constructors
- ApiSpecsTab.tsx, index.css: Move all inline layout styles to CSS classes (project rule compliance)
…ing %q instead of '%s' in Sprintf evidence generation
…nsecure HTTP headers (HSTS, X-Frame-Options, X-Content-Type-Options) and verbose software version exposures (Server, X-Powered-By, X-AspNet-Version) - Registered in default analyzer registry - Added unit tests in security_headers_test.go - Mapped rules to OWASP categories and CWEs in sarif.go - Added pretty display names and auto-remediation advice to the web frontend dashboard and settings
…if fetching succeeded) This resolves issues where URLs like https://mcp.notion.com/mcp return a successful HTTP response (e.g. 200/400/405) that is not a valid OpenAPI/Swagger specification, causing the parser to fail with 'invalid spec: no paths found' without ever attempting the MCP fallback.
…E clients and spec fetching - Pass headers and cookies from the UI through swaggerService.ts to /api/parse API - Handle Headers and Cookies in agent.go parse_request payload - Merge cookies into Cookie header and forward them with GET fetch request and MCP HTTP/SSE connections - Inject GlobalHeaders and Cookies in runner.go when initializing SSE/HTTP MCP clients - Improve spec fetching error messages to clearly prompt for authentication (HTTP 401/403) and guide the user to the right-hand settings panel
Ensure that custom headers and cookies are not discarded by the edge coordinator DO, so they are correctly transmitted to the agent fuzzer container's parse_request payload.
…ads in MCP client
… map http to sse UI config
…ouble-serialization error parsing and deduplication
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces support for Model Context Protocol (MCP) fuzzing across the Swazz engine and Web UI, enabling dynamic discovery and testing of MCP tools via Stdio, SSE, and HTTP transports. It also adds a new SecurityHeadersAnalyzer to detect missing or insecure HTTP headers. The review feedback highlights critical issues that should be addressed, including a data race on c.isClosed in the Stdio client, a potential nil pointer dereference in executeMCPRequest, a potential memory exhaustion (OOM) risk when reading SSE streams, incorrect error wrapping of nil errors in the spec detector, and a connection leak in the frontend's MCP server detection logic.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
…k, error wrapping, and connection leak
|
All review comments have been addressed in the latest commit and the threads have been resolved. Please review. |
|
Addressed the secondary code review comments regarding the nil-check in executeMCPRequest, buffer size adjustments in readSSELoop, and types.go comments. |
|
Adjusted onlyUpgrade checks to check for pre-existing mcp endpoints in config. Local E2E tests verified and passing successfully. |
…ly handle context cancels
…onfig support to SSEClient
…s, and mutex lock in client.go
…ts, strict stdio paths, and verify default TLS certificates
This PR implements Model Context Protocol (MCP) server fuzzing support in the Swazz fuzzer engine, alongside complete integration E2E tests in Playwright.
Accomplishments
MCPServerConfig(supportingstdioandssetypes) to Go configs, updated validation logic, and added the frontend config interface.StdioClientandSSEClientsupporting JSON-RPC 2.0 and the initialize handshake connection. Verified correctness with internal Go unit tests.mcp://tool/<tool_name>) dynamically.swazz/mcp-server-crash(mapped to OWASP A10:2025 Mishandling of Exceptional Conditions) andswazz/mcp-tool-error-reflection(mapped to A05:2025 Injection) to record findings when tools crash/exit or leak exception text.stdiotransport for reliability under local execution. Implementeddemo/mcp-stdio.jsto simulate SQLi-driven panics/exits (exit status 1) and XSS/traversal exception reflections.tests/e2e/TODO.md.All internal Go tests and E2E Playwright tests are passing successfully!