Описание
HAPI FHIR: Incomplete fix for CVE-2026-45367: DSTU2 FHIRPathEngine.matches() missing RegexTimeout protection allows ReDoS
Summary
The fix for CVE-2026-45367 added RegexTimeout protection to the matches() function in DSTU2016MAY, DSTU3, R4, R4B, and R5, but the DSTU2 module was incompletely patched. In org.hl7.fhir.dstu2, replaceMatches() was updated while matches() at line 2462 still calls the raw String.matches(sw) without any timeout, allowing an unauthenticated attacker to trigger catastrophic regex backtracking and exhaust server CPU.
Details
Incomplete patch
Within the same file
(org.hl7.fhir.dstu2/utils/FHIRPathEngine.java), the two functions were
patched inconsistently:
Line 2226 — replaceMatches() — PATCHED:
Line 2462 — matches() — NOT PATCHED:
DSTU3 line 2447 — matches() — PATCHED (for comparison):
Module-by-module status
| Module | matches() | replaceMatches() |
|---|---|---|
| DSTU2 | ❌ raw str.matches(sw) | ✅ RegexTimeout.replaceAll() |
| DSTU2016MAY | ✅ RegexTimeout.matches() | ✅ |
| DSTU3 | ✅ RegexTimeout.matches() | ✅ |
| R4 | ✅ RegexTimeout.matches() | ✅ |
| R4B | ✅ RegexTimeout.matches() | ✅ |
| R5 | ✅ RegexTimeout.matches() | ✅ |
PoC
Requirements: Java 17+, Maven 3.8+
pom.xml dependencies:
Test code (reproduces the exact behaviour of DSTU2 line 2462):
Verified output (JDK 25.0.3, Linux):
The patched approach cuts off the evaluation at 508 ms. The unpatched DSTU2 code runs for 1410 ms on this input with no mechanism to stop it. Longer inputs or more complex patterns produce proportionally worse results.
Impact
Vulnerability type: Regular Expression Denial of Service (ReDoS) causing CPU exhaustion and service disruption.
Who is impacted: Any application using the ca.uhn.hapi.fhir:org.hl7.fhir.dstu2 module that evaluates user-supplied FHIRPath expressions — including the FHIR Validator HTTP endpoint, FHIR servers applying FHIRPath invariants from user-provided resources or profiles, and any system embedding FHIRPathEngine from the DSTU2 module. No authentication is required; an attacker needs only to submit a FHIR resource or FHIRPath expression whose matches() argument contains a catastrophically backtracking regular expression.
Пакеты
ca.uhn.hapi.fhir:org.hl7.fhir.dstu2
<= 6.9.9
6.9.10
ca.uhn.hapi.fhir:org.hl7.fhir.convertors
<= 6.9.9
6.9.10
ca.uhn.hapi.fhir:org.hl7.fhir.validation
<= 6.9.9
6.9.10
ca.uhn.hapi.fhir:org.hl7.fhir.validation.cli
<= 6.9.9
6.9.10
Связанные уязвимости
HAPI FHIR is a complete implementation of the HL7 FHIR standard for healthcare interoperability in Java. Prior to 6.9.10, the fix for CVE-2026-45367 incompletely patched the DSTU2 module, leaving FHIRPathEngine.matches() in org.hl7.fhir.dstu2/utils/FHIRPathEngine.java to call raw String.matches(sw) without RegexTimeout protection while replaceMatches() was updated, allowing an unauthenticated attacker to trigger catastrophic regex backtracking and exhaust server CPU. This issue is fixed in version 6.9.10.
HAPI FHIR is a complete implementation of the HL7 FHIR standard for healthcare interoperability in Java. Prior to 6.9.10, the fix for CVE-2026-45367 incompletely patched the DSTU2 module, leaving FHIRPathEngine.matches() in org.hl7.fhir.dstu2/utils/FHIRPathEngine.java to call raw String.matches(sw) without RegexTimeout protection while replaceMatches() was updated, allowing an unauthenticated attacker to trigger catastrophic regex backtracking and exhaust server CPU. This issue is fixed in version 6.9.10.