Repository navigation
Record the socket peer address in audit events - #600
Open
MichaelLeeHobbs wants to merge 1 commit into
Open
MichaelLeeHobbs wants to merge 1 commit into
MichaelLeeHobbs wants to merge 1 commit into
Conversation
Audit events took their source IP from the client-supplied X-Forwarded-For header, so any client could forge it (fixes OpenIntegrationEngine#578). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Michael Hobbs <michael.lee.hobbs@gmail.com>
MichaelLeeHobbs
marked this pull request as ready for review
November 25, 2026 03:11
MichaelLeeHobbs
requested review from
a team,
NicoPiel,
gibson9583,
jonbartels,
kayyagari,
kpalang,
pacmano1 and
ssrowe
November 25, 2026 03:11
mgaffigan
requested changes
Nov 25, 2026
mgaffigan
left a comment
Contributor
There was a problem hiding this comment.
Given the status quo is the ability to take forwarded for headers, I presume the appropriate fix is a failure to apply trusted networks - not to ignore the header entirely. I rely upon this behavior today in containerized deploys.
I agree it is reasonable to ignore the header by default. A flat enable/disable list (trust 0.0.0.0/0 and ::0/0) is likely sufficient for now, since listen controls can limit bind.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #578
MirthServlet.getRequestIpAddress()returned theX-Forwarded-Forheader verbatim whenever a client sent one, so any client could choose the source IP stored on login, authorization and message-access events. It now returnsrequest.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_ADDRESSisVARCHAR(40)andDefaultEventController.insertEventlogs 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.X-Forwarded-For: 10.0.0.5header and check the IP address on the Login event.I ran the server unit tests on Windows. 876 ran and 11 failed, all in
DICOMSerializerTestandNCPDPSerializerTest. The same 11 fail onmainat 8e5e63d without this change. I did not run the live login check.🤖 Generated with Claude Code