{"id":"XE-0115","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"194","source_url":"https://github.com/xeprotocol/xe/issues/194","reporter_id":22,"title":"sdk: stringifyWithBigInts marker collision — a memo of \"__bigint__<digits>\" is sent as a JSON number, not a string","area":null,"claimed_tier":"minor","assessed_tier":null,"verdict":"duplicate","duplicate_of":"XE-0008","tracked":false,"internal_ref":"","internal_url":"","status":"closed","closed_reason":"duplicate","github_state":"closed","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-10-29T13:57:29.271845+00:00","updated_at":"2026-11-10T00:11:33.992348+00:00","source_created_at":"2026-10-29T13:28:39+00:00","told_at":"2026-11-05T22:24:21+00:00","status_changed_at":"2026-11-05T22:24:09.300485+00:00","url":"https://bounty.xe.network/XE-0115","body":"**Suggested tier:** Minor. SDK (`xeprotocol/sdk`), `src/json.ts`. Client-side robustness bug, verified with a PoC.\n\n> Distinct from #87: that is the parse/schema side (uint64 read as a JS integer). This is the stringify/write side — a marker collision in the SDK's own `stringifyWithBigInts`, independent of the OpenAPI typing.\n\n## Summary\n`stringifyWithBigInts` serializes bigints by replacing them with a plaintext marker `__bigint__<digits>` inside a JSON string, then regex-unquoting `\"__bigint__<digits>\"` back to a bare number. The marker is user-reachable: a `send`/`burn` **memo** equal to `__bigint__<digits>` collides with it, so the memo goes onto the wire as a JSON **number** instead of a string, producing malformed block JSON the node rejects.\n\nNote the asymmetry: the parse side (`parseLossless`) deliberately uses a raw-NUL marker (`\\u0000xe-u64:`) *because* a NUL cannot appear in a JSON string literal, and it has a collision-resistance test. The stringify side uses a guessable ASCII marker with no such protection and no collision test.\n\n## PoC (Node, exact copy of the function)\n```js\nfunction stringifyWithBigInts(value) {\n  const marked = JSON.stringify(value, (_k, v) => typeof v === 'bigint' ? `__bigint__${v.toString()}` : v)\n  return marked.replace(/\"__bigint__(-?\\d+)\"/g, '$1')\n}\nstringifyWithBigInts({ type:'send', balance:100n, amount:25n, memo:'__bigint__999' })\n// => {\"type\":\"send\",\"balance\":100,\"amount\":25,\"memo\":999}   // memo is now a NUMBER\n```\nReachability: `client.ts:174` sends the request body via `stringifyWithBigInts`; `client.ts:419` puts `block.memo` into the wire object. The memo `__bigint__999` is valid UTF-8, 13 bytes, so `marshalCanonical` signs it correctly — only the JSON wire form corrupts, and the node rejects a number in the string `memo` field.\n\n## Impact\nMinor. `memo` is the only user-reachable field that can hit the marker (hex fields can't equal it). No funds at risk and no effect on other users — the sender's own `send`/`burn` with such a memo silently fails.\n\n## Suggested fix\nMirror the parse side: use a collision-proof sentinel on stringify, or track which keys were bigint in the replacer instead of pattern-matching text. Add a stringify collision test for a memo of `__bigint__123`.\n\n## Reward address\n618d0f48a31ab36aaa8eb30d7c757c242b9a08fad7c602ed638f81537ce0d4f8","patch_refs":[],"thread":[{"id":517,"source":"github","source_ref":"6671117591","author":"Joseph Denne","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, reply with what differs and we will look again.","created_at":"2026-11-05T22:24:21+00:00"}]}