Bounty
XE-0064 · Bounty

openapi: uint64 fields (timestamp, pow_nonce) typed as plain integer exceed 2^53; generated JS clients corrupt them and cannot verify block hashes (Medium)

Accepted claimed Medium xe#87 filed 2026-10-26 21:28 UTC by BoomGone

Report

  • Suggested tier: Medium ("inconsistent API responses"), may be seen as related to #13
  • Area: openapi.json field typing; every read endpoint that returns blocks
  • Found: 2026-10-26, node xe/92d83d1, openapi.json 1.0.0

Summary

Block timestamp (unix nanoseconds, about 1.79e18) and pow_nonce (up to 2^64-1) always exceed JavaScript's Number.MAX_SAFE_INTEGER (2^53-1 = 9007199254740991). The OpenAPI document types them as plain {"type": "integer"} with no format: int64, no string representation, and no warning, and the API returns them as bare JSON numbers. Any client generated from the contract, or any client using standard JSON.parse, silently corrupts these values.

Because timestamp and pow_nonce are both inputs to the block hash preimage (core/encoding.go), a standard JS client that reads a block and tries to verify or re-derive its hash gets the wrong bytes and cannot verify ANY block. The official SDK avoids this only by shipping a custom lossless (bigint) JSON parser; the documented contract gives no signal that this is required.

Evidence

Live value from GET /blocks/recent: "timestamp":1793041910652017920, "pow_nonce":2032484613864776222.

JSON.parse('{"timestamp":1793041910652017920,"pow_nonce":2032484613864776222}')
// -> timestamp 1793041910652018000   (wrong: last digits lost)
// -> pow_nonce 2032484613864776200   (wrong)

Spec (openapi.json 1.0.0, schema Block):

timestamp -> {"type":"integer","description":"Block time as unix nanoseconds."}
pow_nonce -> {"type":"integer","description":"Proof-of-work nonce ..."}
balance   -> {"type":"integer","minimum":0, ...}      // micro-units; can exceed 2^53 for large holdings
amount    -> {"type":"integer", ...}

No format: int64, no type: string, no note. A typical generator emits number for integer, so the corruption is silent.

Impact

  • Every non-SDK JS consumer of the API corrupts timestamp and pow_nonce on every block, and balance/amount once they pass 2^53 micro-units.
  • Block hash verification is impossible for such a client, since the corrupted timestamp/nonce change the preimage. This defeats the point of exposing the fields.
  • #13 (explorer rounds pow_nonce) is one downstream symptom of this same contract defect; this report is the contract-level cause plus the hash-verification consequence.
  • No fund risk.

Suggested fix

  • Mark these fields format: int64 and, better for JSON, serialise uint64 fields as strings (as many chains do) or document that clients MUST use a lossless parser. Whichever is chosen, the contract should signal it so generated clients do not silently corrupt data.

Payout

XE address: 6591eab453dbd93b27e2cd674712f94b42d9e7e4d52980b966fa6da4ccd832dc (same as #75).

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