Summary
HAPI FHIR's SHCParser can enter an infinite loop while processing malformed Smart Health Card JWT content that uses raw-DEFLATE compression. An attacker who can submit such content may cause a JVM worker thread to remain occupied, potentially exhausting validation workers and creating a denial-of-service condition.
Affected context
The issue may affect HAPI FHIR deployments that parse Smart Health Card JWTs and accept attacker-controlled compressed or partially compressed content. The vulnerable parsing path can also be reached during file-format detection, so malformed input may trigger the behavior before normal validation completes. Risk is greater in services that process requests using a finite pool of JVM worker threads.
Exploit preconditions
- Attack surface: Smart Health Card JWT or related resource-validation input - Required access: Ability to submit or cause processing of attacker-controlled
token content
- Trigger point: DEFLATE decompression performed by SHCParser during JWT
decoding or resource format detection
- Why exploitation is possible: A decompression loop does not terminate when
the inflater makes no progress, requires more input, or requires a preset
dictionary, allowing a malformed stream to keep a worker thread busy
Why this happens
The underlying bug is an uncontrolled loop in decompression handling. The parser repeatedly calls the inflater without treating zero progress, missing input, or dictionary requirements as terminal conditions. This behavior maps to CWE-835, Infinite Loop, and is also related to CWE-400 because a malformed input can consume a worker indefinitely. Insufficient validation of compressed input is additionally consistent with CWE-20.
Potential impact
- A malformed request may pin a JVM worker thread indefinitely
- Concurrent requests could exhaust validation worker capacity
- The service may become slow, unavailable, or unable to process legitimate requests
- Dependent interoperability or clinical workflow services could experience delays
General mitigation guidance
Mitigation generally focuses on making decompression loops progress-aware and bounded. Secure parser designs should terminate when decompression reports zero progress, needs additional input, has completed, or requires a dictionary that is not available. Compressed input should be subject to explicit size, expansion, time, and processing limits before and during parsing. Validation should reject malformed or truncated content early, and worker pools should use resource isolation, bounded queues, and least privilege so that parser failures do not consume all service capacity. Deployments should use a vendor-maintained corrected implementation through their normal dependency-management process.
How teams detect issues like this
Static analysis can look for decompression loops that omit checks for zero-progress results, end-of-stream state, required dictionaries, or unavailable input. Code review should examine all wrappers around inflater APIs, including shared helpers and format-detection paths, for bounded termination and resource limits. Dynamic testing should include empty, truncated, dictionary-dependent, and malformed compressed streams while monitoring thread occupancy and request latency. Runtime policies can enforce request-size, decompression, timeout, and worker-utilization thresholds. Automated security review tools may help identify suspicious loop and decompression patterns.

