cJSON, Algorithmic Complexity Denial of Service, CVE-2026-67216 (High) -DC-Aug2026-1323

Listen to this Post

CVE-2026-67216 exposes a critical algorithmic complexity vulnerability within the cJSON library, specifically in the `cJSON_Compare()` function. This function is designed to compare two cJSON items for structural and value equality. The flaw arises from the way the function handles nested objects during comparison. When `cJSON_Compare()` encounters two objects, it recursively traverses each shared subtree twice—once in each direction—to verify equality. This bidirectional recursion is performed without any depth guard or cycle detection mechanism.
Under normal circumstances, this approach might be acceptable for shallow JSON structures. However, an attacker can craft a small, deeply nested JSON document, as little as a few hundred bytes, with a nesting depth of around 40 levels. When such a document is compared against a structurally equal reference document, the recursion explodes exponentially. Each additional level of nesting roughly doubles the computational cost, turning a trivial comparison into a CPU-intensive operation that can consume hours of processing time.
The core issue is that `cJSON_Compare()` does not limit recursion depth, nor does it employ memoization or early termination strategies. As a result, the time complexity grows as O(2^n) where n is the nesting depth. This makes the library vulnerable to a denial-of-service (DoS) attack. An application that calls `cJSON_Compare()` on attacker-influenced JSON—for instance, when validating user-supplied configuration or comparing cached data—can be forced into a state of extreme CPU exhaustion.
The vulnerability affects all versions of cJSON up to and including 1.7.19. The NVD has assigned a CVSS 3.1 base score of 7.5 (High) with the vector AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H, indicating that the attack can be launched remotely without authentication, requires low attack complexity, and results in high availability impact. The weakness is classified under CWE-407 (Inefficient Algorithmic Complexity).
This vulnerability is particularly concerning because cJSON is widely used in embedded systems, IoT devices, server-side applications, and is vendored into numerous frameworks including ESP-IDF. A successful exploit can render services unresponsive, leading to service disruption and potential financial or operational losses. As of the publication date, no official patch has been released, though the open-source community is actively discussing mitigation strategies.

DailyCVE Form:

Platform: cJSON library
Version: 1.7.19 and earlier
Vulnerability: Inefficient algorithmic complexity in cJSON_Compare()
Severity: High (CVSS 3.1 7.5)
date: 2026-07-29

Prediction: 2026-08-20

What Undercode Say:

Analytics:

  • Affected component: cJSON_Compare() function
  • Attack vector: Remote, unauthenticated
  • Required payload size: ~200 bytes (depth 40)
  • CPU consumption: hours for single comparison
  • Scaling: Cost doubles per nesting level
  • Exploit reliability: High, deterministic
  • Known affected software: ESP-IDF, FreeSWITCH, Ubuntu packages
  • CWE mapping: CWE-407
  • CVSS 4.0 score: 8.2 (High) per VulnCheck

Bash Commands & Codes:

Check installed cJSON version (Debian/Ubuntu)
dpkg -l | grep libcjson
Check cJSON version in ESP-IDF
grep -r "CJSON_VERSION" /path/to/esp-idf/components/json/
Generate a deeply nested JSON payload (depth 40)
python3 -c "import json; d={}; cur=d;
for i in range(40): cur['x']={}; cur=cur['x'];
print(json.dumps(d))" > payload.json
Simulate CPU exhaustion using cJSON test harness (if available)
./cJSON_test compare payload.json reference.json

C Code Snippet Demonstrating Vulnerability:

include <stdio.h>
include "cJSON.h"
int main() {
// Assume deeply nested JSON strings are loaded from attacker input
char deep_json = "{\"x\":{\"x\":{\"x\":{...}}}}"; // depth 40+
cJSON a = cJSON_Parse(deep_json);
cJSON b = cJSON_Parse(deep_json); // structurally equal
// This call will consume exponential CPU time
int result = cJSON_Compare(a, b, 1);
cJSON_Delete(a);
cJSON_Delete(b);
return 0;
}

Exploit:

An attacker can exploit this vulnerability by submitting a specially crafted, deeply nested JSON document to any application that uses `cJSON_Compare()` to compare user-supplied JSON against a reference. The payload is small (a few hundred bytes) but triggers exponential recursion. The attacker does not need to be authenticated, and the attack can be performed over the network. Once the comparison is initiated, the CPU becomes pinned at 100%, leading to denial of service for other processes and potentially crashing the system if watchdog timers are not configured.

Protection:

  • Upgrade to a patched version once released by the cJSON maintainers.
  • Avoid using `cJSON_Compare()` on untrusted JSON input.
  • Implement a recursion depth limiter in wrapper functions before calling cJSON_Compare().
  • Use alternative JSON comparison libraries that are resistant to algorithmic complexity attacks.
  • Deploy Web Application Firewalls (WAF) or input validation filters to reject deeply nested JSON structures (e.g., limit nesting depth to < 20).
  • Monitor CPU usage and implement rate limiting for endpoints that process JSON comparisons.

Impact:

Successful exploitation results in a denial-of-service condition where the target application becomes unresponsive due to excessive CPU consumption. This can lead to service outages, loss of availability, and in multi-tenant environments, impact other co-hosted services. For embedded systems, the device may become entirely unresponsive, requiring a hard reset. The attack requires minimal bandwidth and can be executed repeatedly to maintain the DoS state, making it a persistent threat until the vulnerability is patched or mitigations are applied.

🎯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: nvd.nist.gov
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