{"id":"XE-16706","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"647","source_url":"https://github.com/xeprotocol/xe/issues/647","reporter_id":2920,"title":"[Medium] client.GetChain never terminates when the server lies about Total (CLI hang + OOM)","area":"sdk-docs-web","claimed_tier":"medium","assessed_tier":null,"verdict":"duplicate","duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":"","status":"closed","closed_reason":"duplicate","github_state":"open","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-17T05:17:32.970950+00:00","updated_at":"2026-11-22T23:26:17.146962+00:00","source_created_at":"2026-11-17T05:16:50+00:00","told_at":"2026-11-22T23:26:17.175841+00:00","status_changed_at":"2026-11-22T23:26:17.158721+00:00","url":"https://bounty.xe.network/XE-16706","body":"## Summary\n`client.GetChain` (`client/client.go:35-59`) paginates until `len(all) >= result.Total`, where `Total` is entirely server-controlled. There is no cap on pages or total blocks, no delay between requests, and no body-size limit on the JSON decode. A malicious `XE_NODE` returning one block per page with `Total` always ahead makes the loop run forever, accumulating blocks in memory. Any `xe send/receive/balance/lease` against a malicious or compromised node hangs the CLI indefinitely at full request rate and grows memory without bound.\n\n## Root Cause\nThe loop in `GetChain` ends only when `len(result.Blocks) == 0 || len(all) >= result.Total`. `Total` comes from the server's JSON response. Nothing bounds the number of pages, the total blocks accumulated, or the request rate.\n\n## Impact\n- CLI hang: any command that calls `GetChain` (`cmd/xe/main.go:699, 748, 836, 910, 1057` -- `send`, `receive`, `balance`, `lease`, ...) never returns against a lying node.\n- Memory exhaustion: `all` grows without bound.\n- Request flood: the loop fires requests as fast as they complete (~11k req/s observed in PoC).\n\n## Verification (executed PoC)\nStub server returning 1 block/page with `Total = offset+100000`: `GetChain` did not return after 5s; 56,891 paginated requests made (~11k req/s, still counting). Audited at HEAD `8cc209d` (testnet-0006).\n\n## Note on related reports\nDistinct from XE-0121 / XE-6695 (`GetChain` status-blindness -- missing status check; this defect works with valid 200s on every page, so a status check does not fix it) and from the client timeout cluster XE-6786/7546/6928/8655 (a per-request timeout does not fix a loop whose every request succeeds).\n\n## Suggested fix\nCap total pages/blocks (e.g. stop after N pages or when accumulated blocks exceed a sane bound), and bound the response body size.","patch_refs":[],"thread":[{"id":18882,"source":"desk","source_ref":"reply:16559","author":"Joseph Denne","team":true,"body":"Thanks. This is the same finding as an earlier report that is not public, which was filed first; the programme pays the\nfirst verifiable submission, so this one closes as a duplicate. If you believe it is a different\nbug, file a new report that links https://bounty.xe.network/XE-16706 and says what differs; it is read like any other.","created_at":"2026-11-22T23:26:17.146962+00:00"}]}