[Security] Logic Tampering via NULL byte (\u0000) Injection in cJSON_Utils Key Names
Maintainer thường phản hồi trong vòng 12 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 55/100
Hướng nghiên cứu
Bắt đầu với tests/old_utils_tests.c và chạy các lệnh cJSON_Utils build và ./tests/old_utils_tests trong báo cáo. Đọc các đường dẫn MergePatch và GeneratePatch để xem tên khóa được đối sánh như thế nào. Được xem là hoàn tất khi khóa admin hiện có vẫn khác biệt với admin\u0000hacked và cả hai bài kiểm thử tiện ích đều chạy thành công với đối tượng đã hợp nhất và patch như mong đợi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Clear and concise description of the bug:
A logic tampering vulnerability exists in cJSON_Utils due to improper handling of NULL characters (\u0000) in JSON key names. While the cJSON core library correctly parses \u0000 and stores it as a 0x00 byte in memory, the cJSON_Utils component (specifically MergePatch and GeneratePatch) relies on standard C string functions like strcmp for key matching.
Because strcmp terminates at the first \0 byte, a cross-layer semantic inconsistency occurs: the JSON parser treats a long key containing a NULL byte as unique, but the utility logic truncates the key and incorrectly matches it against shorter, existing keys. This can lead to unauthorized data overwriting or "silent ignore" defects in differential synchronization.
Steps to reproduce the bug :
1.Modify tests/old_utils_tests.c to include a malicious payload in the merges static array:
/* Base object: {"admin": false} */
/* Malicious Patch: {"admin\u0000hacked": true} */
{"{\"admin\":false}", "{\"admin\\u0000hacked\":true}", "{\"admin\":false,\"admin\\u0000hacked\":true}"}
2.Update the loop limits in merge_tests and generate_merge_tests from 15 to 16 to ensure the new test case is executed.
3.Build the project with cJSON_Utils enabled:
mkdir build && cd build
cmake .. -DENABLE_CJSON_UTILS=On -DENABLE_CJSON_TEST=On -DENABLE_SANITIZERS=On
make
4.Run the utility tests:
./tests/old_utils_tests
Expected behavior:
The parser should recognize "admin" and "admin\u0000hacked" as two distinct keys. The resulting merged object should be {"admin": false, "admin\u0000hacked": true}.
Observed behavior:
1.MergePatch Failure: Expected '{"admin":false,"admin\u0000hacked":true}' Was '{"admin":true}'. The patch incorrectly overwrote the value of the "admin" key.
2.GeneratePatch Failure: Expected '{"admin":false,"admin\u0000hacked":true}' Was '{"admin":false}'. The algorithm failed to detect the difference between the base and target objects, generating an empty patch.
Platform(s) (compiler version, operating system version, CPU) on which the bug was observed:
OS: Ubuntu Linux 20.04+
Compiler: GCC 9.4.0+
CPU: x86_64
cJSON release(s), commit(s), or branch(es) in which the bug was observed (always test the tip of the main branch or the latest to verify that the bug hasn't already been fixed):
cJSON(main branch)
- Ngôn ngữ chính
- C
- Star
- 13k
- Fork
- 3.5k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của DaveGamble/cJSON
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
DaveGamble/cJSON#1106 ·
Maintainer thường phản hồi trong vòng 12 ngày
-
Undefined-Behavior in function cJSON_SetNumberHelperCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
DaveGamble/cJSON#1100 · 1 reaction ·
Maintainer thường phản hồi trong vòng 12 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
DaveGamble/cJSON#1094 · 9 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 12 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
DaveGamble/cJSON#1093 ·
Maintainer thường phản hồi trong vòng 12 ngày
-
Use-after-free in cJSONUtils_ApplyPatches when a patch removes the patch arrayCó thể đã có người làm @iliasabk đã nhận 30 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
DaveGamble/cJSON#1082 ·
Maintainer thường phản hồi trong vòng 12 ngày
Tất cả issue của DaveGamble/cJSON
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
vercel-labs/zerolang#442 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
Maintainer thường phản hồi trong vòng 1 ngày
-
mewencode: base256[] and base128[] are indexed out of bounds by a non-ASCII octetCó thể đã có người làm @kazu-yamamoto đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
kazu-yamamoto/Mew#276 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[iwm] transaction_get() copies the whole payload regardless of the length asked forCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 91/100
FujiNetWIFI/fujinet-firmware#2045 ·
Maintainer thường phản hồi trong vòng 1 ngày