Skip to content

CIMD: support private_key_jwt (ChatGPT dev-mode apps blocked) #118

Closed

Description

@BorisTyshkevich

Symptom

ChatGPT dev-mode apps cannot authenticate against any altinity-mcp broker-mode deployment post-#115. /oauth/authorize rejects with:

{"error":"invalid_client","error_description":"unknown OAuth client"}

Pod log:

DBG OAuth /authorize rejected: CIMD resolution failed
  error="cimd: invalid metadata document: token_endpoint_auth_method must be \"none\" (got \"private_key_jwt\")"
  client_id=https://chatgpt.com/oauth/kDmjx77UnKOM/client.json

Root cause

#115 (cmd/altinity-mcp/cimd.go::parseCIMDMetadata) hardcodes token_endpoint_auth_method == "none" as the only accepted value. This matches claude.ai's CIMD doc but not ChatGPT's. ChatGPT publishes:

{
  "client_id": "https://chatgpt.com/oauth/<id>/client.json",
  "client_uri": "https://chatgpt.com/",
  "redirect_uris": ["https://chatgpt.com/connector/oauth/<id>"],
  "grant_types": ["authorization_code","refresh_token"],
  "response_types": ["code"],
  "client_name": "ChatGPT",
  "token_endpoint_auth_method": "private_key_jwt",
  "token_endpoint_auth_signing_alg": "RS256",
  "jwks_uri": "https://chatgpt.com/oauth/jwks.json"
}

ChatGPT uses RFC 7523 §2.2 private_key_jwt: it signs a client_assertion JWT with its private key, server verifies via the published JWKS. Strictly more authentication than none+PKCE — not less. Our blanket rejection is wrong.

Spec references

  • RFC 7591 §2 — token_endpoint_auth_method registered values include private_key_jwt.
  • RFC 7523 §2.2 — JWT bearer client authentication.
  • RFC 7521 §4.2 — client_assertion/client_assertion_type params at token endpoint.
  • MCP authorization 2025-11-25 explicitly allows CIMD clients to declare private_key_jwt.

Scope

cmd/altinity-mcp/cimd.go

  1. Add JWKSURI string \json:"jwks_uri"`andTokenEndpointAuthMethodtocimdMetadata`.
  2. Accept either none (PKCE-only public client) or private_key_jwt (with jwks_uri non-empty + URL-validated same way as CIMD client_id URL — https only, SSRF-safe IP, IDNA-clean host).
  3. Reject client_secret_* methods (we never have a client secret).
  4. Surface auth method + JWKS URI on statelessRegisteredClient.

cmd/altinity-mcp/oauth_server.go

  1. At /oauth/token, if the resolved CIMD client uses private_key_jwt:
    • Require client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer.
    • Require client_assertion form param.
    • Parse JWT header, look up kid in the CIMD client's JWKS (fetched SSRF-safely; cache reuses cimdCache pattern but separate keyspace, e.g. jwks:<jwks_uri>).
    • Verify signature with the matching JWK.
    • Validate claims: iss == sub == client_id, aud includes our /oauth/token URL, exp not expired, nbf if present, iat within window, jti for replay (short in-memory cache, TTL = exp - now + 60s — matches recommendation in RFC 7523 §3 ¶10).
  2. Maintain existing none path unchanged for claude.ai.

Tests (cmd/altinity-mcp/cimd_test.go + new oauth_private_key_jwt_test.go)

  • CIMD doc parse: none accepted, private_key_jwt w/ jwks_uri accepted, private_key_jwt w/o jwks_uri rejected, client_secret_basic rejected.
  • /token with valid client_assertion → success; tampered signature → 401; expired → 401; wrong aud → 401; replay → 401.

E2E

  • Repeat the 2026-05-15 claude.ai E2E matrix on otel-google-mcp / otel-google-gating-mcp / antalya-mcp / github-mcp (confirm no regression for none+PKCE).
  • Add ChatGPT side: create dev-mode app pointing at each MCP, OAuth flow, execute_query SELECT currentUser(), 1+1.

Out of scope

  • DPoP (separate auth_method, separate spec, ChatGPT doesn't use it today).
  • client_secret_jwt (we have no shared secret with the client).
  • Server-initiated revocation list / dynamic JWKS rotation — TTL-based cache invalidation matches what we already do for CIMD docs.

Affected deployments

All four production broker-mode MCPs (post-#115):

  • otel-google-mcp (forward)
  • otel-google-gating-mcp (gating + broker_upstream)
  • github-mcp (gating + broker_upstream)
  • antalya-mcp (forward)

claude.ai keeps working on all four — only ChatGPT is blocked.

Detection

User reported the failing URL from a fresh ChatGPT dev-mode app:

https://otel-google-36be80-mcp.demo.altinity.cloud/oauth/authorize?...&client_id=https%3A%2F%2Fchatgpt.com%2Foauth%2FkDmjx77UnKOM%2Fclient.json&...

Verified the CIMD doc lives at that URL (HTTP 200, JSON, 485 bytes) — issue is purely on our parser/validator side.

Activity

  1. added a commit that references this issue on May 15, 2026
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions