api/ui: UI reverse proxy makes clientIP resolve to 127.0.0.1, so all web wallet/explorer traffic shares one rate-limit bucket (High)
Report
- Suggested tier: High ("rate limit abuse that degrades service for other clients", "degradation one client can cause")
- Area:
api/ui.goUI reverse proxy,api/handler.goclientIPand rate limiter, testnet deployment - Found: 2026-10-26, repo master
9787859
Note: this is a code-analysis finding. I have not run any load against the public nodes. The behaviour below is read from the source and already observed (as a symptom) by the deployment docs. Confirming the user-facing impact would need a bounded measurement, and per the programme rules I would open a volume-test notice issue before running one.
Summary
The UI listener (ldn.test.network, wallet and explorer) proxies /api/* to the node API on 127.0.0.1:8080 with httputil.NewSingleHostReverseProxy and a custom Director (api/ui.go:28). With a Director, Go's ReverseProxy appends the immediate client address to X-Forwarded-For. The immediate client of the UI listener is the front proxy (Caddy) on loopback, so the API receives:
X-Forwarded-For: <real client IP>, 127.0.0.1
RemoteAddr: 127.0.0.1:<port> (the UI proxy)
clientIP (api/handler.go:375) trusts X-Forwarded-For only from loopback and takes the last entry:
if !isLoopbackHost(host) {
return host
}
if xff := r.Header.Get("X-Forwarded-For"); xff != "" {
parts := strings.Split(xff, ",")
if last := strings.TrimSpace(parts[len(parts)-1]); last != "" {
return last
}
}
The last entry is always 127.0.0.1, so every request that comes through the wallet or explorer is rate limited under the single key 127.0.0.1: one shared bucket of read 200/s burst 1000, write 10/s burst 50, probe 20/s burst 100 (api/handler.go:296) for all users worldwide.
The deployment docs already observe the symptom without treating it as a defect: "Because external clients behind Caddy share an egress bucket in the node's per-IP rate limiter, a plain sequential sweep of the public URLs can trip 429" (https://test.network/docs/deployment, Data Directory section above).
Impact (expected, to be measured)
- One client sending about 51 POSTs in 5 seconds through
https://ldn.test.network/api/...(even invalid ones, the limiter runs before validation) should make every other wallet user's send, receive and faucet related API calls fail with 429 for as long as it continues. - Reads: about 1000 requests in 5 seconds should do the same for the explorer and wallet balance views.
- The cost to the attacker is tiny (no PoW, no funds, no signature), well inside what one home connection can do.
How to confirm (not done yet)
Needs a short, bounded measurement and, per the programme rules, a notice issue first:
- From IP A, send 60 POST requests with an empty JSON body to
https://ldn.test.network/api/blocks/sendwithin 2 seconds, once. Expect 429 after about 50. - During those seconds, from a different IP B (for example a phone on mobile data), request the same URL once. If B also gets 429, the bucket is shared.
- Stop. Total: about 61 requests.
Suggested fix
- In the UI proxy, use
Rewritewithpr.SetXForwarded()or copy the incomingX-Forwarded-Forunchanged, so the real client stays last. - Or have
clientIPwalkX-Forwarded-Forfrom the right and skip trusted proxy addresses (loopback), returning the first untrusted one.
Payout
XE address: 6591eab453dbd93b27e2cd674712f94b42d9e7e4d52980b966fa6da4ccd832dc (same as #75).
Thread
[comment from a blocked account removed]