chore(infra): verify + surface two-hop trusted-proxy posture (BUNYIP-476) #472
Loading…
Reference in a new issue
No description provided.
Delete branch "chore/BUNYIP-476-verify-trusted-proxy"
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?
Closes BUNYIP-476, the last BUNYIP-437 follow-up: verify the two-hop
TRUSTED_PROXY_CIDRconfig so audited-login IPs resolve, and document the requirement.What I verified
The "audit records a Docker IP while auto-ban resolves correctly" symptom is a topology/config condition, not a resolver bug. The shared
extract_client_ipalready serves every surface; audited logins take the two-hop BFF path (Traefik -> bunyip-web -> bunyip-api) and resolve the real browser IP only when bunyip-web re-forwardsX-Forwarded-For(peer Traefik inWEB_TRUSTED_PROXY_CIDR) AND bunyip-api trusts bunyip-web's container peer (inTRUSTED_PROXY_CIDR). Auto-ban's single-hop direct-to-API endpoints resolve regardless, hence the disagreement.The config is already correct by default:
compose.yml/compose.dev.ymldefault bothTRUSTED_PROXY_CIDR(api) andWEB_TRUSTED_PROXY_CIDR(web) to172.16.0.0/12,10.0.0.0/8,192.168.0.0/16, which spans the private ranges Docker assigns container/Traefik addresses, so the two-hop path resolves out of the box. The real residual risk is a silent misconfig: an empty or narrowed CIDR that omits bunyip-web's address drops the forwarded IP with no signal, and the auditedactor_ip_address/ access-log IP / rate-limit key silently fall back to the bunyip-web peer.What I changed
main.rs+Config::trusts_forwarded_client_ip): bunyip-api logs its posture once at startup - an info line when a CIDR is set, aWARNnaming the exact fallback when the list is empty. AWARNon a TLS/BFF deployment is the misconfig, now diagnosable from logs rather than data.docs/client-ip-forwarding.md: a new "audited-login path" section - howactor_ip_addressdepends on both hops, how to verify (boot log + the newestaudit_logrow'sip_address), and that the compose defaults already cover it.Acceptance
actor_ip_addressresolves to the real client on the two-hop path with the default (and any correct)TRUSTED_PROXY_CIDR; a misconfig that would break it now surfaces as a bootWARN.Verification
just check-containergreen (fmt, clippy-D warnings, 182 tests incl. a new test for the boot-diagnostic predicate). No resolver/code-path change - the resolver was already correct and shared; this is verification + observability + docs.🤖 Generated with Claude Code
https://claude.ai/code/session_018TXaT3P192nDsZzbzHETb9