<!-- XE-0062 · The web DAO tool signs a hash over the op value as typed and then submits a different byte string · testnet -->
*Markdown view of <https://bounty.xe.network/XE-0062>. The page is the record; this is the same page for reading.*

XE-0062 · Bounty

# The web DAO tool signs a hash over the op value as typed and then submits a different byte string

Accepted
claimed Minor
[xe#85](https://github.com/xeprotocol/xe/issues/85)
filed 2026-10-26 21:18 UTC
by rusdiwireng

Verdict
:   published when the fix ships

Tier
:   published when the fix ships

Claimed
:   Minor

Area
:   SDK / docs / web

Duplicate of
:   —

Tracked
:   internally

Updated
:   2026-11-10 11:38 UTC

Told
:   2026-11-10 00:15 UTC

### Patches

- [xe#119](https://github.com/xeprotocol/xe/pull/119) open by arturbarszcz78
  fix(web/dao): normalize op value JSON at draft time to match submitted bytes (#85)

### History

- [72431](https://bounty.xe.network/log/72431) 2026-11-10 10:34 UTC note.added
- [61392](https://bounty.xe.network/log/61392) 2026-11-10 00:15 UTC reply.mirrored
- [61349](https://bounty.xe.network/log/61349) 2026-11-10 00:15 UTC reply.sent
- [17830](https://bounty.xe.network/log/17830) 2026-11-07 16:08 UTC proposal.adopted
- [17829](https://bounty.xe.network/log/17829) 2026-11-07 16:08 UTC ticket.award
- [17828](https://bounty.xe.network/log/17828) 2026-11-07 16:08 UTC proposal.rejected
- [6894](https://bounty.xe.network/log/6894) 2026-11-05 13:45 UTC proposal.created
- [1819](https://bounty.xe.network/log/1819) 2026-11-02 19:16 UTC proposal.created
- [1473](https://bounty.xe.network/log/1473) 2026-11-02 10:11 UTC note.added
- [783](https://bounty.xe.network/log/783) 2026-10-29 14:22 UTC note.added
- [782](https://bounty.xe.network/log/782) 2026-10-29 14:22 UTC ticket.facts area
- [632](https://bounty.xe.network/log/632) 2026-10-29 14:05 UTC github.labels

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

### Report

Suggested severity tier: Minor

Summary:
The DAO page in the embedded web UI builds a statechain draft with the op value kept as the exact string the member typed, and it hashes that string. At submit time the tool parses the value as JSON and sends the block after a JSON.stringify of the parsed form. Parsing and restringifying normalises whitespace, number forms such as 2.0 and 1e2, and string escapes. The node recomputes the statechain block hash over the value bytes it receives, so the received hash differs from the signed hash, and the node rejects a block that already carries its threshold signatures.

Evidence:

- web/assets/dao.js, lines 232 to 245: the draft keeps the typed string as the op value, and the draft hash is computed over it.
- web/assets/dao.js, lines 386 to 395: at submit, the value is replaced with JSON.parse of the typed string inside a block sent through JSON.stringify.
- web/assets/statechain-block.js, lines 35 to 52: encodeOp writes the value as the typed string, byte for byte.
- statechain/encoding.go, lines 46 to 55: for a set operation, the value bytes enter the canonical hash preimage as the raw string.
- statechain/chain.go: AddBlock starts with VerifyBlockHash, so the mismatch is rejected before signature checks.
- A proof of concept script that imports the repository file web/assets/statechain-block.js is available on request. Typed values 2, {"x":1}, and "abc" produce a signed hash equal to the received hash. Typed values with surrounding spaces, 2.0, { "x": 1 } with spaces, and a string containing a \\u0062 escape all produce a mismatch.

Impact:
A DAO member who pastes pretty printed JSON, which is the natural way to paste a keyset or tokenomics value, collects signatures over a hash the network will never accept and learns about it only at submit. The signatures are wasted and the operation has to be drafted again. A workaround exists: type the value as exact compact JSON. That workaround is why this draft suggests Minor.

Suggested fix:
Normalise the value once at draft time in dao.js and submit exactly the bytes that were hashed. Parsing the value and restringifying it before the hash is computed, then sending that same string, removes the mismatch.

### Thread

**XE desk**team2026-11-10 00:15 UTCgithub

Read and accepted. It is tracked internally and the fix will land in a public PR; this issue is
updated when it does, and the tier and award follow the fix. The desk entry is https://bounty.xe.network/XE-0062.

**Alicomm**2026-11-11 17:32 UTCgithub

Still reproduces at HEAD 89a542e.

`onGenerateHash` stores the op value exactly as typed, and `encodeOp` hashes `TextEncoder().encode(op.value)`. `onSubmitBlock` sends `value: JSON.parse(o.value)`, re-serialized by `serializeBlockJson` via `JSON.stringify`. The node stores `Op.Value` as `json.RawMessage` (exact bytes received) and `MarshalCanonical` hashes `[]byte(op.Value)`.

So the browser and the node hash different bytes whenever the typed JSON is not already in `JSON.stringify(JSON.parse(value))` form.

Local proof (no network, Node replication of `encodeOp` \+ SHA-256):

- Typed `{ "x": 1 }` → browser op-hash `4946226573f6cc15f69d7e1be96b98d159622f6ab20e4899263145ddae8a4e5b`
- Submitted `{"x":1}` → node op-hash `1444b8756c41421bc5d16d7ca67bd058f06c744ef88146297ec0af41436b12a3`
- Mismatch → the node rejects the block with a hash mismatch. Control `{"x":1}` (already canonical) matches.

Any value whose typed form differs from its canonical form fails: whitespace, `1.0` vs `1`, unicode escapes, etc.

Suggested fix: canonicalize before hashing — hash `JSON.stringify(JSON.parse(op.value))` in `onGenerateHash` (or submit the raw typed string verbatim).
