Bounty
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 filed 2026-10-26 21:18 UTC by rusdiwireng

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

Alicomm2026-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).