Repository navigation
feat(webui): opt-in CF-Connecting-IP for login limits behind a local cloudflared - #187
Open
gerarecipe wants to merge 1 commit into
Open
gerarecipe wants to merge 1 commit into
gerarecipe wants to merge 1 commit into
Conversation
…cloudflared Behind a reverse proxy every visitor shares the proxy's address, so the per-client login limit (5 failures per 5 minutes) becomes global: anyone on the internet can keep the operator locked out of the WebUI with one wrong password a minute. -trust-cloudflare-client-ip (off by default) takes the client address for the login and Playground limits and the audit logs from CF-Connecting-IP, but only when the direct peer is a loopback address (a cloudflared connector on the same host). Cloudflare's edge overwrites that header, so remote visitors cannot choose it; a remote peer is never trusted. Missing, repeated, comma-separated, zoned or malformed values fall back to the peer address, which is stricter, not looser. IPv6 clients share one limit per /64 so rotating addresses inside one allocation does not reset it. X-Forwarded-For stays untrusted. READMEs and management guides (all four languages) describe the flag. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Behind a reverse proxy every visitor shares the proxy's address — the README says so. For the login limit (5 failures per 5 minutes per client) that makes the limit global: anyone who can reach the login page can keep the operator locked out with one wrong password a minute. A common way to expose the WebUI is a
cloudflaredtunnel on the same host, where every request arrives from127.0.0.1.Change
New opt-in flag
-trust-cloudflare-client-ip(defaultfalse, current behavior unchanged):CF-Connecting-IP, only when the direct peer is a loopback address. Cloudflare's edge overwrites that header, so a remote visitor cannot choose it; a remote peer is never trusted, whatever it sends.X-Forwarded-Forstays untrusted. The global concurrent password-check cap is unchanged.clientIPbecomes aServermethod in a newinternal/admin/client_ip.go; call sites are otherwise unchanged. READMEs and management guides (EN/中文/VI/IT) describe the flag and say not to enable it for other reverse proxies.Verification
gofmt -l .,go vet ./..., Linux and Windows builds: clean._test.gofiles) against the real handler on loopback with synthetic credentials: header parsing table (loopback v4/v6, mapped v4, spoofing from a remote peer, missing/garbage/list/repeated/zoned values), IPv6 /64 grouping, and the end-to-end case — without the flag, five failures from one visitor make the operator's correct login return429; with the flag the attacker gets429and the operator200. Happy to add the tests if wanted.🤖 Generated with Claude Code