test(mcp): lock test and save SSRF parity#1450
Open
floze-the-genius wants to merge 1 commit into
Open
Conversation
clark-cant
approved these changes
Jul 19, 2026
clark-cant
left a comment
Contributor
There was a problem hiding this comment.
Review: Approve ✅nnClean test PR: injects MCP discovery for testability and adds comprehensive SSRF parity regression coverage for private/metadata rejection, explicit allowlisting, and public URL acceptance. Low risk; no production behavior change. Mandatory gates clear; no critical/important findings. CI is currently pending (UNSTABLE), so merge after required checks pass. Closes #1070
clark-cant
approved these changes
Jul 19, 2026
clark-cant
left a comment
Contributor
There was a problem hiding this comment.
Maintainer Review — github-maintain
Verdict: APPROVED ✅
Assessment
| Gate | Result |
|---|---|
| Duplicate / prior work | No duplicate — #1248 added the allowlist mechanism, this PR adds test parity for test/save SSRF validation |
| Project standards | Clean — follows existing patterns, no standards violations |
| Strategic necessity | High — locks regression semantics for SSRF parity between test and save flows, directly closes #1070 |
Code review
internal/http/mcp.go (+7/-1)
- Makes
mcp.DiscoverToolsinjectable viadiscoverToolsfield onMCPHandler— clean dependency injection pattern NewMCPHandlerdefaults to productionmcp.DiscoverTools— zero behavioral change for callers- Signature matches the real function — no type drift
internal/http/mcp_tools.go (+1/-1)
- One-line change:
mcpbridge.DiscoverTools(...)→h.discoverTools(...)— correct, minimal
internal/http/mcp_ssrf_parity_test.go (+195)
- 4 test cases covering the full SSRF decision matrix:
- Private/loopback/metadata URLs rejected consistently by both test and save
- Explicit allowlist works for both flows
- Cloud metadata (169.254.169.254) blocked even when allowlisted — correct security invariant
- Public URLs accepted by both flows
- Discovery never fires for blocked URLs — verified via counter
- Store never creates servers for blocked URLs — verified via recorder
- Test/save errors are compared for equality — this is the actual parity assertion
Quality
- Correctness: Solid. The injectable
discoverToolsis the right approach — avoids network calls in tests while proving the validation path is identical. - Security: No regressions. Cloud metadata remains blocked even with allowlist — this is the correct hard invariant.
- Maintainability: Clean. Test helpers are well-structured, no magic values.
- Scope: Tight. 3 files, +203/-2, no scope creep.
Notes
- CI shows UNSTABLE with no checks reported yet — this is likely a transient state for a new PR. The code itself is sound.
- No labels on the PR — suggest adding
area:mcp,area:security,maintain:triaged.
Closes #1070.
Reviewed by github-maintain
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
mcp.DiscoverToolsas the production default/v1/mcp/servers/testand create/save return the same SSRF validation decision and error for local/private destinationsCloses #1070
Type
main)Target Branch
devChecklist
go build ./...passesgo build -tags sqliteonly ./...passesgo vet ./...passesgo test -race -timeout=5m ./...cd ui/web && pnpm install --frozen-lockfile && pnpm build$1, $2(N/A: no SQL changes)internal/upgrade/version.go(N/A: no migration)Test Plan
localhost, loopback, RFC1918, and cloud metadata before discovery or persistenceSurface parity: Web UI N/A because the API contract and UI behavior are unchanged.
Surface parity: CLI/runtime package N/A because this only locks existing HTTP validation semantics with regression coverage.