Skip to content

reject overflowing array index in decode_array_index_from_pointer - #1103

Open
nabhan06 wants to merge 1 commit into
DaveGamble:masterfrom
nabhan06:decode-array-index-overflow
Open

nabhan06 wants to merge 1 commit into
DaveGamble:masterfrom
nabhan06:decode-array-index-overflow

Conversation

@nabhan06

Copy link
Copy Markdown

Silent array-index overflow in decode_array_index_from_pointer

A JSON pointer / JSON Patch array index is accumulated digit by digit into a size_t with no overflow guard, so a numeric reference token larger than size_t wraps around. On 64-bit, /18446744073709551617 (2^64 + 1) wraps to index 1, so cJSONUtils_GetPointer and the patch add/remove/replace/move/copy operations resolve or target an in-range element the literal index never denotes, instead of failing as out of range. This is the same function that CVE-2025-57052 was fixed in. Reject any token that would exceed size_t.

Reproducer on master: cJSONUtils_GetPointer(cJSON_Parse("[10,20,30]"), "/18446744073709551617") returns the element 20 rather than NULL.

Regression test added in tests/misc_utils_tests.c.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant