{"id":"XE-0050","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"69","source_url":"https://github.com/xeprotocol/xe/issues/69","reporter_id":22,"title":"Inconsistent API response: /accounts/{address}/* lookups are case-sensitive and unvalidated","area":"node-api","claimed_tier":"medium","assessed_tier":null,"verdict":null,"duplicate_of":null,"tracked":true,"internal_ref":"","internal_url":null,"status":"accepted","closed_reason":null,"github_state":"open","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-10-29T13:57:19.760976+00:00","updated_at":"2026-11-10T11:38:18.348817+00:00","source_created_at":"2026-10-26T13:36:35+00:00","told_at":"2026-11-10T00:15:30+00:00","status_changed_at":"2026-10-29T14:04:12.438827+00:00","url":"https://bounty.xe.network/XE-0050","body":"**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.\n\n**Component:** HTTP API — `/accounts/{address}/*` read endpoints.\n**Network:** testnet-0005, reproduced against `https://ffm.core.test.network`, 2026-10-26.\n\n## Summary\nAccount 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`).\n\n## Steps to reproduce\nTake any funded account from the public `/blocks/recent` feed, then query it in both cases:\n\n```\n# lowercase (canonical)\ncurl -s https://ffm.core.test.network/accounts/a2673b1cb92518fbcd2c578ef297ce79e90bd1e6e0fca13a50af1485b86f435d/balance\n{\"address\":\"a2673b1cb92518fbcd2c578ef297ce79e90bd1e6e0fca13a50af1485b86f435d\",\"balances\":{\"XE\":147898100},\"spendable\":{\"XE\":0},\"final_height\":182}\n\n# UPPERCASE (same 32 bytes, valid hex)\ncurl -s https://ffm.core.test.network/accounts/A2673B1CB92518FBCD2C578EF297CE79E90BD1E6E0FCA13A50AF1485B86F435D/balance\n{\"address\":\"A2673B1CB92518FBCD2C578EF297CE79E90BD1E6E0FCA13A50AF1485B86F435D\",\"balances\":{},\"spendable\":{},\"final_height\":0}\n```\n\nSame account, two valid encodings, different answers (real balance vs empty).\n\nRelated — no format validation (both return `200` with empty balances instead of `400`):\n```\ncurl -s https://ffm.core.test.network/accounts/gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg/balance   # non-hex\ncurl -s \"https://ffm.core.test.network/accounts/$(python3 -c 'print(\"f\"*4000)')/balance\"                                      # 4000 chars\n```\n\n## Root cause\n- `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.\n- `core/ledger.go` `GetAssetBalances` does a raw map lookup `l.assetBalances[account]` with no case normalization.\n- Blocks are stored lowercased via `normalizeBlockHex` (`core/ledger.go:711`), so the map keys are lowercase; an uppercase query misses.\n\n## Impact\nRead-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).\n\n## Suggested fix\nNormalize the address (`strings.ToLower`) and validate it (exactly 64 hex chars) in the account handlers or a shared middleware; return `400` otherwise.\n\n## Reward address\n618d0f48a31ab36aaa8eb30d7c757c242b9a08fad7c602ed638f81537ce0d4f8","patch_refs":[{"id":160,"repo":"xeprotocol/xe","kind":"pr","ref":"141","title":"fix(api): normalize and validate account address in /accounts/{address}/* (#69)","url":"https://github.com/xeprotocol/xe/pull/141","note":"","state":"open","author":"arturbarszcz78","added_by":"desk","created_at":"2026-10-29T13:57:30.091343+00:00"}],"thread":[{"id":1560,"source":"github","source_ref":"6755089052","author":"XE desk","team":true,"body":"Read and accepted. It is tracked internally and the fix will land in a public PR; this issue is\nupdated when it does, and the tier and award follow the fix. The desk entry is https://bounty.xe.network/XE-0050.","created_at":"2026-11-10T00:15:30+00:00"}]}