Skip to content

feat: implement MCP server fuzzing and integration E2E tests#490

Merged
SecH0us3 merged 54 commits into
masterfrom
feature/mcp-server-fuzzing
Jul 19, 2026
Merged

feat: implement MCP server fuzzing and integration E2E tests#490
SecH0us3 merged 54 commits into
masterfrom
feature/mcp-server-fuzzing

Conversation

@SecH0us3

Copy link
Copy Markdown
Owner

This PR implements Model Context Protocol (MCP) server fuzzing support in the Swazz fuzzer engine, alongside complete integration E2E tests in Playwright.

Accomplishments

  1. Configuration and Schema Extensions: Added MCPServerConfig (supporting stdio and sse types) to Go configs, updated validation logic, and added the frontend config interface.
  2. Go MCP Client: Implemented standard StdioClient and SSEClient supporting JSON-RPC 2.0 and the initialize handshake connection. Verified correctness with internal Go unit tests.
  3. Fuzzer Mapping & Endpoint Generation: Integrated the MCP client during runner initialization to fetch/list tools and generate mapped virtual endpoints (mcp://tool/<tool_name>) dynamically.
  4. Execution & Crash/Reflection Detection: Intercepted virtual endpoints in the HTTP executor. Added Rule IDs swazz/mcp-server-crash (mapped to OWASP A10:2025 Mishandling of Exceptional Conditions) and swazz/mcp-tool-error-reflection (mapped to A05:2025 Injection) to record findings when tools crash/exit or leak exception text.
  5. E2E Playwright Integration Testing: Switched the E2E fuzzer to utilize stdio transport for reliability under local execution. Implemented demo/mcp-stdio.js to simulate SQLi-driven panics/exits (exit status 1) and XSS/traversal exception reflections.
  6. Documentation Update: Appended the Future work scenario for IAST integration approaches in tests/e2e/TODO.md.

All internal Go tests and E2E Playwright tests are passing successfully!

SecH0us3 added 20 commits July 17, 2026 23:27
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

SecH0us3 added 14 commits July 18, 2026 09:45
… 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.
…ouble-serialization error parsing and deduplication
@SecH0us3

Copy link
Copy Markdown
Owner Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread packages/container/internal/mcp/client.go Outdated
Comment thread packages/container/internal/runner/http_executor.go
Comment thread packages/container/internal/mcp/client.go Outdated
Comment thread packages/container/internal/swagger/detect.go
Comment thread packages/web/src/services/swaggerService.ts
@SecH0us3

Copy link
Copy Markdown
Owner Author

All review comments have been addressed in the latest commit and the threads have been resolved. Please review.

@SecH0us3

Copy link
Copy Markdown
Owner Author

Addressed the secondary code review comments regarding the nil-check in executeMCPRequest, buffer size adjustments in readSSELoop, and types.go comments.

@SecH0us3

Copy link
Copy Markdown
Owner Author

Adjusted onlyUpgrade checks to check for pre-existing mcp endpoints in config. Local E2E tests verified and passing successfully.

@SecH0us3
SecH0us3 merged commit 2bd4633 into master Jul 19, 2026
5 checks passed
@SecH0us3
SecH0us3 deleted the feature/mcp-server-fuzzing branch July 19, 2026 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant