Summary
HAPI FHIR's JSON parser does not enforce a maximum nesting depth for arrays or objects, allowing deeply nested but syntactically valid FHIR JSON to trigger excessive recursion.
An attacker who can submit JSON resources for validation may cause a request thread to fail with StackOverflowError, potentially resulting in denial of service or broader process instability when the error is not safely isolated.
Affected context
The issue occurs in HAPI FHIR deployments that use the affected JSON utility parser to process attacker-influenced FHIR resources. It becomes risky when submitted JSON can contain deeply nested arrays or objects and the service lacks parser depth limits, request isolation, or safe handling for stack exhaustion errors.
Exploit preconditions
- Attack surface: An endpoint or service that accepts FHIR JSON for parsing or validation
- Required access: Ability to submit or cause processing of a JSON resource
- Trigger point: Recursive array or object parsing before structural validation completes
- Why exploitation is possible: The parser permits unbounded nesting depth, allowing recursion to exhaust the request thread's stack
Why this happens
The underlying bug is an uncontrolled-recursion condition mapped to CWE-674. Array and object parsing recursively descends through nested JSON structures without enforcing a maximum depth, so a relatively small input can consume the available call stack before normal validation controls run.
The related lack of input-size or resource-consumption limits also aligns with CWE-400, while insufficient structural validation before resource consumption relates to CWE-20.
Potential impact
- Affected request threads may terminate with StackOverflowError
- FHIR validation or ingestion services may become unavailable
- Worker capacity could be reduced under repeated requests
- The hosting process may become unstable if stack exhaustion is not isolated safely
- Dependent healthcare interoperability workflows could experience delays
General mitigation guidance
Mitigation generally focuses on bounding parser resource consumption and isolating failures.
Common defensive patterns include:
- Enforcing explicit maximum nesting depth for arrays and objects
- Applying request-size, structure, and processing-time limits before deep parsing
- Using iterative parsing or bounded recursion where practical
- Validating input structure incrementally rather than after unrestricted traversal
- Isolating parser failures at the request boundary and handling stack exhaustion safely
- Running validation workers with least privilege and controlled resource quotas
- Rejecting malformed, excessively complex, or policy-disallowed resources by default
How teams detect issues like this
Organizations can look for this class of issue through:
- Static analysis rules identifying recursive parsers without depth guards
- Code review checks for missing limits on nesting, input size, and parser work
- Tests using progressively deeper arrays and objects to confirm bounded behavior
- Runtime monitoring for StackOverflowError, repeated validation failures, and worker exhaustion
- API gateway or policy controls that enforce request complexity limits
Automated security review tools may help identify recursive parsing paths that lack explicit resource bounds.

