Loopback XFF trust collapses all UI-proxy clients into one limiter bucket
Report
Loopback XFF trust collapses all UI-proxy clients into one limiter bucket
Summary
The UI proxies /api/* to the API on loopback, and the API's clientIP
trusts X-Forwarded-For on loopback connections, taking the last XFF
element. Go's reverse proxy appends its bare loopback IP to the header, so
every UI API request lands in the same rate-limiter bucket: one heavy UI
user exhausting the shared read burst (1000, then 200/s) or write burst
(50, then 10/s) gets 429s for all UI users.
Impact
API availability for UI users. One UI client can deny the API to every other UI client through the shared bucket; no funds are directly at stake, and direct non-loopback connections correctly ignore XFF, so this is scoped to UI-proxied traffic. The 429 consequence was proven at the limiter level (see Proof of concept), not just inferred from bucket-key equality.
Suggested program tier: Medium.
Root cause
cmd/xe/main.go:1509-1514+api/ui.go:34-44(Director plus the/api/mount): the UI reverse-proxies API requests tohttp://127.0.0.1:<apiPort>. The default--api-bindis already127.0.0.1, so the loopback target holds by default, not only via the wildcard normalization. The UI path requires--ui(default off).api/handler.go:375-393clientIP(withisLoopbackHostat:395-400): on a loopbackRemoteAddrit returns the last comma-separated XFF element verbatim — no port stripping, no normalization — falling back toX-Real-IPand then the host. Direct non-loopback connections return the host early and ignore XFF entirely.api/handler.go:364-372rateLimitMiddlewarekeys the limiter byclientIP(r)and returns 429rate limit exceededon exhaustion. Constants (handler.go:296-297): read 200/s with burst 1000, write 10/s with burst 50.- Why the bucket is shared: Go's proxy appends its bare loopback IP, so
the backend sees
X-Forwarded-For: 9.9.9.9, 127.0.0.1and the last element — the key — is127.0.0.1for every UI client. An earlier draft of this report claimed the proxy appends IP:port (a fresh bucket per connection); the harness disproved that and proved the opposite, and this report states the correction plainly. - Generalization, no scope change: the collapse holds for any fixed proxy
IP, not just loopback — with a non-loopback proxy address, clients
still collapse to one key (the proxy's IP), because non-loopback
RemoteAddris returned verbatim.
Proof of concept
Target: xeprotocol/xe @ 978785929bc17a2f4ab30c383e5fc9cf4d634512
(2026-10-15). Two harnesses, both against the real api package; the
repository itself is not modified.
Attached PoCs: pocs/slice8-harness.t.txt (original harness, 6 tests)
and pocs/reval-f06-test.go.txt (re-validation harness, including the
end-to-end 429 test), both byte-identical copies of the runnable
sources.
Run (Go 1.25.14):
export PATH="$HOME/.local/go/bin:$PATH"
GOPROXY=off go test ./api/ -run 'TestSlice8' -count=5 -vet=off -v
Observed output (verbatim, re-validation run 2026-10-29): all 6 tests PASS on all 5 runs, zero failures. Every iteration of the proxy test logged:
request 0: backend XFF="9.9.9.9, 127.0.0.1" -> clientIP bucket key="127.0.0.1"
request 1: backend XFF="9.9.9.9, 127.0.0.1" -> clientIP bucket key="127.0.0.1"
End-to-end 429 proof (re-validation 2026-10-29)
A second test wired the real NewUIHandler through the real
rateLimitMiddleware with the real limiter configuration (not a lowered
one) over real HTTP through two test servers. Client A (XFF 1.1.1.1)
through the UI proxy was allowed 1387 requests (burst 1000 plus 200/s
refill during the ~1.9 s drain) before the shared bucket 429'd; client B
(XFF 2.2.2.2) through the same UI proxy then got 429. A control on
the same middleware instance — a fresh non-loopback key — got 200,
proving the 429 is bucket-keyed, not a global lockout.
No escape was found: clientIP has only two callers in the repository
(rateLimitMiddleware and attestation); IPv6 loopback [::1] and the
localhost hostname are both treated as loopback; a trailing-comma XFF
with an empty last element falls back to the host bucket 127.0.0.1 —
still the shared bucket; and X-Real-IP cannot override XFF when both are
present.
Reproduction steps
- Two fresh connections through the UI proxy to the API.
- Observe both bucketed under
127.0.0.1. - Exhaust the shared burst from one → all UI users get 429.
Recommended fix
Key UI-proxied requests by an authenticated/session identifier, or stop trusting XFF on loopback, or exempt the UI proxy path from the shared bucket.
Severity
- CVSS 3.1: 5.3 —
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L - CWE-400 (Uncontrolled Resource Consumption)
Caveats
- The 429 proof is a loopback end-to-end run through the real middleware stack, not a production deployment observation.
- The conditional variant — fresh-bucket minting if a front proxy forwards client headers without appending its own bare IP — is NOT part of this claim: the front-proxy layout of the public deployment was not tested and no deployment configuration for it exists in the repository.
- No XE-specific prior report of the limiter/XFF mechanism was found (dedup query Q6 recorded in the audit's DEDUP-BASELINE.md; only generic XFF articles recurred).
- This reproduction runs against the repository code at the stated HEAD. No testnet transactions were sent as part of this report.
Payout address (XE): eff2c51dd8457df740b919226cd9b37a2944e5abea7501094db80234f87f010e
Best, Chaplin
Thread
Thanks. This is the same finding as https://bounty.xe.network/XE-0082, 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, reply with what differs and we will look again.