Relay: per-address limit counts all HTTPS users as one #114
Labels
No labels
area/ci
area/desktop
area/packaging
area/protocol
area/reading
area/ui
area/web
area/writing
kind/bug
kind/feature
kind/infra
kind/request
needs/user
parked
perf
security
upstream
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
littlefox/neokom#114
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
In the Docker image's HTTPS mode (#98), Caddy proxies /relay to 127.0.0.1:4895, so the relay sees every https client as 127.0.0.1. NEOKOM_RELAY_TRUST_PROXY isn't set (and setting it would be unsafe: port 4895 is also published directly, so any client could send a fake X-Forwarded-For). Result: NEOKOM_RELAY_PER_ADDRESS (8) is shared by all https users together.
Fix: honour X-Forwarded-For only when the TCP peer is the proxy (loopback by default, or a configured address), and turn that on in the image. Test: two clients over https get their own limits; a direct ws:// client with a forged X-Forwarded-For is counted by its own address.
Fixed in #116. Verified: unit and integration tests in kom-relay; tools/web-image-smoke.sh on a fresh image counts https clients by their own address and ignores a forged X-Forwarded-For (through Caddy and on 4895); the same check fails on the 0.2.0-era image git-d4d6827. Published as latest/git-b6292c5; the user's container runs it (healthy, trusted_proxies loopback).