Repository navigation
Description
Bug description
EmbeddedAuthServerConfig has two layers of validation for confidential-client transport safety, and they disagree. The Go layer deliberately permits a loopback http:// issuer together with delegateClients when insecureAllowConfidentialOverLoopbackHTTP is set. The CEL admission rule rejects that combination unconditionally, so the Go layer never runs and the supported path is unreachable through the operator.
The CEL rule (cmd/thv-operator/api/v1beta1/mcpexternalauthconfig_types.go:495):
!has(self.delegateClients) || size(self.delegateClients) == 0 || !self.issuer.startsWith('http://')
The Go check it shadows (pkg/authserver/config.go:1486-1488) explicitly returns nil for exactly this case:
if insecureAllowConfidentialOverLoopbackHTTP {
return nil
}And the CRD's own comment (:504-511) says the divergence is intentional, and that the CEL side is the compromise — not the security position:
This is stricter than the Go-level ValidateConfidentialClientTransport, which still permits a loopback-HTTP issuer with delegate clients when InsecureAllowConfidentialOverLoopbackHTTP is set — intentionally, since that flag's loopback-is-safe rationale applies equally to delegate-client secrets. Do not tighten the Go-level check to match this CEL rule; the CRD is stricter only because CEL cannot express the loopback exception, not because delegate clients need one.
The effect is that insecureAllowConfidentialOverLoopbackHTTP — a documented, first-class CRD field with a +kubebuilder:default=false and its own rationale in the field docs (:670-683) — cannot be used with delegateClients at all, which is the case its own doc comment describes.
Why this matters
There is no way to exercise RFC 8693 delegation on a local/Kind cluster:
- the CEL rule requires a non-
http://issuer, and - vMCP cannot terminate TLS itself.
pkg/vmcp/server/server.go:752-783builds a plainhttp.Serverovernet.Listen; there is noListenAndServeTLS, no CRD TLS listener field, and no vMCP CLI TLS flag (cmd/vmcp/app/commands.go:113-116ishost/port/enable-audit/session-ttl). The operator also hardcodes anhttp://status URL (cmd/thv-operator/controllers/virtualmcpserver_controller.go:2279).
So a local operator must stand up a separate HTTPS reverse proxy carrying the whole auth-server origin (/.well-known/*, /oauth/authorize, /oauth/token, /oauth/register, /oauth/callback, plus /mcp) purely to satisfy an admission rule that the runtime would have waived.
Reproduction
ToolHive v0.44.0 (operator image ghcr.io/stacklok/toolhive/operator:v0.44.0, charts toolhive-operator-0.44.0 / toolhive-operator-crds-0.44.0), Kind.
authServerConfig:
issuer: http://127.0.0.1:18080
insecureAllowConfidentialOverLoopbackHTTP: true
delegateClients:
- clientId: mecak8s-delegate
clientSecretRef: {name: vmcp-delegate-auth, key: client-secret}
scopes: [openid, email]
audiences: ["http://127.0.0.1:18080/mcp"]Rejected at admission by the CEL rule, regardless of the flag.
Note the failure is ordering-dependent and easy to misread: with the flag absent but CEL bypassed, the runtime check surfaces as a status condition rather than an admission error — AuthServerConfigValidated=False / AuthServerConfigInvalid, phase Failed:
spec.authServerConfig: allow_confidential_client_registration cannot be combined
with a plain-HTTP loopback issuer ("http://127.0.0.1:18080") unless
insecure_allow_confidential_over_loopback_http is set
That message names the flag the CRD will not let you combine with delegateClients.
Confirmed working once admission is bypassed
Patching the CEL rule cluster-locally and setting the flag, the whole path works correctly — this is a reachability gap, not a functional one. The delegate client registers (pkg/authserver/server_impl.go:247 warn fires), discovery begins advertising client_secret_basic/client_secret_post alongside none, and an RFC 8693 exchange against a self-issued subject token returns a correctly attenuated token (sanitized):
{
"act": { "iss": "http://127.0.0.1:18080", "sub": "mecak8s-delegate" },
"sub": "<end user, carried from the subject token>",
"client_id": "mecak8s-delegate",
"aud": ["http://127.0.0.1:18080/mcp"],
"scp": ["openid", "email"]
}Scope narrowed from the subject token's [openid profile email offline_access] to the delegate's configured ceiling, audience bound to the delegate's audiences, actor chain recorded in act, and exp clamped to the subject token's own expiry rather than the configured access-token lifespan.
Expected behavior
delegateClients with a loopback http:// issuer and insecureAllowConfidentialOverLoopbackHTTP: true should be admitted, matching the Go layer's documented intent.
Suggested fix: move this check into a validating webhook, which can parse the URL properly and apply the same networking.IsLocalhost test the runtime uses.
Please do not implement this as a CEL prefix match. Something like self.issuer.startsWith('http://127.0.0.1') also matches http://127.0.0.1.evil.com, which is exactly the hazard the current comment cites as the reason not to attempt a CEL loopback exception. That approach would turn an inconvenience into a real bypass. (We used precisely that patch as a throwaway local workaround, which is safe only because it never leaves a disposable Kind cluster.)
Current workaround
Either patch the CRD's CEL rule in-cluster — reverted by any helm upgrade, and unsafe to generalize per the note above — or run an HTTPS reverse proxy in front of vMCP carrying the full auth-server origin.
Scope
- Affects only
delegateClientswith a loopbackhttp://issuer; HTTPS issuers and non-loopback hosts are unaffected and should stay rejected. - The shared
EmbeddedAuthServerConfigtype means the rule is enforced at admission for bothMCPExternalAuthConfig.spec.embeddedAuthServerandVirtualMCPServer.spec.authServerConfig(:488-492), so both are affected. - Successor to Token-exchange grant is unreachable: no way to provision a confidential client #6082 (token-exchange grant unreachable — no way to provision a confidential client).
delegateClientsresolved that generally; this is the remaining gap for loopback development.
Activity
Allow loopback delegate clients (stacklok#6426)