Skip to content

store real client IP in audit logs instead of Traefik proxy IP - #178

Merged
oveldman merged 3 commits into
mainfrom
bugfix/165-audit-ip
Jul 6, 2026
Merged

store real client IP in audit logs instead of Traefik proxy IP#178
oveldman merged 3 commits into
mainfrom
bugfix/165-audit-ip

Conversation

@oveldman

@oveldman oveldman commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Audit logs were recording the internal Traefik IP (e.g. 10.1.9.123) instead of the real client IP. Two issues combined to cause this: ASP.NET Core's forwarded headers middleware only trusts loopback proxies by default, so X-Forwarded-For from Traefik was silently ignored; and when the server runs on a dual-stack socket, IPv4 connections arrive as IPv4-mapped IPv6 addresses (::ffff:x.x.x.x) which were stored as-is.

Changes

  • Api/Program.cs & Status/Program.cs — Clear KnownIPNetworks and KnownProxies so X-Forwarded-For from Traefik is trusted
  • IpAddress.cs — Normalize IPv4-mapped IPv6 addresses (::ffff:x.x.x.x → x.x.x.x) when constructing the value object

How to Test

  • Make an API request through Traefik and verify the audit log stores the real client IP (e.g. 89.99.250.35) instead of the internal proxy IP (10.1.9.x)

Checklist

  • Code builds without errors
  • Changes have been tested locally
  • No new warnings introduced

@oveldman oveldman self-assigned this Jul 6, 2026
@oveldman oveldman added the bug Something isn't working label Jul 6, 2026
@oveldman oveldman linked an issue Jul 6, 2026 that may be closed by this pull request
…ary HTTP delete in ApiHooks initialization
@sonarqubecloud

sonarqubecloud Bot commented Jul 6, 2026

Copy link
Copy Markdown

@oveldman
oveldman merged commit 0bcb84d into main Jul 6, 2026
10 checks passed
@oveldman
oveldman deleted the bugfix/165-audit-ip branch July 6, 2026 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Audit log records proxy internal IP instead of real user IP

1 participant