Sentry.AspNet reports the server's IP as the user's IP
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- csharp
- Domain
- observability
Research direction
Start with Enricher.cs to see where {{auto}} is set, then SystemWebRequestEventProcessor.cs where IpAddress ??= context.Request.UserHostAddress never fires. SentryAspNetOptionsExtensions.cs shows the processor registration order. The test Process_PresetUserIP_NotOverwritten in SystemWebRequestEventProcessorTests.cs calls the processor directly, so it misses the enricher. Done means a System.Web event with user info on and no app-set IP carries a real client or chosen IP, with a test that runs both processors. The open question of which IP to use is still undecided.
Written by the indexing model from the issue text.
Description
When user info is on, events and transactions from classic ASP.NET apps never get the client's IP. They get {{auto}}, and Relay turns that into the address the server reaches Sentry from. This affects 5.15.1 and later. I found it while reviewing #5983.
What happens
- The enricher in
MainSentryEventProcessorsetsUser.IpAddressto{{auto}}when user info is on. SystemWebRequestEventProcessorruns after it, becauseAddAspNetregisters it withAddEventProcessor. ItsIpAddress ??= context.Request.UserHostAddressnever assigns anything, because the IP is already{{auto}}.- Relay resolves
{{auto}}torequest.env.REMOTE_ADDRwhen the event has one, and otherwise to the address the envelope came from. System.Web events have noREMOTE_ADDR, so they get the server's address, or the address of a NAT gateway or proxy in front of it. Relay then looks up the location of that IP, so the user shows up wherever the server runs.
Transactions go through the same enricher, and System.Web has no transaction processor, so they carry {{auto}} too.
ASP.NET Core doesn't have this problem. It puts the client IP on the scope's user before the SDK captures anything, and it also sets request.env.REMOTE_ADDR.
I confirmed the processor order with a probe on .NET 10. A processor added with AddEventProcessor that does the same ??= always sees {{auto}} when user info is on. I haven't run it end to end on IIS.
Who it affects
User info is on when the app calls ConfigureDataCollection and leaves UserInfo at its default of true. It's also on when the app doesn't call ConfigureDataCollection and sets SendDefaultPii = true.
| User info | The app sets User.IpAddress |
user.ip_address in Sentry |
|---|---|---|
| On | No | The server's IP |
| On | Yes | The app's value |
| Off | No | None |
How it got here
The enricher has set {{auto}} for apps with SendDefaultPii on since before 4.0.0. System.Web used to overwrite it with UserHostAddress, which also replaced IPs that apps set themselves, as #3337 reported. #4513 fixed that in 5.15.1 by switching to ??=, and since then {{auto}} wins.
Why the tests don't catch it
The SystemWebRequestEventProcessor tests call Process directly, so the enricher never runs. Process_PresetUserIP_NotOverwritten sets an IP before calling the processor, and the processor can't tell that apart from {{auto}}.
Open questions
- Which IP should a System.Web event carry when user info is on and the app didn't set one?
UserHostAddressis the address of the TCP connection, so behind a load balancer or a CDN it's the proxy's IP. #3337 asked for proxy handling too. - Should this wait for #4515, which wants System.Web to share ASP.NET Core's scope logic?
The same processor also replaces a username the app set on the scope, and the user ID when the principal has a name identifier claim. That's a separate bug, so it should get its own issue.
- Dominant language
- C#
- Stars
- 775
- Forks
- 262
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 118
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from getsentry/sentry-dotnet
-
chore: remove stale IL3050/IL3053 workaround from the iOS samplePossibly taken A pull request linked to this issue is open or already merged. OpenState: Needs Discussion
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
getsentry/sentry-dotnet#6071 · 1 comment ·
Maintainers usually reply within 1 day
-
Heap dumps: every SDK shutdown logs "Error waiting for GarbageCollectionMonitor task to complete"Possibly taken @pcbeingused33 claimed this today. OpenState: Needs Discussion
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
getsentry/sentry-dotnet#6039 · 3 comments ·
Maintainers usually reply within 1 day
-
.NET Platform: Android Task
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
getsentry/sentry-dotnet#6020 · 3 comments ·
Maintainers usually reply within 1 day
-
Move the Blazor WebAssembly sample off the deprecated DevServerPossibly taken A pull request linked to this issue is open or already merged. Open.NET Framework: Blazor
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
getsentry/sentry-dotnet#5906 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
Docs MSBuild Needs Docs Update
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
getsentry/sentry-dotnet#5691 · 1 comment ·
Maintainers usually reply within 1 day
All issues in getsentry/sentry-dotnet
Similar issues
-
In-car displays show 0 km/h and P while the AV drivesPossibly taken @bazilinskyy claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
bazilinskyy/coupled-sim#366 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
BaryoDev/umbraco-pwa#196 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
microsoft/fluentui-blazor#5688 ·
Maintainers usually reply within 1 day
-
bug flaky lsp-transport small
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day