Bounty
XE-0050 · Bounty

Inconsistent API response: /accounts/{address}/* lookups are case-sensitive and unvalidated

Accepted claimed Medium xe#69 filed 2026-10-26 13:36 UTC by cryptoloser8-coder

Report

Suggested tier: Medium (inconsistent API responses / missing checks). I may be over-rating it — it is read-only with no funds at risk, so Minor would also be fair. Deferring to the core team.

Component: HTTP API — /accounts/{address}/* read endpoints. Network: testnet-0005, reproduced against https://ffm.core.test.network, 2026-10-26.

Summary

Account addresses are 32-byte values rendered as hex, and hex is case-insensitive (A2… and a2… are the same bytes / the same account). The ledger stores addresses lowercased, but the balance lookup does not normalize the query, so the same account returns its real balance in lowercase and an empty result in uppercase. The endpoints also do not validate the address format at all (non-hex and arbitrarily long strings return 200 with empty data instead of 400).

Steps to reproduce

Take any funded account from the public /blocks/recent feed, then query it in both cases:

# lowercase (canonical)
curl -s https://ffm.core.test.network/accounts/a2673b1cb92518fbcd2c578ef297ce79e90bd1e6e0fca13a50af1485b86f435d/balance
{"address":"a2673b1cb92518fbcd2c578ef297ce79e90bd1e6e0fca13a50af1485b86f435d","balances":{"XE":147898100},"spendable":{"XE":0},"final_height":182}

# UPPERCASE (same 32 bytes, valid hex)
curl -s https://ffm.core.test.network/accounts/A2673B1CB92518FBCD2C578EF297CE79E90BD1E6E0FCA13A50AF1485B86F435D/balance
{"address":"A2673B1CB92518FBCD2C578EF297CE79E90BD1E6E0FCA13A50AF1485B86F435D","balances":{},"spendable":{},"final_height":0}

Same account, two valid encodings, different answers (real balance vs empty).

Related — no format validation (both return 200 with empty balances instead of 400):

curl -s https://ffm.core.test.network/accounts/gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg/balance   # non-hex
curl -s "https://ffm.core.test.network/accounts/$(python3 -c 'print("f"*4000)')/balance"                                      # 4000 chars

Root cause

  • api/handler.go handleGetBalance (and the sibling /chain, /keyset, /reputation handlers) use r.PathValue("address") with only a non-empty check, then look it up directly.
  • core/ledger.go GetAssetBalances does a raw map lookup l.assetBalances[account] with no case normalization.
  • Blocks are stored lowercased via normalizeBlockHex (core/ledger.go:711), so the map keys are lowercase; an uppercase query misses.

Impact

Read-only. No funds at risk, no state change, no crash, no auth bypass. The concrete harm is a correctness/consistency bug: a client, SDK or explorer that passes a validly-encoded uppercase address is told the account is empty (balance 0, final_height 0), which could mislead balance checks. The missing format validation is a hardening gap (unvalidated input echoed with 200).

Suggested fix

Normalize the address (strings.ToLower) and validate it (exactly 64 hex chars) in the account handlers or a shared middleware; return 400 otherwise.

Reward address

618d0f48a31ab36aaa8eb30d7c757c242b9a08fad7c602ed638f81537ce0d4f8

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