fix(mcp): sessionId loses precision in JavaScript JSON consumers
Les mainteneurs répondent en général sous 2 jours
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 48/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- Active
- Stack technique
- javascript, json
- Domaine
- api
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- C++
- Étoiles
- 1.3k
- Forks
- 304
- Merge moyen
- 2 j 20 h
- PR mergées (30 j)
- 10
Préparer son environnement
Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de Vector35/binaryninja-api
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 84/100
Vector35/binaryninja-api#8715 ·
Les mainteneurs répondent en général sous 2 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Vector35/binaryninja-api#8714 ·
Les mainteneurs répondent en général sous 2 jours
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 85/100
Vector35/binaryninja-api#8713 ·
Les mainteneurs répondent en général sous 2 jours
-
Difficulté 1/5 1-3 heures Accessibilité débutants 78/100
Vector35/binaryninja-api#8689 ·
Les mainteneurs répondent en général sous 2 jours
-
Component: Python API
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
Vector35/binaryninja-api#8649 ·
Les mainteneurs répondent en général sous 2 jours
Toutes les issues de Vector35/binaryninja-api
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 80/100
ESPresense/ESPresense#2680 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 Moins d'une heure Accessibilité débutants 75/100
stew675/llama-cpp-rdna-boosts#348 ·
Les mainteneurs répondent en général sous 1 jour
-
Documentation: Add comprehensive newcomer onboarding guide, project structure, and local usage to READMEPeut-être pris @Ash-Blanc l’a pris aujourd’hui. Ouvertearea/other status/bot-triaged status/need-triage
Difficulté 2/5 Une demi-journée Accessibilité débutants 85/100
-
bug
Difficulté 1/5 Moins d'une heure Accessibilité débutants 85/100
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour