← Back to Pull requests

Record the socket peer address in audit events #600

Open
unknown opened this pull request with 201 lines diff across 2 files
View on GitHub
unknown unknown commented on Nov 25, 2026 03:03 UTC
Author

Fixes #578

MirthServlet.getRequestIpAddress() returned the X-Forwarded-For header verbatim whenever a client sent one, so any client could choose the source IP stored on login, authorization and message-access events. It now returns request.getRemoteAddr(), which was already the fallback. This is the first item of the issue's suggested fix.

It also closes a second problem the issue doesn't mention. EVENT.IP_ADDRESS is VARCHAR(40) and DefaultEventController.insertEvent logs insert failures without rethrowing them. From reading that code, a header longer than 40 characters would fail the insert and lose the event. I did not reproduce this against a database.

Behavior change

Behind a reverse proxy, events now record the proxy's address instead of the client's. Events are unchanged for clients that connect directly without sending the header.

I left out the trusted-proxy setting the issue proposes, so this PR adds no configuration. If reviewers need proxy support before this merges, I can add it here.

How to verify

  • ./gradlew :server:test --tests '*MirthServletTest'. The new test, getRequestIpAddressIgnoresForwardedForHeader, fails without the change and passes with it.

  • Or log in through the API with an X-Forwarded-For: 10.0.0.5 header and check the IP address on the Login event.
  • I ran the server unit tests on Windows. 876 ran and 11 failed, all in DICOMSerializerTest and NCPDPSerializerTest. The same 11 fail on main at 8e5e63da3 without this change. I did not run the live login check.

    🤖 Generated with Claude Code

    Diff: 201 lines (+150 / -51) across 2 files Reviewer: mgaffigan Review duration: 7998m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.36) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.36 · 201 lines diff across 2 files
    0.36
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.318
    Real PR Conversation Timeline
    1 comments
    "Review active on #600"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 36.2% (MEDIUM) · Higher = larger blast radius
    36.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 43.0% · Lower = rushed or shallow review
    43.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.7% · Safe to merge
    20.7%