<!-- XE-0115 · sdk: stringifyWithBigInts marker collision — a memo of "__bigint__<digits›" is sent as a JSON number, not a string · testnet -->
*Markdown view of <https://bounty.xe.network/XE-0115>. The page is the record; this is the same page for reading.*

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](https://github.com/xeprotocol/xe/issues/194)
filed 2026-10-29 13:28 UTC
by cryptoloser8-coder

Verdict
:   Duplicate

Tier
:   —

Claimed
:   Minor

Area
:   —

Duplicate of
:   [XE-0008](https://bounty.xe.network/XE-0008) accepted

Tracked
:   —

Updated
:   2026-11-10 00:11 UTC

Told
:   2026-11-05 22:24 UTC

### Patches

None linked.

### History

- [10476](https://bounty.xe.network/log/10476) 2026-11-05 22:24 UTC github.state\_pushed
- [10475](https://bounty.xe.network/log/10475) 2026-11-05 22:24 UTC github.labels
- [10461](https://bounty.xe.network/log/10461) 2026-11-05 22:24 UTC reply.mirrored
- [10457](https://bounty.xe.network/log/10457) 2026-11-05 22:24 UTC reply.sent
- [10456](https://bounty.xe.network/log/10456) 2026-11-05 22:24 UTC proposal.adopted
- [10455](https://bounty.xe.network/log/10455) 2026-11-05 22:24 UTC proposal.adopted
- [10454](https://bounty.xe.network/log/10454) 2026-11-05 22:24 UTC ticket.status new → closed
- [10453](https://bounty.xe.network/log/10453) 2026-11-05 22:24 UTC proposal.adopted
- [10452](https://bounty.xe.network/log/10452) 2026-11-05 22:24 UTC ticket.facts
- [10451](https://bounty.xe.network/log/10451) 2026-11-05 22:24 UTC proposal.adopted
- [10450](https://bounty.xe.network/log/10450) 2026-11-05 22:24 UTC ticket.facts
- [7967](https://bounty.xe.network/log/7967) 2026-11-05 14:02 UTC proposal.created

[Full history](https://bounty.xe.network/log?ref=XE-0115) · [JSON](https://bounty.xe.network/v1/tickets/XE-0115) · [markdown](https://bounty.xe.network/XE-0115.md)

### 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 Denne**team2026-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.
