Summary
A Saxon-based XML transformation utility in HAPI FHIR instantiates a TransformerFactory without restricting external DTD or stylesheet access, enabling XML External Entity (XXE) injection.
When an attacker can control or tamper with XML passed into these transforms, they can attempt local file disclosure and blind XXE or SSRF to internal or external URLs reachable from the host.
Affected context
This vulnerability occurs in HAPI FHIR deployments that rely on org.hl7.fhir.utilities.XsltUtilities.saxonTransform(...) overloads using Saxon for XML/XSLT processing.
It is relevant when application flows accept XML that can be influenced, crafted, or intercepted by an adversary and then pass that XML into the vulnerable transformation logic.
Configurations where external entities or network access are permitted to the runtime environment are more exposed, though effective damage depends on filesystem layout, service reachability, and the privileges of the HAPI FHIR process.
Exploit preconditions
- Attack surface: XML inputs passed to
XsltUtilities.saxonTransform(...)(including XSLT or XML documents used by that utility). - Required access: Ability to supply or modify XML being transformed, such as via API endpoints, integration interfaces, or configuration-driven transformation pipelines.
- Trigger point: Execution of the Saxon-based XSLT transformation that parses attacker-influenced XML containing external entity references or external stylesheet URLs.
- Why exploitation is possible: The code instantiates
net.sf.saxon.TransformerFactoryImplwithout settingACCESS_EXTERNAL_DTDorACCESS_EXTERNAL_STYLESHEETrestrictions, so the XML processor can resolve external entities and remote resources controlled by the attacker.
Why this happens
The core bug lies in unsafe XML processing configuration: the transformation logic creates a generic Saxon TransformerFactoryImpl instance without explicitly disabling external entity resolution and external resource access.
This maps to CWE-611: Improper Restriction of XML External Entity Reference, where XML parsers or transformers are left with defaults that allow external DTDs, entities, or stylesheets to be fetched and processed.
Conceptually, the pattern is trusting XML input as purely data while using a library that treats XML as instructions capable of initiating file reads or network calls, leading to data exfiltration and server-side interactions beyond the intended scope.
Potential impact
- Local file disclosure from the host filesystem via crafted external entities.
- Blind XXE attacks that infer data or behavior based on parser error messages or timing.
- Server-Side Request Forgery (SSRF) to internal services and metadata endpoints accessible from the HAPI FHIR host.
- Interaction with external URLs that may facilitate secondary attacks or data exfiltration.
- Expanded attack surface for chaining with other vulnerabilities (e.g., internal admin interfaces, cloud metadata, or privileged services).
General mitigation guidance
Effective mitigation focuses on hardening XML processing configuration and reducing trust in XML supplied by external or semi-trusted sources.
Typical defensive patterns include:
- Configuring XML and XSLT processors to disable external entity resolution and external stylesheet loading by default.
- Applying explicit restrictions via secure processor properties (e.g., limiting or denying
ACCESS_EXTERNAL_DTDandACCESS_EXTERNAL_STYLESHEETto trusted locations only). - Treating XML and XSLT inputs as untrusted unless they originate from controlled, authenticated, and integrity-protected sources.
- Segregating transformation logic from sensitive filesystem areas and high-value internal services, combined with least-privilege execution for the HAPI FHIR process.
- Incorporating secure configuration templates so that new XML processing utilities inherit locked-down defaults without requiring per-call overrides.
How teams detect issues like this
Organizations can identify similar XXE risks with a mix of automated and manual techniques:
- Static analysis or custom rules that flag XML parsers and transformers instantiated without secure properties or with external access enabled.
- Code review checklists that require verification of entity expansion settings and external resource restrictions for all XML/XSLT utilities.
- Centralized configuration policies ensuring XML processing libraries are wrapped by secure factory methods rather than directly instantiated.
- Runtime monitoring or testing using benign XXE/SSRF probes in staging environments to confirm that external entities and remote URLs are blocked rather than resolved.

