Summary
The HAPI FHIR Java client may send the same set of HTTP headers, including privacy-sensitive or authentication-related data, to both the original host and any redirect targets when following 30X responses.
If an attacker can influence redirect destinations, this behavior can expose confidential healthcare or session information to unintended hosts and enable request impersonation.
Affected context
This vulnerability affects applications using the HAPI FHIR Java client that:
- Configure the client to follow HTTP redirects (30X status codes)
- Attach sensitive headers to outgoing requests (e.g., authentication tokens, cookies, API keys, patient-identifying headers)
- Interact with servers or intermediaries that may issue redirects to different hostnames
The issue manifests when the same headers are automatically forwarded to the host specified in the Location header, which may not be under the same administrative or trust domain as the original endpoint.
Exploit preconditions
- Attack surface: Outbound HTTP requests made by the HAPI FHIR client.
- Required access: Ability to influence or control an HTTP redirect target (e.g., control of an upstream server, MITM on the network path, or poisoning of a redirect endpoint).
- Trigger point: A request with sensitive headers is sent to a legitimate host, which responds with a 30X redirect pointing to an attacker-controlled or untrusted host.
- Why exploitation is possible: The client reuses the same headers, including sensitive ones, when following redirects to a different host, effectively disclosing these headers to the new endpoint.
Why this happens
The core issue lies in the HTTP client's redirect handling logic that does not differentiate between same-origin and cross-origin redirects when propagating headers.
Instead of selectively forwarding only non-sensitive or origin-appropriate headers to redirected hosts, the client blindly re-sends the entire header set from the original request.
This aligns with CWE-200: Information Exposure, as internal or sensitive data contained in headers is exposed to unintended recipients due to insufficient access control and origin checks during redirect processing.
Potential impact
- Exposure of authentication tokens, API keys, or session identifiers to untrusted hosts.
- Leakage of patient-identifying or other regulated healthcare data present in custom headers.
- Ability for an attacker to reuse captured headers to impersonate the client in subsequent requests.
- Cross-domain leakage of internal routing or environment information contained in proprietary headers.
- Increased risk of compliance violations in environments subject to privacy regulations.
General mitigation guidance
Mitigation generally focuses on tightening redirect handling and reducing header sensitivity:
- Adopt HTTP client patterns that validate redirect targets, limiting automatic redirects to trusted hostnames or same-origin domains.
- Implement a header policy that whitelists which headers may be forwarded on redirects, especially when the redirect crosses host or domain boundaries.
- Separate highly sensitive credentials from general-purpose headers, using scoped, least-privilege tokens and minimizing patient or identity data in transport headers.
- Enforce architectural patterns where back-end systems perform sensitive operations server-side, reducing the reliance on long-lived or highly privileged tokens in client requests.
- Apply defense-in-depth by combining TLS, strict certificate validation, and network controls to reduce opportunities for malicious redirect injection.
How teams detect issues like this
Organizations can approach detection with a combination of code and traffic analysis:
- Static analysis & code review:
- Identify uses of the HAPI FHIR client where redirect-following is enabled.
- Look for client configuration or wrapper logic that attaches sensitive headers to all requests without considering redirect contexts.
- Flag patterns where authentication or patient-specific information is placed directly in custom headers.
- Dynamic analysis & logging:
- Enable detailed HTTP client logging (without storing full secrets) to capture redirect chains and review which hosts receive which headers.
- Use proxy or API gateway logs to detect sensitive headers being sent to unexpected domains.
- Policy enforcement:
- Introduce lints or CI checks that require explicit justification for cross-domain redirects.
- Use automated security testing tools to simulate redirect scenarios and verify that sensitive headers are not propagated to untrusted hosts.

