Skip to content

Paginated nextLink leaks the RP's cluster-internal address, breaking any out-of-cluster client #12837

Closed

Description

@nithyatsu

Bug

nextLink on a paginated LIST response leaks the serving RP's cluster-internal address, so any client that is not inside the cluster cannot follow it.

Observed from a GitHub Actions runner talking to a k3d control plane through the Kubernetes API-server proxy:

Error: Get "http://dynamic-rp.radius-system:8082/planes/radius/local/resourcegroups/default/providers/Radius.Compute/containers?api-version=2025-08-01-preview&skipToken=MjAyNi0wOC0xOVQyMjo1MjoyNi4zNjc5MDha&top=10": dial tcp: lookup dynamic-rp.radius-system on 127.0.0.53:53: no such host

The first page succeeds over the proxied connection. The second page fails, because rad follows the returned absolute URL verbatim and dynamic-rp.radius-system is not resolvable outside the cluster.

Practical impact: rad app delete fails during resource enumeration, before anything is deleted, for any application with more than one page of resources of a single type (top=10 by default). The application is left undeletable. This is not delete-specific though — it affects any paginated LIST for any non-in-cluster caller.

Root cause

GetNextLinkURL builds the link from the inbound request, and GetURLFromReqWithQueryParameters takes the host straight from req.Host:

https://github.com/radius-project/radius/blob/main/pkg/armrpc/frontend/controller/util.go

func GetURLFromReqWithQueryParameters(req *http.Request, qps url.Values) *url.URL {
	url := url.URL{
		Host:     req.Host,
		Scheme:   req.URL.Scheme,
		Path:     req.URL.Path,
		RawQuery: qps.Encode(),
	}
	...
}

When UCP proxies a LIST downstream to an RP, req.Host as seen by that RP is the internal service address (dynamic-rp.radius-system:8082), not the address the caller used. So the emitted nextLink is only valid from inside the cluster.

The caller-visible host is already available

UCP's proxy forwards the original host and scheme downstream — see pkg/ucp/proxy/testdata/arm/basic-roundtrip/downstream-request.json:

{
  "url": "http://example.com/some-path?query=yes",
  "method": "GET",
  "headers": {
    "X-Forwarded-Host": ["ucp.example.com"],
    "X-Forwarded-Proto": ["http"],
    "traceparent": ["traceid"]
  },
  "body": ""
}

GetURLFromReqWithQueryParameters simply ignores them.

Suggested fix

Prefer X-Forwarded-Host / X-Forwarded-Proto when present, falling back to req.Host and the existing default scheme. That fixes the link for every RP and every paginated LIST in one place, with no change required in the CLI.

An alternative (or additional) mitigation is to have the CLI re-base a returned nextLink onto the workspace's connection endpoint rather than dialing it directly, which would also harden the client against a misconfigured RP.

Repro

  1. Model an application with more than 10 resources of the same type (e.g. 10+ Radius.Compute/containers).
  2. Deploy it to a cluster where the control plane is reached through the API-server proxy rather than from inside the cluster.
  3. Run rad app delete <name> --yes --preview.
  4. The second page of the container listing is dialed at http://dynamic-rp.radius-system:8082/... and fails DNS resolution.

Originally reported downstream as radius-project/ai-extensions#441.

Related

  • A workflow-level mitigation for the delete workflows (aliasing the control-plane services onto loopback before the delete) is being proposed separately in .github/extension/actions/delete-resource. That unblocks the delete path only; this issue tracks the actual leak.

Activity

  1. added
    bug
    on Aug 26, 2026
  2. radius-triage commented on Aug 26, 2026

    @radius-triage

    👋 @nithyatsu Thanks for filing this bug report.

    A project maintainer will review this report and get back to you soon. If you'd like immediate help troubleshooting, please visit our Discord server.

    For more information on our triage process please visit our triage overview

  3. nithyatsu commented on Aug 26, 2026

    @nithyatsu
    ContributorAuthor

    Correcting the root-cause analysis in the issue description

    My original write-up said the fix was to have the resource provider build the nextLink from X-Forwarded-Host. That is wrong on two counts, and I want the corrected analysis recorded here before anyone picks this up.

    1. The RP cannot know its client-facing identity.

    UCP sets X-Forwarded-Host from its own inbound host (pkg/ucp/proxy/types.go → SetXForwarded()). When the CLI reaches UCP through the aggregated APIService, the Kubernetes aggregator has already thrown the original host away:

    // k8s.io/apiserver/pkg/util/proxy/proxy.go
    newReq.Host = location.Host   // the ucp Service address

    That is kubernetes/kubernetes#107435 — the exact bug pkg/sdk/connection_location.go already documents. So honoring the header only swaps dynamic-rp.radius-system:8082 for the UCP service address. Both are in-cluster; an external client can reach neither.

    2. RPs are not a client-facing surface.

    Only UCP is exposed to a CLI, so the follow-up page must go back through UCP. Any fix that makes the client dial the RP directly (for example aliasing the RP's in-cluster DNS name on the client) is routing around plane resolution and is not viable.

    The mechanism that already exists

    UCP fixes up response URLs for exactly this reason, in two stages:

    1. UCP, on the way out — ProcessAsyncOperationHeaders (pkg/ucp/proxy/async.go) rebuilds Location / Azure-AsyncOperation from the Referer header, which UCP sets at pkg/ucp/frontend/controller/radius/proxy.go:220 from its inbound host and full path. That restores the /apis/api.ucp.dev/v1alpha3 path base and the /planes/<type>/<name> prefix the RP never sees.
    2. Client, on the way in — locationRewriteRoundTripper (pkg/sdk/connection_location.go) rebases the host onto the client's real endpoint, because Referer only carries UCP's inbound host.

    nextLink gets neither, purely because it lives in the response body instead of a header. That is the whole bug.

    Fix

    Give nextLink the same two-stage treatment:

    • a responder alongside ProcessAsyncOperationHeaders that rewrites nextLink in the JSON body, reusing the existing rewriteHeader path logic
    • extend locationRewriteRoundTripper to rebase nextLink's host as it already does for Location

    This keeps pagination flowing through UCP and fixes external clients generally, not just CI.

    For the record: #12839 (make the runner dial the RP directly) and #12841 (honor X-Forwarded-Host in the RP) were both wrong and are closed.

  4. added a commit that references this issue on Aug 27, 2026
    c152409
  5. added a commit that references this issue on Sep 3, 2026
    24bb9ec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions