`OpenIdProviderDiscoveryMetadataSchema` strips `revocation_endpoint`, so clients can't revoke against OIDC-only authorization servers

Đang mở Phù hợp với người mới
#3,213 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@marcus-beauregard đang làm issue này rồi.

Từ ngày 19/11/2026.

  • #3214 của @marcus-beauregard — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
api, authentication

Hướng nghiên cứu

Bắt đầu tại src/shared/auth.ts, ở OpenIdProviderDiscoveryMetadataSchema, rồi so sánh với OpenIdProviderMetadataSchema và OAuthMetadataSchema. Tái hiện lần parse được báo cáo với revocation_endpoint để xác nhận những trường nào bị loại bỏ. Công việc hoàn tất khi schema discovery OpenID giữ lại endpoint thu hồi được công bố và lỗi hồi quy được bao phủ bằng một bài kiểm thử.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

v1 v2

Summary

When authorization server metadata comes from OpenID Connect discovery, parsing it with OpenIdProviderDiscoveryMetadataSchema silently drops revocation_endpoint, along with any other RFC 8414 field that isn't declared. A client that later looks for revocation_endpoint concludes the server doesn't support revocation, even though the discovery document lists it.

Where

src/shared/auth.ts in @modelcontextprotocol/sdk 1.32.2 (with zod 4.6.7):

export const OpenIdProviderDiscoveryMetadataSchema = z.object({
    ...OpenIdProviderMetadataSchema.shape,
    ...OAuthMetadataSchema.pick({
        code_challenge_methods_supported: true
    }).shape
});
  • OpenIdProviderMetadataSchema is a z.looseObject, but spreading .shape into a plain z.object drops the loose behaviour. In zod v4, unknown keys are stripped.
  • OpenIdProviderMetadataSchema doesn't declare revocation_endpoint.
  • The only OAuth metadata field picked in is code_challenge_methods_supported.
  • So the parsed result never contains revocation_endpoint.

Impact

Some authorization servers publish metadata only through OpenID discovery and return an error for the RFC 8414 paths. Amazon Cognito is one. Against those servers, clients built on the SDK never revoke on logout.

We see this in Claude Code 2.1.328: claude mcp logout <server> deletes the local credentials but logs Server does not support token revocation, and no revoke request reaches the server. The discovery document does list revocation_endpoint.

By contrast, anthropics/claude-code#105134 reports that logout does send revoke requests for servers that serve RFC 8414 metadata. That fits this being specific to the OpenID discovery path.

Repro

import { OpenIdProviderDiscoveryMetadataSchema, OAuthMetadataSchema } from "@modelcontextprotocol/sdk/shared/auth.js";

const doc = {
  issuer: "https://issuer.example.com",
  authorization_endpoint: "https://issuer.example.com/oauth2/authorize",
  token_endpoint: "https://issuer.example.com/oauth2/token",
  jwks_uri: "https://issuer.example.com/.well-known/jwks.json",
  response_types_supported: ["code"],
  subject_types_supported: ["public"],
  id_token_signing_alg_values_supported: ["RS256"],
  code_challenge_methods_supported: ["S256"],
  revocation_endpoint: "https://issuer.example.com/oauth2/revoke",
};

console.log(OpenIdProviderDiscoveryMetadataSchema.parse(doc).revocation_endpoint); // undefined
console.log(OAuthMetadataSchema.parse(doc).revocation_endpoint);                   // "https://issuer.example.com/oauth2/revoke"

(Run against 1.32.2: the first line prints undefined, the second prints the URL.)

Suggested fix

Either:

  • keep unknown keys, by building the schema with z.looseObject({...}) or .loose(); or
  • spread the optional RFC 8414 fields that OpenID discovery documents commonly carry, such as revocation_endpoint, introspection_endpoint and revocation_endpoint_auth_methods_supported.

Related: #2733 and #2734 (the same schema, about over-strict validation rather than dropped fields), and the closed #739 (a client revocation helper).

Ngôn ngữ chính
TypeScript
Star
13.8k
Fork
2.5k
Merge trung bình
6 ngày 23 giờ
Pull request đã merge (30 ngày)
2

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của modelcontextprotocol/typescript-sdk

Tất cả issue của modelcontextprotocol/typescript-sdk

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.