fix(mcp): sessionId loses precision in JavaScript JSON consumers
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- javascript, json
- 領域
- api
調査の方向性
The report identifies structuredContent.openItem.sessionId in the GUI MCP server response, but the server implementation is shipped inside the proprietary application and no source file or test is named. Start by locating the code that builds the bn_binary_view_set_active response and checking how it serializes sessionId; reproduce with an identifier above JavaScript’s safe-integer limit. Done means JavaScript can recover the exact identifier while opaque handle selection still works.
索引モデルが issue の本文から書いたものです。
説明
Summary
The GUI MCP server emits structuredContent.openItem.sessionId as a bare JSON integer above JavaScript's safe-integer range. Parsing the raw HTTP reply with JSON.parse changes its exact integer value. This is an interoperability defect in emitted metadata, not a claim that the JSON syntax is invalid or that opaque openItem handles stop working.
Steps to reproduce
- Save the C source below as
fixture.c, compile it, and openfixturein Binary Ninja. Enable and start the built-in GUI MCP server, then connect an MCP client and runtools/list.
#include <stdio.h>
volatile int fixture_global = 7;
__attribute__((noinline, used)) int fixture_leaf(int value) { puts("FIXTURE_LEAF"); return value + fixture_global; }
__attribute__((noinline, used)) int fixture_branch(int value) { return value > 3 ? fixture_leaf(value) : fixture_leaf(-value); }
int main(int argc, char **argv) { return fixture_branch(argc); }
clang -arch arm64 -O0 -g -fno-inline fixture.c -o fixture
-
Call
bn_binary_view_list, select the returned Mach-O view withbn_binary_view_set_active, and wait untilbn_analysis_statusreportsIdleState. Use the returned handle unchanged; handle values are session-scoped. -
Capture a raw HTTP reply from
bn_binary_view_set_activebefore a JavaScript JSON parser touches it. The following Python standard-library script initializes a separate MCP connection, retainsMCP-Session-Id, lists tools and views, selects the returned Mach-O handle, and saves the response bytes asreply.raw. Run it in a disposable directory while the fixture is open. It does not execute the target or save a database.
import json
import urllib.request
from pathlib import Path
url = "http://127.0.0.1:24642/mcp"
headers = {"Content-Type": "application/json", "Accept": "application/json, text/event-stream"}
def send(method, params=None, request_id=1):
message = {"jsonrpc": "2.0", "method": method}
if request_id is not None:
message["id"] = request_id
if params is not None:
message["params"] = params
request = urllib.request.Request(url, json.dumps(message).encode(), headers)
with urllib.request.urlopen(request) as response:
return response.headers, response.read()
def decode(raw):
text = raw.decode()
if text.startswith(("event:", "data:")):
text = "\n".join(line[5:].strip() for line in text.splitlines() if line.startswith("data:"))
return json.loads(text)
response_headers, _ = send("initialize", {"protocolVersion": "2025-11-25", "capabilities": {}, "clientInfo": {"name": "repro", "version": "1"}})
headers["MCP-Session-Id"] = response_headers["MCP-Session-Id"]
send("notifications/initialized", request_id=None)
send("tools/list", {})
_, listing = send("tools/call", {"name": "bn_binary_view_list", "arguments": {}})
text = decode(listing)["result"]["content"][0]["text"]
rows = [[cell.strip() for cell in line.strip().strip("|").split("|")] for line in text.splitlines() if line.startswith("|")]
handle = next(row[0] for row in rows if row[2] == "Mach-O")
_, raw = send("tools/call", {"name": "bn_binary_view_set_active", "arguments": {"binaryView": handle}})
Path("reply.raw").write_bytes(raw)
- Run this JavaScript against those saved bytes. It isolates the numeric token in
structuredContentand compares its exact integer value with the already-parsed JavaScript number, without publishing the generated identifier.
const fs = require('fs');
const raw = fs.readFileSync('reply.raw', 'utf8');
const json = raw.startsWith('event:') || raw.startsWith('data:')
? raw.split('\n').filter(line => line.startsWith('data:')).map(line => line.slice(5).trim()).join('\n')
: raw;
const token = json.match(/"structuredContent"[\s\S]*?"sessionId"\s*:\s*(\d+)/)[1];
const id = JSON.parse(json).result.structuredContent.openItem.sessionId;
console.log('raw sessionId above MAX_SAFE_INTEGER:', BigInt(token) > BigInt(Number.MAX_SAFE_INTEGER));
console.log('Number.isSafeInteger(parsed):', Number.isSafeInteger(id));
console.log('BigInt(parsed) === BigInt(raw):', BigInt(id) === BigInt(token));
Expected behavior
An identifier exposed to MCP JSON clients should retain its exact value through supported JSON consumption. The guide explicitly formats output addresses as strings to avoid losing 64-bit precision, but does not document a precision-loss exception for sessionId. RFC 8259 section 6 describes the interoperable exact-integer range for binary64 consumers; it does not prohibit larger JSON number tokens.
Actual behavior
Raw HTTP bytes confirmed that the property was a bare decimal JSON number, not a quoted decimal string. The generated value exceeded Number.MAX_SAFE_INTEGER. The JavaScript check printed:
raw sessionId above MAX_SAFE_INTEGER: true
Number.isSafeInteger(parsed): false
BigInt(parsed) === BigInt(raw): false
The text field of the same response contained the original digits inside its JSON-encoded string, and bn_open_item_list displayed those digits in its Markdown table. The loss occurs when parsing the numeric structuredContent field with JavaScript's normal JSON parser. This was observed for one disposable fixture's generated identifier; frequency across other identifiers is unmeasured. Generated identifier values and local paths are intentionally omitted from this public report.
Evidence
- Expected source: JSON interoperability guidance above and the MCP guide's output-address precision convention, linked under Runtime or environment;
sessionIdhas no separate documented precision contract. - Failure source: Raw HTTP response bytes from the view-selection tool and the executed JavaScript token-versus-parsed-integer comparison shown above.
- Evidence provenance: observed
- Local verification: reproduced
- Reproduction completeness: complete
Restoration check
Capture the same response before JSON parsing and verify that a normal JavaScript JSON consumer can recover the exact emitted identifier value. Include a generated identifier above the binary64 safe-integer range as a control; passing only with a smaller identifier would not cover the observed failure. Preserve normal opaque-handle selection behavior.
Runtime or environment
- Binary Ninja Version: Free 6.0.10905-Stable; bundle version
6.0.10905_free; built-in GUI HTTP MCP serverbinaryninja_ui_mcpversion0.1.0. - Edition: Free. OS: macOS 27.2; CPU architecture: arm64. Target: thin arm64 Mach-O built with the command above. Analysis status was
IdleStatebefore the observations. - The official stable release metadata matched the installed build. A fresh profile enabled
ui.mcp.enabled; no user plugins or existing databases were involved. The target was analyzed, never executed, and no database was saved. - The stable MCP guide and the current default-branch MCP guide were compared. Their relevant calling conventions agree. The implementation ships inside the proprietary application, so public default-branch source inspection does not verify its runtime behavior.
- The issue template requests development-build testing. That was not performed: Free cannot switch to the development channel. Personal/Commercial editions, development builds, Windows, and Linux are untested.
Triage assessment
- Impact level: P2
- Assessment status: supported
- Impact basis: Normal JavaScript JSON consumption silently changes the exact identifier in structured metadata for the observed value. No failed handle operation, collision, database corruption, or analysis error was observed.
- Workaround status: available
- Workaround basis: The exact digits remained in the reply's text string and in the open-item list's Markdown table; a client can preserve them as text. Python's arbitrary-precision JSON parser also retained the raw integer. These avoid the observed numeric precision loss without changing the binary or server.
- 主要言語
- C++
- スター
- 1.3k
- フォーク
- 304
- 平均マージ
- 2日 20時間
- マージ済み PR(30日)
- 10
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Vector35/binaryninja-api のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 84/100
Vector35/binaryninja-api#8715 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Vector35/binaryninja-api#8714 ·
メンテナーはふだん 2 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
Vector35/binaryninja-api#8713 ·
メンテナーはふだん 2 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 78/100
Vector35/binaryninja-api#8689 ·
メンテナーはふだん 2 日以内に返信
-
Component: Python API
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
Vector35/binaryninja-api#8649 ·
メンテナーはふだん 2 日以内に返信
Vector35/binaryninja-api の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
ESPresense/ESPresense#2680 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1時間未満 初心者へのやさしさ 75/100
stew675/llama-cpp-rdna-boosts#348 ·
メンテナーはふだん 1 日以内に返信
-
Documentation: Add comprehensive newcomer onboarding guide, project structure, and local usage to README対応中かも @Ash-Blanc が今日担当しました。 オープンarea/other status/bot-triaged status/need-triage
難易度 2/5 半日 初心者へのやさしさ 85/100
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信