Bounty
XE-0115 · Bounty

sdk: stringifyWithBigInts marker collision — a memo of "__bigint__<digits>" is sent as a JSON number, not a string

Closed · duplicate —claimed Minor xe#194 filed 2026-10-29 13:28 UTC by cryptoloser8-coder

Report

Suggested tier: Minor. SDK (xeprotocol/sdk), src/json.ts. Client-side robustness bug, verified with a PoC.

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.

Summary

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.

Note 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.

PoC (Node, exact copy of the function)

function stringifyWithBigInts(value) {
  const marked = JSON.stringify(value, (_k, v) => typeof v === 'bigint' ? `__bigint__${v.toString()}` : v)
  return marked.replace(/"__bigint__(-?\d+)"/g, '$1')
}
stringifyWithBigInts({ type:'send', balance:100n, amount:25n, memo:'__bigint__999' })
// => {"type":"send","balance":100,"amount":25,"memo":999}   // memo is now a NUMBER

Reachability: 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.

Impact

Minor. 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.

Suggested fix

Mirror 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.

Reward address

618d0f48a31ab36aaa8eb30d7c757c242b9a08fad7c602ed638f81537ce0d4f8

Thread

Joseph Denneteam2026-11-05 22:24 UTCgithub

Thanks. This is the same finding as https://bounty.xe.network/XE-0008, which was filed first; the programme pays the first verifiable submission, so this one closes as a duplicate. If you believe it is a different bug, reply with what differs and we will look again.