fix(server): use listener port for managed tunnel origins #8353
Closedmateo-m(GitHub profile, opens in a new tab)wants to merge 7 commits into
main fromrefs/pull/8353/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- apps/server/src/cloud/http.ts lines 463 to 463OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -433,4 +445,19 @@433445 message: "Invalid managed endpoint origin.",434446 });435447 }436- const proof = yield* makeCloudLinkProof(dependencies, request, requestUrl);448+ let proofRequest = request;449+ let proofRequestUrl = requestUrl;450+ if (request.endpoint.providerKind === "cloudflare_tunnel") {451+ const server = yield* HttpServer.HttpServer;452+ if (453+ server.address._tag !== "TcpAddress" ||454+ !hasAllowedEndpointOriginHost({ origin: request.origin, requestUrl })455+ ) {456+ return yield* new EnvironmentHttpBadRequestError({457+ message: "Invalid managed endpoint origin.",458+ });459+ }460+ proofRequest = {461+ ...request,462+ origin: {463+ localHttpHost: "127.0.0.1",
- @@ -2005,0 +2105,21 @@2105+ const { port: forwardedPort } = yield* openTcpForward(serverPort);2106+ const linkProofResponse = yield* fetchEffect(2107+ `http://127.0.0.1:${forwardedPort}/api/connect/link-proof`,2108+ {2109+ method: "POST",2110+ headers: { "content-type": "application/json" },2111+ body: jsonRequestBody({2112+ challenge: "relay-link-challenge",2113+ relayIssuer: "https://relay.example.test",2114+ endpoint: {2115+ httpBaseUrl: `http://127.0.0.1:${forwardedPort}`,2116+ wsBaseUrl: `ws://127.0.0.1:${forwardedPort}/ws`,2117+ providerKind: "cloudflare_tunnel",2118+ },2119+ origin: {2120+ localHttpHost: "127.0.0.1",2121+ localHttpPort: forwardedPort,2122+ },2123+ }),2124+ },2125+ );
juliusmarminge added labelsmacroscope-review
maria-rcks closed this
Sign in to join this conversation.


No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
8838f626-0829-4ba5-bc8c-aa442cba66e5📥 Commits
Reviewing files that changed from the base of the PR and between 3ac23f2bdba233d6e762743223796197853b5a45 and b44cd3248325ebce0f0d5f9bdeeceda782daa0bd.
📒 Files selected for processing (1)
apps/server/src/server.test.tsIncluded review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
📝 Walkthrough
Walkthrough#
The server now derives Cloudflare tunnel link proofs from its bound TCP listener. It separates loopback host checks from port checks and rejects unsupported listener addresses. Tests cover wildcard and IPv6 mappings, forwarded requests, and authentication.
Changes#
Cloudflare tunnel origin handling
apps/server/src/cloud/http.tsmanagedTunnelOriginForAddressmaps wildcard listeners to loopback hosts and rejects non-loopback or non-TCP addresses. Cloudflare tunnel proofs use the resolved host and listener port.apps/server/src/cloud/http.test.ts,apps/server/src/server.test.tsEstimated code review effort: 3 (Moderate) | ~20 minutes
Merge Risk: ⚪ Minimal · up to
b44cdManaged tunnel proofs now use the server’s listener host and port while preserving authentication and loopback protections, with focused regression tests covering forwarded ports and IPv6 behavior. No actionable merge-blocking risk remains after normal checks and review.
Suggested reviewers:
juliusmarminge,t3dotgg🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)#
✅ Passed checks (4 passed)
#7458by deriving managed Cloudflare tunnel proof origins from the active T3 listener host and port. Regression tests cover forwarded ports and listener mappings.✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment `@coderabbitai help` to get the list of available commands.