Skip to content

VirtualMCPServer ignores MCPOIDCConfig.caBundleRef — CA is mounted but never read #4918

Closed

Description

@danbarr

Summary

When a VirtualMCPServer references an MCPOIDCConfig whose spec.inline.caBundleRef points at a ConfigMap holding a custom CA, the operator mounts the CA into the pod but never tells the vmcp binary where it is. OIDC discovery against an issuer fronted by a self-signed CA consequently fails with:

tls: failed to verify certificate: x509: certificate signed by unknown authority

The analogous path for MCPServer was fixed in #3142 / #3391 — the vMCP converter wasn't updated at the same time. Reproduced on operator v0.21.0.

Expected

ThvCABundlePath is auto-computed by the resolver (as it is for MCPServer) and rendered into the vMCP config so the incoming-OIDC middleware trusts the supplied CA.

Actual

The vMCP OIDCConfig struct has no CA-bundle field, and the vMCP converter silently drops resolved.ThvCABundlePath. The volume mount at /config/certs/<configmap-name>/<key> lands on the pod but nothing reads it.

Code references (tag v0.21.0)

  • pkg/vmcp/config/config.go:203-252 — OIDCConfig struct defines Issuer, ClientID, ClientSecretEnv, Audience, Resource, JWKSURL, IntrospectionURL, Scopes, ProtectedResourceAllowPrivateIP, JwksAllowPrivateIP, InsecureAllowHTTP — no CACertPath / ThvCABundlePath / CABundlePath.
  • cmd/thv-operator/pkg/vmcpconfig/converter.go — mapResolvedOIDCToVmcpConfigFromRef (around line 237+) never references resolved.ThvCABundlePath.
  • cmd/thv-operator/controllers/virtualmcpserver_deployment.go:300-308 — the operator does correctly add the volume via AddOIDCConfigRefCABundleVolumes.
  • cmd/thv-operator/pkg/controllerutil/oidc_volumes.go:17-57 — mount path is /config/certs/<configmap-name>/<key>.

Compare to the working MCPServer path: cmd/thv-operator/controllers/mcpserver_runconfig.go correctly plumbs resolvedOIDCConfig.ThvCABundlePath into RunConfig → TokenValidatorConfig.CACertPath (pkg/runner/config_builder.go:453,470).

Minimal reproduction

Issuer with a self-signed CA (e.g. a kind cluster behind Traefik using a *.traefik.me cert):

apiVersion: toolhive.stacklok.dev/v1alpha1
kind: MCPOIDCConfig
metadata:
  name: example-oidc
  namespace: toolhive-system
spec:
  type: inline
  inline:
    issuer: https://auth.example.internal/realms/demo
    caBundleRef:
      configMapRef:
        name: example-ca   # holds ca.crt
        key: ca.crt
    jwksAllowPrivateIP: true
---
apiVersion: toolhive.stacklok.dev/v1alpha1
kind: VirtualMCPServer
metadata:
  name: example-vmcp
  namespace: toolhive-system
spec:
  groupRef:
    name: some-group
  incomingAuth:
    type: oidc
    oidcConfigRef:
      name: example-oidc
      audience: example-audience
  outgoingAuth:
    source: inline
  serviceType: ClusterIP

The vmcp pod comes up, mounts /config/certs/example-ca/ca.crt, but the rendered incomingAuth.oidc section of the operator-produced config ConfigMap contains no CA-path field, and the binary errors on the first OIDC discovery fetch.

Suggested fix

Mirror the MCPServer change: add a CACertPath (or ThvCABundlePath) field to pkg/vmcp/config/config.go's OIDCConfig, plumb resolved.ThvCABundlePath through mapResolvedOIDCToVmcpConfigFromRef, and have the vMCP incoming-OIDC middleware pass it to its HTTP client when discovering the issuer / fetching JWKS.

Workarounds

None via CRD config. Options are:

  • insecureAllowHTTP: true with a plaintext issuer (not useful if the issuer uses OIDC's browser-redirect flows over HTTPS).
  • Publicly-trusted cert for the issuer (not available in offline / demo setups).

Context

Surfaced while wiring Keycloak → LibreChat → vmcp-chat end-to-end authentication in our demo-sandbox. Happy to test a fix.

Activity

  1. added
    bug
    vmcp
    on Apr 17, 2026
  2. added a commit that references this issue on Apr 17, 2026
    ee0b7a9
  3. added a commit that references this issue on Jul 25, 2026
    8fc7109
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

    authenticationbugoperatorsecurityvmcp

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions