Skip to content

Forgeable source IP in security audit / PHI-access event records (unvalidated X-Forwarded-For trust) #578

Open

Description

@MichaelLeeHobbs

Summary

The REST/API layer records the client source IP for every audited action (login success/failure, authorization checks, and PHI message access/export) by trusting the client-supplied X-Forwarded-For request header verbatim. There is no config gate and no restriction to trusted proxies. Because the HTTPS connector binds 0.0.0.0 by default and no reverse proxy is required, any client that can reach the API can set this header to an arbitrary value and forge the source IP written into the server's security/audit event log. That breaks the integrity and attribution of records that function as a HIPAA access-audit control over PHI, and defeats IP-based detection and alerting.

Affected version / commit

Commit dcd48b96dbbf73408f77ca89b19cb0a7886934de (2026-11-14). The pattern is inherited from upstream Mirth Connect.

Vulnerability class

CWE-348 (Use of Less Trusted Source: trusting a client-supplied header as the source IP), leading to an audit-integrity failure (CWE-778) and log-forgery / record-injection exposure (CWE-117), since the stored value is unbounded free-form attacker text.

Who can trigger it

Anyone who can send an HTTP(S) request to the API connector. The forged IP is recorded even for unauthenticated requests, because the login endpoint records the event for failed logins too. An authenticated low-privilege user can likewise forge the recorded IP on every audited operation, including PHI access/export events. No special role is required.

Locations

Source (returns the header verbatim):

Sinks that persist the forged value into audit/event records:

Input-to-sink evidence

1. Source. getRequestIpAddress() prefers the client-controlled header over the real socket address and applies no validation:

protected String getRequestIpAddress() {
    String address = request.getHeader("x-forwarded-for");
    if (address == null) {
        address = request.getRemoteAddr();
    }
    return address;
}

The real peer address (request.getRemoteAddr()) is used only as a fallback when the header is absent. Any present X-Forwarded-For value wins.

2. Sink. The returned value is written straight onto the persisted ServerEvent and dispatched to the event/audit log, with no checks, at AuthorizationController.java:63, UserServlet.java:131, MessageServlet.java:407, and the MirthServlet authorization path.

3. No guard in between. There is no config flag to enable or disable X-Forwarded-For trust, no allowlist of trusted upstream proxies, and no validation that the value is even an IP address. The same class already knows how to get the genuine peer address: isRequestLocal() uses request.getRemoteAddr() at MirthServlet.java:452. The audit path just doesn't use it.

Example: an attacker connecting directly from 203.0.113.9 and sending X-Forwarded-For: 10.0.0.5 (or any string) causes every resulting audit record, including a brute-force series of failed logins or a successful PHI export, to be attributed to 10.0.0.5.

Impact

  • Audit attribution is unreliable. The source IP field an operator or SIEM uses during incident response can be set to any value by the requester, attributing actions to an internal host, a colleague's workstation, or noise.
  • Defeats IP-based detection. Rules such as "N failed logins from one IP" or "PHI export from an unexpected IP" are evaded by rotating the header per request, and can be weaponized to frame an innocent address.
  • PHI-access audit integrity (HIPAA). The event log doubles as an access-audit trail over PHI; forgeable source IPs undermine its trustworthiness.
  • The stored value is unbounded free-form text, so it is also a log/record-injection vector into downstream consumers of the event log.

This is an integrity and accountability weakness, not a direct confidentiality or RCE bug. Its value to an attacker is in covering tracks and misdirecting investigation after some other action.

Suggested fix

  • Default to the real socket peer address (request.getRemoteAddr()) for all audit/event records.
  • Honor X-Forwarded-For only when an explicit config flag enables proxy-awareness and the immediate peer (getRemoteAddr()) is in an operator-configured list of trusted proxy addresses. When honored, parse the header correctly (take the right-most untrusted hop, not the attacker-chosen left-most entry) and validate it as an IP literal before storing.
  • Consider recording both the socket peer and any forwarded chain as distinct fields so audit consumers can tell the transport source from a claimed one.

Note

Found through source review of the public repository by an external contributor. Nothing has been exploited. Filing as a normal issue per guidance from pacmano1.

Activity

  1. MichaelLeeHobbs commented on Nov 16, 2026

    @MichaelLeeHobbs
    Author
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions