#1143048 cjson: CVE-2026-67215 CVE-2026-67216 CVE-2026-67217

Package:
src:cjson
Source:
src:cjson
Submitter:
Salvatore Bonaccorso
Date:
2026-11-03 05:25:01 UTC
Severity:
normal
Tags:
#1143048#5
Date:
2026-07-30 04:06:56 UTC
From:
To:
Hi,

The following vulnerabilities were published for cjson.

CVE-2026-67215[0]:
| cJSON through 1.7.19 is vulnerable to uncontrolled recursion leading
| to stack exhaustion when an untrusted RFC 6902 JSON Patch is applied
| via cJSONUtils_ApplyPatches() or
| cJSONUtils_ApplyPatchesCaseSensitive(). A patch containing add and
| copy operations grafts duplicated subtrees to amplify document depth
| beyond the parser's nesting limit: cJSON_Delete() recurses with no
| depth bound, and the cJSON_Duplicate() guard CJSON_CIRCULAR_LIMIT is
| set to 10000, ten times the parser's 1000-level nesting limit and
| high enough to overflow a default thread stack. An attacker who can
| supply the patch document can crash the process, resulting in denial
| of service.


CVE-2026-67216[1]:
| 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.


CVE-2026-67217[2]:
| cJSON through 1.7.19 applies RFC 6902 JSON Patch operations non-
| atomically in apply_patch() in cJSON_Utils.c. For a replace
| operation that is missing its value member, or a move operation
| whose destination path cannot be resolved, the existing target
| member is detached and deleted before the operation is fully
| validated, so the target document is mutated while
| cJSONUtils_ApplyPatches() or cJSONUtils_ApplyPatchesCaseSensitive()
| returns a failure status. An attacker who can supply the patch
| document can destroy addressable members of the target document even
| though the API reports that the patch failed, defeating the all-or-
| nothing behavior callers rely on to reject bad patches.

Those ar a subset of the 33 findings/reports of [3].


If you fix the vulnerabilities please also make sure to include the
CVE (Common Vulnerabilities & Exposures) ids in your changelog entry.

For further information see:

[0] https://security-tracker.debian.org/tracker/CVE-2026-67215
https://www.cve.org/CVERecord?id=CVE-2026-67215
[1] https://security-tracker.debian.org/tracker/CVE-2026-67216
https://www.cve.org/CVERecord?id=CVE-2026-67216
[2] https://security-tracker.debian.org/tracker/CVE-2026-67217
https://www.cve.org/CVERecord?id=CVE-2026-67217
[3] https://joshua.hu/cjson-json-parser-cve-vulnerabilities

Regards,
Salvatore

#1143048#10
Date:
2026-11-03 05:24:01 UTC
From:
To:
Hi,

Each of the three CVEs now has an open, mergeable upstream pull request
that names it. All three are from the same contributor and include
regression tests:

CVE-2026-67215
https://www.google.com/url?q=https://github.com/DaveGamble/cJSON/pull/1115&source=gmail&ust=1793769841720000&sa=E
"Cap JSON Patch graft depth at the nesting limit"
cJSON_Utils.c +74 -1, tests/misc_utils_tests.c
CVE-2026-67216
https://www.google.com/url?q=https://github.com/DaveGamble/cJSON/pull/1116&source=gmail&ust=1793769841720000&sa=E
"Bound cJSON_Compare cost: sort-based objects, depth cap"
cJSON.c +133 -26, cJSON_Utils.c +122 -20, tests/compare_tests.c
CVE-2026-67217
https://www.google.com/url?q=https://github.com/DaveGamble/cJSON/pull/1114&source=gmail&ust=1793769841720000&sa=E
"Apply JSON Patch arrays atomically"
cJSON_Utils.c +36 -29, cJSON_Utils.h (comment only),
tests/misc_utils_tests.c

Verified on the Debian 1.7.19-2 source with its patch applied. I built
with cmake, -DENABLE_CJSON_UTILS=On and -DENABLE_SANITIZERS=On (ASan+UBSan,
leak checking on).

- Each PR applies cleanly on its own (#1116 with offsets only).
- All three together, plus #1120 for CVE-2026-29036 (#1146718), also
apply. The only conflict is between #1114 and #1115, which add tests
at the same place in tests/misc_utils_tests.c; I merged that by hand.
- Full test suite: 22/22 passed for each PR alone and for all four
combined, with no sanitizer reports.
- Each PR's new regression test fails on unpatched 1.7.19-2 and passes
with the PR:
#1115 apply_patches_should_reject_grafts_past_the_nesting_limit
#1116 cjson_compare_should_fail_safe_past_nesting_limit
#1114 apply_patches_should_leave_document_untouched_when_a_patch_fails

Notes for whoever takes this:
- #1114 changes documented behaviour. cJSONUtils_ApplyPatches() and
ApplyPatchesCaseSensitive() become atomic; the old header comment said
they were explicitly not, and suggested a duplicate-and-swap wrapper.
There is no ABI change (the header change is only that comment), but
callers that relied on partial application would see a difference.
- #1116 also changes cJSON.c (cJSON_Compare), so it affects libcjson1
as well as libcjson-utils.
- None of these are merged upstream yet (no release since 1.7.19), so
waiting for review there may be preferable to carrying them.

Thanks!