CVE-2024-27454

7.5 HIGH

📋 TL;DR

CVE-2024-27454 is a vulnerability in orjson's loads function that fails to limit recursion depth when parsing deeply nested JSON documents. This allows attackers to cause denial of service (DoS) by crashing the application through stack exhaustion. Any application using vulnerable versions of orjson to parse untrusted JSON data is affected.

💻 Affected Systems

Products:
  • orjson
Versions: All versions before 3.9.15
Operating Systems: All platforms where orjson is used
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects the loads() function when parsing deeply nested JSON. The dumps() function is not affected.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete application crash leading to denial of service, potentially affecting availability of dependent services.

🟠

Likely Case

Application crashes when processing malicious JSON payloads, causing temporary service disruption.

🟢

If Mitigated

No impact if JSON input is validated or comes from trusted sources only.

🌐 Internet-Facing: HIGH - Web applications accepting JSON input from untrusted sources are directly vulnerable.
🏢 Internal Only: MEDIUM - Internal services processing JSON from controlled sources have lower risk.

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

Exploitation requires sending a specially crafted JSON document with deep nesting. Proof of concept is available in GitHub issues.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 3.9.15

Vendor Advisory: https://github.com/ijl/orjson/blob/master/CHANGELOG.md#3915

Restart Required: No

Instructions:

1. Update orjson package using pip: pip install --upgrade orjson>=3.9.15
2. Verify the update with: pip show orjson
3. No application restart needed for Python package updates.

🔧 Temporary Workarounds

Input validation and depth limiting

all

Validate JSON input depth before passing to orjson.loads()

# Python example:
import json
import sys

def safe_loads(json_str, max_depth=1000):
    parsed = json.loads(json_str)
    # Check depth of parsed structure
    def check_depth(obj, current=0):
        if current > max_depth:
            raise ValueError('JSON nesting too deep')
        if isinstance(obj, dict):
            for v in obj.values():
                check_depth(v, current+1)
        elif isinstance(obj, list):
            for v in obj:
                check_depth(v, current+1)
    check_depth(parsed)
    return parsed

🧯 If You Can't Patch

  • Implement strict input validation to reject JSON documents with excessive nesting depth
  • Use alternative JSON parsers with recursion limits for untrusted input

🔍 How to Verify

Check if Vulnerable:

Check orjson version: python -c "import orjson; print(orjson.__version__)" and compare with 3.9.15

Check Version:

python -c "import orjson; print('orjson version:', orjson.__version__)"

Verify Fix Applied:

Test with a deeply nested JSON document to ensure it raises an exception instead of crashing

📡 Detection & Monitoring

Log Indicators:

  • Application crashes with stack overflow errors
  • High memory usage spikes during JSON parsing
  • Python interpreter segmentation faults

Network Indicators:

  • Large JSON payloads with repeated nesting patterns
  • Multiple failed requests to JSON endpoints

SIEM Query:

source="application.logs" AND ("stack overflow" OR "segmentation fault" OR "RecursionError") AND process="python"

🔗 References

📤 Share & Export