Description
cJSON through 1.7.19 contains an inefficient algorithmic complexity flaw in cJSON_Compare(). When comparing objects, the function recurses into each shared subtree twice, once in each direction, with no depth guard, making the running time exponential in nesting depth. A small, deeply nested document of a few hundred bytes (depth around 40) compared for equality consumes hours of CPU, and the cost roughly doubles with each additional level of nesting. An application that calls cJSON_Compare() on attacker-influenced JSON that is structurally equal to a reference document is exposed to a denial-of-service condition.
Metrics
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:HWeakness enumeration
Affected software
| Vendor | Product | Versions |
|---|---|---|
| DaveGamble | cJSON | <= 1.7.19 |
References
- https://github.com/DaveGamble/cJSON/blob/v1.7.19/cJSON.c#L3057-L3180Patch
- https://joshua.hu/cjson-json-parser-cve-vulnerabilitiesExploit, Press/Media Coverage, Third Party Advisory
- https://www.vulncheck.com/advisories/cjson-cjson-compare-exponential-complexity-denial-of-serviceThird Party Advisory
Timeline
- Published
- Jul 29, 2026
- Last modified
- Oct 23, 2026
- NVD status
- Analyzed