/

CVE-2026-62296

Severity:

HIGH RISK

(7.5)

Uncontrolled Recursion (CWE-674) in HAPI FHIR XhtmlParser

CVE-2026-62296

Received

Vulnerability type

Category:

Uncontrolled Recursion

CWE:

CWE-20, CWE-400, CWE-674

Impact:

Denial of Service

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

HAPI FHIR's XHTML parser does not limit element nesting depth, allowing deeply nested FHIR narrative content to trigger unbounded recursion and a StackOverflowError. An attacker who can submit crafted FHIR JSON or XML may crash parsing or validation worker threads, disrupting services that process attacker-supplied resources.

Affected context

The issue occurs in applications using HAPI FHIR's XhtmlParser to process FHIR resources containing narrative content in text.div. It is most relevant when parsing or validation services accept FHIR JSON or XML from untrusted users or external systems and do not impose a maximum XHTML element nesting depth.

Exploit preconditions

  • Attack surface: FHIR resource parsing or validation that processes XHTML narrative content
  • Required access: Ability to submit or cause processing of a crafted FHIR JSON or XML resource
  • Trigger point: Parsing a deeply nested text.div narrative
  • Why exploitation is possible: The parser recursively processes nested elements without enforcing a maximum depth, allowing stack consumption to grow until the worker encounters a StackOverflowError

Why this happens

The underlying bug is uncontrolled recursive processing of attacker-influenced structured input. parseElementInner() and parseElement() continue calling one another for nested XHTML elements without a depth limit or equivalent resource bound. This maps primarily to CWE-674: Uncontrolled Recursion, with related concerns under CWE-20: Improper Input Validation and CWE-400: Uncontrolled Resource Consumption.

Potential impact

  • Parsing or validation worker threads may terminate unexpectedly
  • FHIR validator or ingestion services could become unavailable
  • Requests containing malicious narratives could consume excessive stack resources
  • Applications may experience reduced throughput or broader denial of service
  • Recovery activity could delay processing of legitimate healthcare interoperability messages

General mitigation guidance

Mitigation generally focuses on bounding parser resource consumption and reducing trust in externally supplied narrative content.

Common defensive patterns include:

  • Enforcing a configurable maximum element nesting depth before or during recursive parsing
  • Using iterative parsing or bounded traversal where practical
  • Applying limits to request size, narrative size, recursion depth, and processing time
  • Validating XHTML structure against a strict schema or permitted-content policy
  • Isolating parsing workers and assigning least-privilege permissions
  • Applying request throttling, concurrency limits, and controlled failure handling
  • Treating parser errors as isolated request failures rather than allowing worker-wide disruption

How teams detect issues like this

Organizations can look for this weakness through:

  • Static analysis rules that identify recursive parser calls lacking depth or resource guards
  • Code review checks for recursive processing of user-controlled XML, HTML, or tree-structured data
  • Fuzz testing with increasingly deep but syntactically valid nested elements
  • Runtime monitoring for repeated StackOverflowError events, parser crashes, elevated latency, or worker restarts
  • Policy enforcement requiring bounded parsing and resource quotas for externally supplied FHIR content

Automated security and code-quality review tools may help identify recursive input-processing paths, but should be supplemented with targeted parser testing.

Sources

SourceLink
github.comgithub.com/hapifhir/org.hl7.fhir.core/commit/396f447500407693d6ae1e64db59782862ca7506
github.comgithub.com/hapifhir/org.hl7.fhir.core/security/advisories/GHSA-5v24-q6x8-hc38

Frequently asked

questions

It can be remotely exploitable when a service accepts attacker-controlled FHIR JSON or XML and passes the content to the affected XHTML parser.

The attacker generally needs the ability to submit a FHIR resource for parsing or validation. The exact requirement depends on whether the application exposes public, authenticated, or trusted-partner ingestion endpoints.

Bound XHTML nesting depth and other parser resources, validate narrative content before processing, and isolate parser failures so one malformed resource cannot disrupt shared workers.

Use depth-limited or iterative parsers, enforce request and processing quotas, fuzz-test structured input handlers, and monitor for repeated parser exceptions or abnormal worker termination.

Find out what's already
exploitable in your codebase.