DefaultJsonSchemaValidator: caching by $id alone can validate tool input against another tool's schema
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 72/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- java, json
調査の方向性
Read generateCacheKey() in mcp-json-jackson2/src/main/java/io/modelcontextprotocol/json/schema/jackson2/DefaultJsonSchemaValidator.java and its Jackson 3 counterpart. First inspect how each validator builds and uses its cache key, then reproduce the issue with two schemas sharing $id but having different properties or required fields. Done means both modules distinguish different schema documents and validation behaves correctly for each; the issue does not name test files.
索引モデルが issue の本文から書いたものです。
説明
Summary
DefaultJsonSchemaValidator uses the optional JSON Schema $id field as the sole cache key when present. Unlike the hashCode() collision case (#1328), two different schema documents that share the same $id URI will share one compiled Schema instance. Tool B's tools/call arguments may then be validated against Tool A's schema.
Affected code
mcp-json-jackson2/src/main/java/io/modelcontextprotocol/json/schema/jackson2/DefaultJsonSchemaValidator.java—generateCacheKey()mcp-json-jackson3/src/main/java/io/modelcontextprotocol/json/schema/jackson3/DefaultJsonSchemaValidator.java—generateCacheKey()
When $id is present, the cache key is String.valueOf(schema.get("$id")) with no hash of the schema body.
Steps to reproduce
- Register two tools on an MCP server (or unit-test the validator directly) with identical
$idbut differentproperties/requiredininputSchema. - Call
validate(toolB.inputSchema(), argumentsValidForBButInvalidForA). - Observe validation outcome depends on which schema was compiled and cached first.
Expected behavior
Cache keys must uniquely identify the full schema document (content-based hash, canonical JSON, or composite key $id + content hash). Different documents must never share a compiled schema even if $id matches.
Actual behavior
First registered/compiled schema wins for that $id; later tools with the same $id may get wrong validation.
Impact
Incorrect accept/reject of tool arguments; security-relevant when validation is used as a gate before handler execution.
Related
- #1328 —
hashCode()fallback cache key collision (orthogonal but same component)
Environment
- Modules:
mcp-json-jackson2,mcp-json-jackson3 - Logic present on current
main/ 2.2.x line
- 主要言語
- Java
- スター
- 3.8k
- フォーク
- 1.1k
- 平均マージ
- 1日 3時間
- マージ済み PR(30日)
- 38
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
modelcontextprotocol/java-sdk のほかの issue
-
Modern `HttpServletMcpTransport` does not check `Mcp-Name` when `params.name` or `params.uri` is not a JSON string対応中かも @starryeye が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
modelcontextprotocol/java-sdk#1352 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Unknown tool error always says "Unknown tool: invalid_tool_name" instead of the name that was calledオープン
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
modelcontextprotocol/java-sdk#1346 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
modelcontextprotocol/java-sdk#1345 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Tool result _meta is lost when the server automatically adds text content for structured outputオープンarea/server legacy P3
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
modelcontextprotocol/java-sdk#1330 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Client request handlers that complete empty send no JSON-RPC response対応中かも @1fanwang が 83 日前に担当しました。 オープンarea/client bug P2
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
modelcontextprotocol/java-sdk#1124 · コメント 6 件 ·
メンテナーはふだん 1 日以内に返信
modelcontextprotocol/java-sdk の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
crash
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
-
account bug course exam iris lecture
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信