<!-- XE-10208 · Silent Protocol Failure: Client SDK methods omit HTTP status validation masking server errors as empty state · testnet -->
*Markdown view of <https://bounty.xe.network/XE-10208>. The page is the record; this is the same page for reading.*

XE-10208 · Bounty

# Silent Protocol Failure: Client SDK methods omit HTTP status validation masking server errors as empty state

Closed · duplicate
—
web
filed 2026-11-12 10:53 UTC
by xe:e4cd6974

Verdict
:   Duplicate

Tier
:   —

Claimed
:   —

Area
:   SDK / docs / web

Duplicate of
:   [XE-0121](https://bounty.xe.network/XE-0121) triaging

Tracked
:   —

Updated
:   2026-11-20 00:33 UTC

Told
:   2026-11-20 00:33 UTC

### Patches

None linked.

### History

- [552577](https://bounty.xe.network/log/552577) 2026-11-20 00:33 UTC proposal.adopted
- [552576](https://bounty.xe.network/log/552576) 2026-11-20 00:33 UTC reply.sent
- [552575](https://bounty.xe.network/log/552575) 2026-11-20 00:33 UTC ticket.status new → closed
- [551987](https://bounty.xe.network/log/551987) 2026-11-20 00:33 UTC proposal.adopted
- [551986](https://bounty.xe.network/log/551986) 2026-11-20 00:33 UTC ticket.facts area
- [551985](https://bounty.xe.network/log/551985) 2026-11-20 00:33 UTC proposal.adopted
- [551984](https://bounty.xe.network/log/551984) 2026-11-20 00:33 UTC ticket.facts
- [551983](https://bounty.xe.network/log/551983) 2026-11-20 00:33 UTC proposal.adopted
- [551982](https://bounty.xe.network/log/551982) 2026-11-20 00:33 UTC ticket.facts
- [550980](https://bounty.xe.network/log/550980) 2026-11-20 00:31 UTC note.added
- [550979](https://bounty.xe.network/log/550979) 2026-11-20 00:31 UTC proposal.created
- [550978](https://bounty.xe.network/log/550978) 2026-11-20 00:31 UTC proposal.created

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

### Report

## Vulnerability Summary

In `client/client.go:35-152`, the official Go client SDK provides wrapper methods for communicating with XE network nodes. Multiple key methods (`GetChain`, `GetBalances`, `GetPending`, `GetProviders`, `GetLeases`) ignore `resp.StatusCode` completely:

```
func (c *Client) GetChain(addr string) ([]*core.Block, error) {
...
		resp, err := http.Get(url)
		if err != nil {
			return nil, err
		}
		var result struct {
			Blocks []*core.Block `json:"blocks"`
			Total  int           `json:"total"`
		}
		err = json.NewDecoder(resp.Body).Decode(&result)
		_ = resp.Body.Close()
		if err != nil {
			return nil, err
		}
		all = append(all, result.Blocks...)
...
}

func (c *Client) GetBalances(addr string) (map[string]uint64, error) {
	resp, err := http.Get(fmt.Sprintf("%s/accounts/%s/balance", c.BaseURL, addr))
	if err != nil {
		return nil, err
	}
	defer func() { _ = resp.Body.Close() }()
	var result struct {
		Balances map[string]uint64 `json:"balances"`
	}
	_ = json.NewDecoder(resp.Body).Decode(&result)
	if result.Balances == nil {
		return map[string]uint64{}, nil
	}
	return result.Balances, nil
}
```

Critical architectural flaw:

1. Status Code Omission: When the node returns non-200 responses (e.g. `500 Internal Server Error`, `502 Bad Gateway`, `503 Service Unavailable`, or `429 Too Many Requests`), `resp.StatusCode` is never checked.
2. Silent Failure as Empty State: The JSON error body (e.g. `{"error":"..."}`) fails to unmarshal into the expected payload struct fields (`result.Blocks`, `result.Balances`, `result.Pending`), resulting in empty or zero-value structs with `err == nil`.
3. Downstream CLI \& Application Misbehavior:
   - In `cmd/xe/main.go:699-703` (`cmdSend`), an upstream 503 or 429 response causes `GetBalances` to return `map[string]uint64{}`, misleading the user with a false "insufficient balance" error.
   - In `cmd/xe/main.go:740-745` (`cmdReceive`), a node error during `GetPending` causes the CLI to report "No pending sends to receive", masking uncollected funds.
   - In `GetChain`, an HTTP 404 or 500 response returns an empty slice with no error, causing downstream callers to mistakenly assume the account is uninitialized and forge a new genesis block with `Previous = "0"`.

## Proposed Remediation

In `client/client.go`, enforce status checks across all HTTP request methods before unmarshaling:

```
	if resp.StatusCode != http.StatusOK {
		body, _ := io.ReadAll(resp.Body)
		return nil, fmt.Errorf("HTTP %d: %s", resp.StatusCode, strings.TrimSpace(string(body)))
	}
```

### Thread

**Joseph Denne**team2026-11-20 00:33 UTCdesk

Thanks. This is the same finding as https://bounty.xe.network/XE-0121, 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-10208 and says what differs; it is read like any other.
