<!-- XE-0082 · 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) · testnet -->
*Markdown view of <https://bounty.xe.network/XE-0082>. The page is the record; this is the same page for reading.*

XE-0082 · Bounty

# 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)

Awarded
High
[xe#81](https://github.com/xeprotocol/xe/issues/81)
filed 2026-10-26 20:48 UTC
by BoomGone

Verdict
:   Valid

Tier
:   High

Claimed
:   High

Area
:   Node / API

Duplicate of
:   —

Tracked
:   internally

Award
:   2,000 XE approved
    · ceiling 10,000

Updated
:   2026-11-05 22:09 UTC

### Patches

- [xe#117](https://github.com/xeprotocol/xe/pull/117) open by arturbarszcz78
  fix(api): resolve clientIP across reverse proxy chain to prevent shared rate limit bucket (#81)
- [core#1108](https://github.com/xeprotocol/core/pull/1108)

### History

- [9399](https://bounty.xe.network/log/9399) 2026-11-05 22:09 UTC github.labels
- [9357](https://bounty.xe.network/log/9357) 2026-11-05 22:08 UTC ticket.status patched → awarded
- [9356](https://bounty.xe.network/log/9356) 2026-11-05 22:08 UTC ticket.award
- [9353](https://bounty.xe.network/log/9353) 2026-11-05 22:08 UTC proposal.adopted
- [9352](https://bounty.xe.network/log/9352) 2026-11-05 22:08 UTC ticket.award
- [9349](https://bounty.xe.network/log/9349) 2026-11-05 22:08 UTC proposal.adopted
- [9348](https://bounty.xe.network/log/9348) 2026-11-05 22:08 UTC ticket.status accepted → patched
- [9345](https://bounty.xe.network/log/9345) 2026-11-05 22:08 UTC proposal.rejected
- [6906](https://bounty.xe.network/log/6906) 2026-11-05 13:45 UTC proposal.created
- [1836](https://bounty.xe.network/log/1836) 2026-11-02 19:16 UTC proposal.created
- [1486](https://bounty.xe.network/log/1486) 2026-11-02 10:11 UTC note.added
- [1098](https://bounty.xe.network/log/1098) 2026-10-30 14:20 UTC proposal.created

[Full history](https://bounty.xe.network/log?ref=XE-0082) · [JSON](https://bounty.xe.network/v1/tickets/XE-0082) · [markdown](https://bounty.xe.network/XE-0082.md)

### Report

- Suggested tier: High ("rate limit abuse that degrades service for other clients", "degradation one client can cause")
- Area: `api/ui.go` UI reverse proxy, `api/handler.go` `clientIP` and 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:

1. From IP A, send 60 POST requests with an empty JSON body to `https://ldn.test.network/api/blocks/send` within 2 seconds, once. Expect 429 after about 50\.
2. 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.
3. Stop. Total: about 61 requests.

## Suggested fix

- In the UI proxy, use `Rewrite` with `pr.SetXForwarded()` or copy the incoming `X-Forwarded-For` unchanged, so the real client stays last.
- Or have `clientIP` walk `X-Forwarded-For` from the right and skip trusted proxy addresses (loopback), returning the first untrusted one.

## Payout

XE address: `6591eab453dbd93b27e2cd674712f94b42d9e7e4d52980b966fa6da4ccd832dc` (same as #75).

### Thread

**arturbarszcz78**2026-10-28 08:16 UTCgithub

\[comment from a blocked account removed\]
