Bounty
XE-16852 · Bounty

[Low] Go client SDK silently converts server errors and malformed responses into empty results

Closed · duplicate — xe#675 filed 2026-11-17 06:39 UTC by kecedanzz77-bit

Report

Summary

Several Go client SDK methods never check resp.StatusCode and ignore the JSON decode error, returning zero values with a nil error. A node outage, a 502, or a malformed response is indistinguishable from "no data" — and callers act on the empty result.

Root cause

GetBalances (client/client.go:63-77), GetPending (:79-91), GetProviders (:120-129), GetLeases (:143-152), getJSON (:169-178) never check resp.StatusCode and ignore the decode error (_ = json.NewDecoder(...).Decode(...)), returning zero values with a nil error. GetVM (:154-167) additionally returns (nil, nil) on transport error AND on any non-200 status. Contrast GetReputation (:120-136), which checks the status code and returns decode errors — the silent pattern is inconsistent, not by design.

Verification

Executed PoC against a fake node:

  • HTTP 502 HTML page → GetBalances returns empty map + nil error.
  • Malformed JSON → GetPending/GetLeases return nil + nil error.
  • HTTP 500 and connection-refused → GetVM returns nil + nil error.

Impact (callers in cmd/xe/main.go)

  • cmdWalletBalance (:647) prints "(no balance)" on a 502.
  • cmdReceive (:740) prints "No pending sends to receive." and returns when the node errors — a user with real pending funds is told there is nothing to receive.
  • cmdVM (:1164) fatals "VM not found" on a node outage, and its err != nil check is dead code since GetVM never returns an error.

Note on related reports

#77 is about the TypeScript SDK (src/client.ts) + OpenAPI error-schema mismatch — different SDK, different mechanism (error-shape parsing vs no status check + swallowed decode errors). Search GetBalances GetLeases GetVM — 0 hits.

Suggested fix

Check resp.StatusCode and return decode errors in the affected methods, matching GetReputation.

Thread

Joseph Denneteam2026-11-22 23:26 UTCdesk

Thanks. This is the same finding as an earlier report that is not public, which was filed first; the programme pays the first verifiable submission, so this one closes as a duplicate. If you believe it is a different bug, file a new report that links https://bounty.xe.network/XE-16852 and says what differs; it is read like any other.