[Security] Logic Tampering via NULL byte (\u0000) Injection in cJSON_Utils Key Names
I maintainer di solito rispondono entro 12 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 55/100
Direzione di ricerca
Inizia da tests/old_utils_tests.c ed esegui i comandi cJSON_Utils build e ./tests/old_utils_tests indicati nel report. Leggi i percorsi MergePatch e GeneratePatch per vedere come vengono confrontati i nomi delle chiavi. Il lavoro è completato quando la chiave admin esistente rimane distinta da admin\u0000hacked ed entrambi i test delle utility passano con l’oggetto unito e la patch attesi.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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)
- Lingua principale
- C
- Stelle
- 13k
- Fork
- 3.5k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di DaveGamble/cJSON
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
DaveGamble/cJSON#1106 ·
I maintainer di solito rispondono entro 12 giorni
-
Undefined-Behavior in function cJSON_SetNumberHelperForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
DaveGamble/cJSON#1100 · 1 reazione ·
I maintainer di solito rispondono entro 12 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
DaveGamble/cJSON#1094 · 9 commenti · 1 reazione ·
I maintainer di solito rispondono entro 12 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
DaveGamble/cJSON#1093 ·
I maintainer di solito rispondono entro 12 giorni
-
Use-after-free in cJSONUtils_ApplyPatches when a patch removes the patch arrayForse già presa @iliasabk l’ha presa 30 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
DaveGamble/cJSON#1082 ·
I maintainer di solito rispondono entro 12 giorni
Tutte le issue di DaveGamble/cJSON
Issue simili
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 84/100
VirusTotal/yara#2255 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
neutralinojs/neutralinojs#1861 ·
I maintainer di solito rispondono entro 1 giorno
-
[BUG] Filename sequence expansion (`+`) panics on numeric values exceeding `i32::MAX`Forse già presa @muntasir-396 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
CCExtractor/ccextractor#2402 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
FujiNetWIFI/fujinet-lib#204 ·
I maintainer di solito rispondono entro 1 giorno
-
os:linux
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
mpv-player/mpv#18649 ·
I maintainer di solito rispondono entro 1 giorno