`asBigInt` lets plain `Error`s escape the typed client accessors on malformed numeric fields
Report
Title
asBigInt lets plain Errors escape the typed client accessors on malformed numeric fields
Summary
Every typed client accessor funnels node-supplied numerics through
asBigInt (src/json.ts), which throws a bare Error ("field: expected an integer, got …") on a non-integer value. That plain
Error propagates unchanged out of balances(), pending(),
certificate(), lease(), and — by code-reading, same helper —
toProvider, toEpoch, timekeepers(), requestAttestation() and
latestEpoch()'s index read. The SDK's error taxonomy (XeError →
XeApiError / XeTransportError / XeUsageError) is the contract
callers code against: isRetryable() only recognises XeApiError
and XeTransportError, Xe.rentLease and holdLease's retry logic
branch on instanceof XeApiError, and XeClient.request() only
retries isRetryable errors. A malformed numeric field therefore
produces an error that is invisible to every one of those handlers —
it is neither retryable-classified nor usage-classified, it is just a
raw Error with no status, no retryable flag, and no body.
Impact
- Typed-error contract broken on the malformed-response path.
A node (or a proxy/malicious node — the SDK already has to assume
node responses may be hostile, cf. SDK-2) returning e.g.
{"balances":{"XE":"abc"}}makesbalances()throw a plainError; the same for a non-integerpending.Amount, certificateprice_multiplier_milli, or leasecost. Callers that catchXeError— as the SDK's ownrentLease/waitForLease/holdLeasecode does — miss it, and retry logic cannot classify it. - Scope limit (stated plainly). The failure is fail-closed (the call throws; nothing is signed on a garbage value) and the trigger needs a malformed response. No funds move and no wrong value is used.
Severity reasoning
- Minor, not Low: the defect is in the error taxonomy itself —
the same class as DAO-12 (
_unwrapraises rawJSONDecodeError) and DAO-13 (Signer.loadlets raw errors escape), both filed as Minor — and it affects at least four public accessors plus the shared record mappers. But it is fail-closed and needs malformed input.
Root cause
src/json.ts asBigInt throws a bare Error instead of an
XeError subclass, and none of its call sites (toMap in
balances(), pending(), toCertificate's big(),
toLeaseRecord's big(), toProvider, toEpoch,
requestAttestation, timekeepers, latestEpoch) wraps it.
Reproduction
Harness /tmp/sdk-r5/verify.mjs (section F), mock fetch only. Run
from the built SDK:
cd ~/workspace/xe-bounty/sdk
node /tmp/sdk-r5/verify.mjs
Observed output:
PASS F-balances-plain-error PLAIN:Error
PASS F-pending-plain-error PLAIN:Error
PASS F-certificate-plain-error PLAIN:Error
PASS F-lease-plain-error PLAIN:Error
PASS F-control-good-balances XE=5
What the run shows: a non-integer numeric in each of the four
responses makes the accessor throw a plain Error (not an
XeError); well-formed responses still parse normally.
Dedup note
Checked against the public ticket list (186 public tickets, max
XE-1799, snapshot 2026-11-09 ~14:19 WIB; title sweep). No title match
for asBigInt, plain errors escaping, or malformed numeric fields in
the SDK. Closest reports:
- XE-1774 (DAO-12) —
XeClient._unwrapraises a rawJSONDecodeErroron garbage JSON. Same class (raw error escaping a typed taxonomy), different codebase (DAO Python client) and trigger (unparsable body vs non-integer field). - XE-1779 (DAO-13) —
Signer.loadlets corrupt-keyfile errors escape as raw exceptions. Same class, different codebase. - XE-0057 — node errors are
{"error": string}but response schemas are the objectErrorshape. About the node's error shape, not the SDK throwing plainErrors on bad numerics.
No known report covers this SDK defect. Private/sealed tickets are invisible, so a sealed duplicate cannot be ruled out.
Suggested fix direction
- Make
asBigIntthrowXeApiError(status 200, non-retryable, body attached) or a dedicatedXeErrorsubclass, so every accessor's malformed-response failure is classifiable byisRetryableand catchable asXeError. Alternatively wrap the calls at each accessor — fixing it inasBigIntcloses the whole class at once.
Payout address
052e33e0ed9c43e2bdf07faff9a90d25642b51d53d96f49f5d45b81f6584b3da
References (file:line; sdk @ 605c20a)
| Location | What it shows |
|---|---|
src/json.ts (asBigInt) |
throw new Error(...) — bare Error, no XeError |
src/client.ts (balances/toMap, pending, toCertificate/big, toLeaseRecord/big, toProvider, toEpoch, requestAttestation, timekeepers, latestEpoch) |
All call sites that let it escape |
src/errors.ts (isRetryable) |
Only recognises XeApiError/XeTransportError — a plain Error is unclassifiable |
/tmp/sdk-r5/verify.mjs (section F) |
Verification harness (ephemeral, see "Reproduction") |
Thread
Thank you for this report. We have read it against the code and it is being handled. The assessment and any award follow the fix. https://bounty.xe.network/XE-1857