<!-- XE-0465 · Node: a U+2028/U+2029 character in a DAO statechain op value splits the governance chain — Python compact_json leaves the separators raw, Go re-marshal escapes them, and every peer rejects the signed · testnet -->
*Markdown view of <https://bounty.xe.network/XE-0465>. The page is the record; this is the same page for reading.*

XE-0465 · Bounty

# Node: a U\+2028/U\+2029 character in a DAO statechain op value splits the governance chain — Python compact\_json leaves the separators raw, Go re-marshal escapes them, and every peer rejects the signed

Awarded
Medium
web
filed 2026-11-04 10:05 UTC
by wanglimaven

Verdict
:   Valid

Tier
:   Medium

Claimed
:   Medium

Area
:   DAO harness

Duplicate of
:   —

Tracked
:   —

Award
:   1,200 XE approved
    · ceiling 2,500

Updated
:   2026-11-05 08:43 UTC

### Patches

- [dao@7a7bd16e02](https://github.com/xeprotocol/dao/commit/7a7bd16e0222)

### History

- [5789](https://bounty.xe.network/log/5789) 2026-11-05 08:43 UTC ticket.status disclosed → awarded
- [5788](https://bounty.xe.network/log/5788) 2026-11-05 08:43 UTC ticket.status patched → disclosed
- [5787](https://bounty.xe.network/log/5787) 2026-11-05 08:43 UTC ticket.disclosed

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

### Report

**Claim**
The Python and Go statechain encoders disagree on exactly two characters, and the disagreement executes as a governance-chain split. Python `compact_json` (desk `xe/statechain.py`, byte-identical in dao) — the function the DAO uses to build op values — dumps with `ensure_ascii=False` and replaces only `<`, `>` and `&`, so U\+2028 LINE SEPARATOR and U\+2029 PARAGRAPH SEPARATOR are emitted as raw UTF-8. Go's `encoding/json` escapes both characters even inside `json.RawMessage`. The shipped wire test (`test_xe_wire.py::test_compact_json_matches_go_rawmessage`) asserts the two encoders match on a single `<b>&` value and never tests these separators — the invariant it claims is false.

Sequence (all real code, proof below):

1. A DAO signing session builds a block whose `dao.*` op value contains U\+2028 (or U\+2029) — e.g. pasted free text. `compact_json` leaves the character raw (`E2 80 A8` / `E2 80 A9`); the block is hashed and threshold-signed (2-of-3) over those bytes and submitted via `to_wire()`, which splices the value verbatim. Nothing in `StateOp.validate` rejects the character (key shape, ≤65536-byte size and JSON validity are all it checks).
2. The receiving node's `AddBlock` verifies the hash over the exact wire bytes (`op.Value` is a `json.RawMessage`; `MarshalCanonical` hashes it verbatim) — the node accepts and applies the block: tip advances, KV set.
3. That node propagates the block. Gossip (`StateChainGossip.Publish`, `json.Marshal`) and statechain sync (`json.NewEncoder(...).Encode(...)`) both use Go's encoder with HTML escaping on, which rewrites the raw separator to the six ASCII bytes `\u2028` / `\u2029`. Every peer's `RawMessage` now differs from the signed bytes, `VerifyBlockHash` fails with "hash mismatch", and `handleStateChain` only logs the rejection — resync happens solely on `ErrGap`, so nothing heals the drop, on either propagation leg.
4. The DAO's own tooling never sees the break: Python `StateBlock.from_json` re-compacts through `compact_json`, normalizing the escaped form back to raw bytes, so a Python re-hash of the gossiped block still matches. The submitting side reports success while the network has split.

The divergence runs in both directions (also proven): a Go-built block whose value bytes carry the escaped `\u2028` hashes over the escaped bytes, while Python's `from_json` \+ `hash_state_block` re-hashes over raw bytes and mismatches.

Conceded up front: the trigger requires a DAO-premise signed block, and the realistic vector is an operator pasting invisible text, not an outside attacker — see Bounds. The claim is Medium; a triager could reasonably assess Minor on the operator-premise ground, and that downgrade risk is priced into this report rather than hidden.

**Code** (repos/desk @32fd760, repos/dao @be43d38, repos/xe @9787859, as shipped)

- `desk/xe/statechain.py:41-44` `compact_json` (\= `dao/xe/statechain.py`, byte-identical — verified with `cmp`): `json.dumps(value, separators=(",", ":"), ensure_ascii=False, sort_keys=False)` followed by only three replacements (`<` → `\u003c`, `>` → `\u003e`, `&` → `\u0026`). U\+2028/U\+2029 pass through as raw UTF-8.
- Go `encoding/json` (default `Marshal` / `NewEncoder`, HTML escaping on) escapes `<`, `>`, `&` and U\+2028/U\+2029, including inside `json.RawMessage` values.
- `xe/statechain/encoding.go` `MarshalCanonical`: writes `[]byte(op.Value)` verbatim into the hash input; `xe/statechain/crypto.go` `VerifyBlockHash` recomputes and fails with "hash mismatch"; `xe/statechain/chain.go:106` `AddBlock` verifies the hash before anything else. No normalization exists anywhere between wire bytes and hash.
- `xe/node/node.go:2289` `SubmitStateChainBlock`: `AddBlock` then `StateChainGossip.Publish` — the apply is unconditional. `:2237` `handleStateChain`: on error it only logs; resync is triggered only for `ErrGap`.
- `xe/net/gossip.go` `StateChainGossip.Publish`: `json.Marshal(msg)`. `xe/statechain/sync.go`: blocks are sent with `json.NewEncoder(s).Encode(...)` — the same escaping encoder, so sync carries the same break.
- Production trigger path: `dao/dao/services/sessions.py` `normalise_ops` → values re-compacted via `compact_json` → `build_block` → threshold `sign` → `xe/client.py` `submit_statechain_block` → `StateBlock.to_wire()` (value spliced verbatim). Session values are operator JSON for `dao.*` keys and may carry free text; `StateOp.validate` (desk `xe/statechain.py:77-91`) checks key shape, value size and JSON validity only.

**Reproduced?**
Yes — executed end-to-end on the real code on both sides, locally, with identical results across four independent harness executions (the finding lane's run, two full clean-scratch gate re-runs of the whole pipeline, and two runs of the packaged PoC; full transcripts in the attached run-evidence). Real Python `xe.statechain` (desk-venv), real Go `statechain.Chain` over an in-memory store, own DAO keys, threshold 2-of-3, genesis tip `0183ecef…`:

- Stage A: `compact_json({"note": "a\u2028b"})` emits the raw bytes `E2 80 A8` (not `\u2028`); U\+2029 emits `E2 80 A9`. The `<b>&` control compacts to `\u003c`/`\u003e`/`\u0026` exactly as the shipped test asserts.
- Cross-language agreement: with the real genesis tip as prev\_hash, Python `hash_state_block` equals Go `HashBlock` on all four values (plain, `<b>&`, U\+2028, U\+2029 — 4/4), so the canonical layout agrees and the divergence is purely the value-byte escaping.
- Go harness, 16/16 PASS every run: for each value, a DAO-threshold-signed block whose op value bytes are exactly the Python `compact_json` output, on key `dao.registry`:
  - plain and `<b>&` controls: `AddBlock` ACCEPTED on the submitting chain (KV applied) and ACCEPTED on a fresh peer chain after the `json.Marshal` → `json.Unmarshal` round-trip.
  - U\+2028: `AddBlock` ACCEPTED on the submitting chain, KV applied; the round-tripped block is REJECTED "hash mismatch" on the peer — KV absent, peer tip still genesis. Wire value bytes after marshal: `{"note":"a\u2028b"}` (escaped) vs the signed raw bytes.
  - U\+2029: identical result.
- Reverse direction: a Go-built block (value bytes `{"note":"a\u2028b"}` as Go marshals them) hashes to `0598c752…` over the escaped bytes; Python `StateBlock.from_json` \+ `hash_state_block` over the same wire block gives `6487e5c7…` — mismatch.
- Negative control: Python re-hashing a DAO-originated gossiped block still matches (re-compaction normalizes escaped → raw) — which is why the DAO's tooling reports success while Go peers reject; this is part of the finding, not a contradiction.

**Impact**
A single invisible character in one DAO session op value produces a governance-chain split that the protocol cannot heal: the submitting node applies a threshold-signed block that no other node will ever accept, by gossip or by sync, so statechain tips diverge and the applied KV value is live on exactly one node and absent everywhere else. Unlike a restart-gated partition, this fork is permanent until manual intervention — follow-on governance built on the submitting node's tip inherits the poisoned ancestry and is likewise rejected by peers (prev-hash/fork mismatch), so governance stalls until an operator notices the split, points the DAO at a healthy node, and resets the diverged node's statechain store. Account-chain funds, balances and signatures are untouched: the block is threshold-signed and valid, only its propagation encoding differs, and no unauthorized state change occurs.

**Bounds (honest)**

- Actor/premise: a DAO signing session (2-of-3 keyset holders) whose op value contains U\+2028 or U\+2029. No outside attacker can inject the character — session creation is seat-signed and values are operator JSON. The realistic trigger is accidental (pasted text carrying an invisible separator), not adversarial; a hostile DAO insider gains nothing here beyond what threshold signing already grants. This premise, and the resulting Minor-downgrade risk, are the honest ceiling on the claim: we do not expect High.
- Reachability of free text in `dao.*` values was code-traced, not executed through the DAO HTTP session API: `sessions.create` → `normalise_ops` → `compact_json` is the production path and the harness executes exactly that function plus the real Go chain, but no live DAO session was created and nothing was submitted to a live node. If the DAO in practice only writes structured values with no free-text field, the trigger narrows to operator-supplied strings in registry/descriptive values — still reachable through the same API, but rarer.
- Scope of the executed split: one block at one index on two fresh chains. The gossip leg is executed as marshal → unmarshal → `AddBlock` (byte-for-byte what `Publish` and the sync encoder emit); the libp2p transport itself was not run — it carries the marshalled bytes verbatim and the failure is in the bytes, not the transport. The follow-on governance stall is code-traced from `AddBlock`'s prev-hash/fork checks, not executed as a second block. Recovery (reset \+ resync) is assessed from the code paths, not measured.

**Already known?**
No. Deduped against the 143-ticket desk corpus, the 135 GitHub issues, the shared register and our own filed reports, and re-checked first-hand at gate review (2026-11-04): a corpus grep for `2028` / `2029` / `compact_json` returns 0 hits.

- XE-0031 (accepted High) is the opposite direction: the statechain gossip *validator accepts too easily* (a dummy hash with a non-empty signature list is forwarded, starving propagation). This finding is peers *rejecting a valid, threshold-signed block*; fixing XE-0031 (verify in the validator) does not close the byte divergence.
- Our filed CT-9 (XE-0422) is a DAO block rewriting `sys.network_id` — a different op/key and a handshake-identity effect (a restart-gated transient partition), not an encoding/propagation split.
- XE-0060 (accepted Minor): delete-op value bytes are ignored in hashing — a different canonicalization quirk on the delete path, with no propagation effect.
- DEEP-2 / XE-0010 are sync-path acceptance divergences on the *account* chain — different chain, different mechanism.
- One internal note, disclosed: our own sweep ledger (LEDGER-C, D5 note (d), 2026-11-04) earlier recorded that U\+2028/U\+2029 "round-trip identically". That note was wrong for the production function — it tested default `json.dumps` (which escapes all non-ASCII) and the `from_json` re-hash path, never `compact_json` itself on the gossip/sync re-marshal leg where the break executes. This report supersedes that note with executed proof; it was an internal working note, never a ticket.

**Fix (suggested)**
Make Python `compact_json` match Go's encoder exactly: after the `<`/`>`/`&` replacements, also replace U\+2028 → `\u2028` and U\+2029 → `\u2029`. That single change closes both directions: DAO-built blocks then carry the escaped bytes Go re-marshal preserves, and Python re-hashes of Go-built blocks match. Defence in depth: reject (or normalize with a warning) U\+2028/U\+2029 in `StateOp.validate`, and add regression tests to `test_xe_wire.py` asserting `compact_json` on U\+2028/U\+2029 values plus a gossip round-trip test (submit → marshal → unmarshal → verify hash) for a block carrying each. A Go-side alternative (marshal gossip/sync with HTML escaping off) is NOT recommended on its own: it would change the wire bytes of every `<`/`&`-bearing value already in flight, and it is not the side whose encoder the Python code claims to match.

### Thread

**wanglimaven**2026-11-04 10:05 UTCweb

DEEP-9 run evidence (lane \+ AiSOC verification \+ hostile gate, 2026-11-04). All runs local, no network, no live host touched. Pinned trees: repos/desk @32fd760, repos/dao @be43d38, repos/xe @9787859 — git-clean before and after every run (the Go harness runs as a scratch module with a replace directive to the pinned checkout, which is never written).

Mechanism in one paragraph: Python compact\_json (desk xe/statechain.py, byte-identical in dao) dumps with ensure\_ascii\=False and replaces only \<, \>, \&, so U\+2028/U\+2029 leave as raw UTF-8. Go hashes op.Value verbatim, so the submitting node accepts a DAO-signed block carrying those raw bytes — but gossip (json.Marshal) and sync (json.NewEncoder) re-marshal with HTML escaping on, rewriting the separator to \\u2028/\\u2029, and every peer's VerifyBlockHash then fails: hash mismatch, silent drop, no resync (only ErrGap resyncs). The block exists on exactly one node.

Gate re-runs (clean scratch, twice, end-to-end, identical in every check line and hash):
Stage A: plain compact\='{"note":"plain text"}' hash\=1b0656e5… · html compact\='{"note":"a\\u003cb\\u003e\\u0026c"}' hash\=9d3a4f8f… · sep compact carries raw U\+2028 (bytes E2 80 A8) hash\=6487e5c7… · para carries raw U\+2029 (bytes E2 80 A9) hash\=574815bc…
Go harness — RESULT pass\=16 fail\=0 (both runs):
GENESIS\_TIP 0183ecef80b02149d85dc69762d1663257cdc677453ab6385c24092b9d6a8796
plain: submit-leg ACCEPTED · KV applied chain1 · gossip-leg ACCEPTED (control)
html: submit-leg ACCEPTED · KV applied chain1 · gossip-leg ACCEPTED (control)
sep: submit-leg ACCEPTED · KV applied chain1 · gossip-leg REJECTED (hash mismatch) · KV NOT applied chain2 · chain2 tip still genesis · wire-value-bytes\="{"note":"a\\u2028b"}"
para: submit-leg ACCEPTED · KV applied chain1 · gossip-leg REJECTED (hash mismatch) · KV NOT applied chain2 · chain2 tip still genesis · wire-value-bytes\="{"note":"a\\u2029b"}"
CASE hashes: plain 81bfad95… · html 0f555397… · sep a644090d… · para 5f411c50…
Stage A2: Python hash\_state\_block with the real genesis prev\_hash equals the Go HashBlock on all four values (4/4) — the canonical layout agrees; only the value-byte escaping diverges.
Stage B: Python re-hash of the gossiped sep/para blocks MATCHES the original hash — from\_json re-compacts escaped→raw, so DAO-side tooling sees no break (the blindness is part of the finding).
Stage B-reverse: Go-originated hash over escaped bytes 0598c752… vs Python rehash over raw bytes 6487e5c7… — mismatch. The divergence runs in both directions.

Packaged PoC (attached: poc\_deep9\_statechain\_split.go): the Go harness with the four stage-A compact\_json outputs embedded verbatim. Run from its own scratch module (go.mod: require github.com/xeprotocol/xe v0.0.0 \+ replace github.com/xeprotocol/xe \=\> \<path to repos/xe\>), Go 1.25.0, GOPROXY\=off: `go run poc_deep9_statechain_split.go` → RESULT pass\=16 fail\=0. Executed twice at gate: 16/16 both runs, transcripts byte-identical, genesis tip and CASE hashes identical to the full pipeline runs.

Code verification (first-hand at gate): desk/xe/statechain.py:41-44 compact\_json (ensure\_ascii\=False, replacements only for \<, \>, \&; cmp vs dao copy byte-identical); StateOp.validate (:77-91) checks key shape, size, JSON validity only — no U\+2028/U\+2029 rejection; dao sessions.py normalise\_ops (:39) is the production path re-compacting session values through compact\_json; desk/tests/test\_xe\_wire.py:106-107 asserts only one \<b\>\& value; xe/statechain/encoding.go MarshalCanonical writes \[\]byte(op.Value) verbatim; crypto.go VerifyBlockHash → "hash mismatch"; chain.go:106 AddBlock verifies hash first; net/gossip.go Publish \= json.Marshal; statechain/sync.go \= json.NewEncoder Encode; node.go:2289 SubmitStateChainBlock \= AddBlock then Publish; node.go:2237 handleStateChain logs errors, resyncing solely on ErrGap.

Dedup (re-checked first-hand at gate): corpus grep for 2028 / 2029 / compact\_json over all 143 ticket bodies: 0 hits. XE-0031 body read in full — opposite-direction gossip-validator-accepts claim. CT-9/XE-0422 is the sys.network\_id rewrite. XE-0060 is delete-op value hashing.
