fix(connection): block SSRF on connection create/update tool-fetch - #5516
Merged
Conversation
Reuse the private-network guard and redirect-blocking that REGISTRY_DISCOVER_TOOLS already enforces for the same trust boundary (a user-supplied MCP server URL) in CONNECTION_CREATE/CONNECTION_UPDATE's tool-fetch path, which had neither: an org member could set an HTTP/SSE connection_url pointing at a private/metadata address (or a public URL that 3xx-redirects to one) and the server would connect to it directly, bypassing the guard entirely by not going through discovery first.
decocms Bot
pushed a commit
that referenced
this pull request
Aug 1, 2026
PR: #5516 fix(connection): block SSRF on connection create/update tool-fetch Bump type: patch - decocms (apps/api/package.json): 4.158.0 -> 4.158.1 - @decocms/native (apps/native/package.json): 4.158.0 -> 4.158.1 Deploy-Scope: server
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.
Follows the SSRF-hardening lineage on
REGISTRY_DISCOVER_TOOLS(#4999, #5488, and others in the registry SSRF vein) — this closes the same gap on a sibling entry point.The gap:
apps/api/src/tools/connection/fetch-tools.ts(fetchToolsFromHttpMCP/fetchToolsFromSSEMCP) is called fromCONNECTION_CREATEandCONNECTION_UPDATEwith a user-suppliedconnection_url, and connects to it with the defaultfetch(redirect-following, no private-IP check). This is the exact same trust boundarydiscover-tools.ts'sisPrivateUrl/resolvesToPrivateAddress/createNoRedirectFetchguard was built for, but an org member could bypass that guard entirely just by callingCONNECTION_CREATE/CONNECTION_UPDATEdirectly (skippingREGISTRY_DISCOVER_TOOLS) with an HTTP/SSEconnection_urlpointing at a private/loopback/cloud-metadata address, or a public URL that 3xx-redirects to one.The fix: extracted the inline private-URL check in
discover-tools.ts's handler into a reusable exportedguardAgainstPrivateUrl(url)(no behavior change there — same logic, same order of checks, existing tests still cover it), then call that guard pluscreateNoRedirectFetch()from bothfetchToolsFromHttpMCPandfetchToolsFromSSEMCPbefore connecting. STDIO fetch is untouched (already gated bylocalMode, no network URL involved).Regression test: added
apps/api/src/tools/connection/fetch-tools.test.ts— assertsfetchToolsFromMCPreturnsnull(its existing failure contract) for an HTTP connection targeting169.254.169.254and an SSE connection targeting127.0.0.1, without ever attempting a network connection (blocked synchronously by the literal-IP check).Reviewer command:
bun test apps/api/src/tools/connection/fetch-tools.test.ts apps/api/src/tools/registry/discover-tools.test.tsLocally verified:
bun run fmt,cd apps/api && bunx tsc --noEmit(clean), the two test files above (22 pass), andbunx oxlinton all three changed files (0 warnings/errors). Full CI validates the rest.Summary by cubic
Blocks SSRF in connection create/update by enforcing the same private-network URL guard and no-redirect fetch used in
REGISTRY_DISCOVER_TOOLS. HTTP/SSEconnection_urlcan no longer target private/loopback/metadata IPs or redirect to them.guardAgainstPrivateUrl()from discovery and reused it infetch-toolsforCONNECTION_CREATEandCONNECTION_UPDATE.createNoRedirectFetch()to HTTP and SSE transports to prevent redirect-based bypass.fetchToolsFromMCPreturnsnullfor private targets (e.g.169.254.169.254,127.0.0.1) without making network requests.Written for commit 7b73335. Summary will update on new commits.