#5 (H-1): rate-limit on the real client IP behind trusted proxies + Retry-After #45
No reviewers
Labels
No labels
architecture
code-quality
correctness
critical
docs
high
low
medium
ops
performance
privacy
security
tests
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
antrapol/CA-MDID-eMudhra!45
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/h-1-real-client-ip"
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?
Behind Caddy every caller shared the proxy's IP in the login/token rate limiter — five bad secrets from anyone locked out everyone for 30 minutes (remote DoS).
Changes
MdidWsWeb.Plugs.ForwardedRemoteIP: rewritesremote_ipfromx-forwarded-foronly when the peer and every hop is a trusted proxy (TRUSTED_PROXIESCIDRs; default empty = header never trusted, spoofing impossible as before). Handles chained hops,host:portand bracketed IPv6 entriesTRUSTED_PROXIES=172.16.0.0/12(Docker networks)Retry-Afteron 429 from both/oauth/tokenand/login(remaining lockout seconds)Full suite: 170 passed locally.
Fixes #5
Behind the Caddy reverse proxy every request arrived with the proxy container's IP, so the login/token rate limiter bucketed all callers into one {proxy_ip}:{client_id} identifier — five bad secrets from anyone locked out everyone for 30 minutes (remote DoS). - new ForwardedRemoteIP plug: rewrites conn.remote_ip from x-forwarded-for only when the peer AND every intermediary hop is a trusted proxy (TRUSTED_PROXIES CIDRs, default empty = header never trusted, unspoofable as before); handles chained hops, ports and bracketed IPv6 - endpoint pipeline wired before the router; compose default TRUSTED_PROXIES=172.16.0.0/12 (docker networks) - 429 responses now carry Retry-After (remaining lockout seconds) on both /api/v1/cert_mgmt/oauth/token and /login Fixes #5 (audit H-1)Pull request closed