Repository navigation
Record the socket peer address in audit events - #600
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>
mgaffigan
left a comment
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.
|
Thanks. #620 adds that: The two are meant to land together. Merging #620 first, or both at once, avoids a window where proxied deploys record the proxy's address. Does that cover it, or would you rather have both in one PR? |
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.
#620 adds the opt-in trusted-proxy setting. With both merged, a proxied deploy lists its proxy in
server.api.trustedproxiesand events record the forwarded client address again.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