Summary
HAPI FHIR's SHCParser may allocate excessive memory when processing an attacker-controlled Smart Health Card JWT containing a compressed payload that expands dramatically. An application or validator that accepts such content could experience severe garbage-collection pressure, failed requests, process instability, or termination.
Affected context
The issue can arise in HAPI FHIR deployments that accept and validate attacker-supplied Smart Health Card content before version 6.9.12. It is relevant when the SHCParser handles JWT headers requesting raw DEFLATE decompression and processes the expanded content without an effective output-size boundary.
Exploit preconditions
- Attack surface: An application, API, or validator service that accepts Smart Health Card content - Required access: Ability to submit attacker-controlled SHC JWT content - Trigger point: JWT payload decompression in SHCParser before JSON parsing completes - Why exploitation is possible: Compressed input can expand to a very large value while decompressed bytes are accumulated without an output-size limit
Why this happens
The parser uses an unbounded decompression pattern in which output bytes are accumulated in memory before the resulting content is parsed as JSON. A small raw-DEFLATE payload can therefore expand into a disproportionately large in-memory value. This maps primarily to CWE-400, Resource Exhaustion, and is also associated with CWE-409, Improper Handling of Highly Compressed Data, because compression expansion is not bounded.
Potential impact
- An attacker may exhaust application heap memory.
- Requests could fail or experience substantial latency.
- The service could suffer severe garbage-collection pressure.
- The application process could become unstable or terminate.
- Availability of dependent healthcare interoperability services could be reduced.
General mitigation guidance
Mitigation generally focuses on bounding resource consumption throughout the decompression and parsing pipeline. Secure-by-default designs can enforce maximum compressed and decompressed sizes, reject payloads that exceed application-specific limits, and use streaming or quota-aware processing rather than unbounded in-memory accumulation. Input trust should be reduced through strict structural and schema validation before expensive processing, with timeouts, request-size limits, concurrency controls, and isolation applied where appropriate. Services should run with only the privileges and resource capacity required for their function, and defensive behavior should avoid exposing process-wide availability to a single request.
How teams detect issues like this
Detection approaches can include static analysis for decompression loops that write indefinitely to memory buffers, review of parser code for missing output and input limits, and tests using highly compressible content with controlled expansion ratios. Code review should examine every decompression path, including helper methods and alternate parsing entry points. Runtime monitoring can alert on abnormal heap growth, garbage-collection activity, request sizes, decompression ratios, latency, and process restarts. Policy enforcement may require explicit resource limits for parsers handling untrusted compressed data, while automated review tools can help identify unbounded decompression patterns.

