batch-v07h: real client address everywhere, detection and Overview warning, audit.ip (#864, v0.6.331) #881

Merged
Cordy merged 11 commits from batch-v07h into main 2026-10-12 16:09:36 +00:00
Owner

Closes #864. Built to the approved mockups and the decisions on #864.

Address plumbing and audit

  • The client address is resolved once per request (auth.WithClientAddr, using trusted proxies, read from the right). The request log, audit, detector and API all use it.
  • The request log now writes remote= as the resolved client, and adds peer= when the client came through a proxy.
  • Audit events get an addr field. It is stamped centrally through AppendCtx, and a guard test pins every exemption to its exact call. Inbound peering events carry the peer instance's address.
  • New audit.ip: full | truncated | off setting (env CAIRN_AUDIT_IP). It is applied before the event is written and hashed, and only parsed addresses are stored.
  • Sign-in alarm notes no longer embed the address (R5).
  • Old sealed files still verify.

Detection

States, in priority order:

  • unsafe: trust list too broad (R6). This means 0/0, ::/0, or a private/CGNAT/loopback/ULA range wider than /24 (IPv4) or /64 (IPv6). Wide public ranges such as Cloudflare's are fine.
  • cluster: Kubernetes .0/.1 SNAT signature, the service /16, or the pod /16 (R1). The fix is externalTrafficPolicy: Local, and the card never suggests trusting a node address.
  • proxy-untrusted: the exact proxy address. It is gated on at least 20 forwarded requests, at least 3 distinct client hops and at least 50% of traffic (R2). It sets peerPublic, and podAddress for an ingress pod (R7).
  • shared: the mix rule. Each account is counted once per address (R3). A limit alarm counts only when it comes from a gateway-style address (R8).

Memory is bounded. The detector logs a WARN on every state change, and the admin bell gets an item that can't be muted. Admin API: GET /api/v1/admin/client-address.

UI (per the mockups)

  • A card first in the Overview attention strip: red for unsafe, amber for check. It has copyable fixes and can't be dismissed.
  • A "Client addresses" row in Access with an OK / Check / Unsafe chip.
  • A dot on Overview in the admin rail.
  • A bell item.
  • Texts in all 4 languages.

Chart and docs

  • Chart: service.externalTrafficPolicy: Local by default, with a render test.
  • deployment.md: "Getting the real client address", including the 17-setup matrix, k3s Traefik, PROXY protocol and Cloudflare.
  • New data-protection-operators.md. It is marked not legal advice and needs a lawyer's review before it goes public.
  • CHANGELOG v0.6.331 with upgrade notes.

Review

  • Task 1: one Important finding (peering context), fixed.
  • Task 2: the R1/R2 rulings, fixed.
  • Final review: one Important finding (a LAN false alarm, now R8) plus R5/R6, fixed. R7 was added.
  • Go tests, -race, gofmt and web tests (574/574) all pass.
Closes #864. Built to the approved mockups and the decisions on #864. ## Address plumbing and audit - The client address is resolved once per request (`auth.WithClientAddr`, using trusted proxies, read from the right). The request log, audit, detector and API all use it. - The request log now writes `remote=` as the resolved client, and adds `peer=` when the client came through a proxy. - Audit events get an `addr` field. It is stamped centrally through `AppendCtx`, and a guard test pins every exemption to its exact call. Inbound peering events carry the peer instance's address. - New `audit.ip: full | truncated | off` setting (env `CAIRN_AUDIT_IP`). It is applied before the event is written and hashed, and only parsed addresses are stored. - Sign-in alarm notes no longer embed the address (R5). - Old sealed files still verify. ## Detection States, in priority order: - **unsafe:** trust list too broad (R6). This means `0/0`, `::/0`, or a private/CGNAT/loopback/ULA range wider than /24 (IPv4) or /64 (IPv6). Wide public ranges such as Cloudflare's are fine. - **cluster:** Kubernetes `.0`/`.1` SNAT signature, the service /16, or the pod /16 (R1). The fix is `externalTrafficPolicy: Local`, and the card never suggests trusting a node address. - **proxy-untrusted:** the exact proxy address. It is gated on at least 20 forwarded requests, at least 3 distinct client hops and at least 50% of traffic (R2). It sets `peerPublic`, and `podAddress` for an ingress pod (R7). - **shared:** the mix rule. Each account is counted once per address (R3). A limit alarm counts only when it comes from a gateway-style address (R8). Memory is bounded. The detector logs a WARN on every state change, and the admin bell gets an item that can't be muted. Admin API: `GET /api/v1/admin/client-address`. ## UI (per the mockups) - A card first in the Overview attention strip: red for unsafe, amber for check. It has copyable fixes and can't be dismissed. - A "Client addresses" row in Access with an OK / Check / Unsafe chip. - A dot on Overview in the admin rail. - A bell item. - Texts in all 4 languages. ## Chart and docs - Chart: `service.externalTrafficPolicy: Local` by default, with a render test. - deployment.md: "Getting the real client address", including the 17-setup matrix, k3s Traefik, PROXY protocol and Cloudflare. - New `data-protection-operators.md`. It is marked not legal advice and needs a lawyer's review before it goes public. - CHANGELOG v0.6.331 with upgrade notes. ## Review - Task 1: one Important finding (peering context), fixed. - Task 2: the R1/R2 rulings, fixed. - Final review: one Important finding (a LAN false alarm, now R8) plus R5/R6, fixed. R7 was added. - Go tests, `-race`, gofmt and web tests (574/574) all pass.
Cordy merged commit 9fe50f0f6c into main 2026-10-12 16:09:36 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Cordy/Cairn#881
No description provided.