SEGV has occurred in function cJSONUtils_ApplyPatchesCaseSensitive at cJSON_Utils.c
还没有人认领这个 Issue。
评估
调研方向
从 cJSON_Utils.c 中的 cJSONUtils_ApplyPatchesCaseSensitive 开始,然后跟踪 ASan trace 中命名的 apply_patch 和 detach_path frames。使用 clang 和 AddressSanitizer 构建最小 C 重现程序,针对已链接的 POC 运行它,并确认该输入不再导致所报告的 SEGV 或 DoS 条件。
由索引模型根据 Issue 内容生成。
描述
Description
SEGV has occurred in function cJSONUtils_ApplyPatchesCaseSensitive at cJSON_Utils.c:1085
Version
commit c859b25da02955fef659d658b8f324b5cde87be3 (HEAD -> master, tag: v1.7.19, origin/master, origin/HEAD)
Author: Alan Wang <[email protected]>
Date: Tue Sep 9 21:56:10 2025 +0800
Release 1.7.19 (#958)
Steps to reproduce
The Crash can be reproduced with the following minimal c code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "cJSON.h"
#include "cJSON_Utils.h"
int main(int argc, char** argv) {
if (argc < 2) return 0;
unsigned char* data = NULL;
size_t size = 0;
FILE* fp = fopen(argv[1], "rb");
if (!fp) return 0;
fseek(fp, 0, SEEK_END);
size = ftell(fp);
fseek(fp, 0, SEEK_SET);
data = (unsigned char*)malloc(size + 1);
if (!data) { fclose(fp); return 0; }
if (fread(data, 1, size, fp) != size) { free(data); fclose(fp); return 0; }
data[size] = '\0';
fclose(fp);
cJSON* obj_1 = cJSON_CreateObject();
cJSON* obj_2 = cJSON_Parse(data);
if (obj_1 && obj_2) {
cJSONUtils_ApplyPatchesCaseSensitive(obj_1, obj_2);
}
if (obj_1) cJSON_Delete(obj_1);
if (obj_2) cJSON_Delete(obj_2);
free(data);
return 0;
}
$ https://github.com/DaveGamble/cJSON; cd cJSON.
$ clang -fsanitize=address -O0 -g -o minimize ./minimize.c cJSON.c cJSON_Utils.c
$ ./minimize poc-ApplyPatchesCaseSensitive-SEGV
=================================================================
==544063==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x757b239b213c bp 0x7ffc00685a30 sp 0x7ffc006851e8 T0)
==544063==The signal is caused by a READ memory access.
==544063==Hint: address points to the zero page.
#0 0x757b239b213c string/../sysdeps/x86_64/multiarch/strlen-evex.S:77
#1 0x5584c61d7489 in strlen (/Data/du4t/harnessGeneration/testcase/cJSON/5-CVE+0x36489) (BuildId: 675a8db95ab4b2105e92973333a1dd1eccdabf1b)
#2 0x5584c629b059 in cJSONUtils_strdup /cJSON/cJSON_Utils.c:71:14
#3 0x5584c629b059 in detach_path /cJSON/cJSON_Utils.c:438:22
#4 0x5584c62973db in apply_patch /cJSON/cJSON_Utils.c:918:21
#5 0x5584c6297e3f in cJSONUtils_ApplyPatchesCaseSensitive /cJSON/cJSON_Utils.c:1085:18
#6 0x5584c62800d0 in main cJSON/minimize.c:30:9
#7 0x757b23829d8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#8 0x757b23829e3f in __libc_start_main csu/../csu/libc-start.c:392:3
#9 0x5584c61c0414 in _start (/cJSON/5+0x1f414) (BuildId: 675a8db95ab4b2105e92973333a1dd1eccdabf1b)
POC
https://github.com/Du4t/POC/blob/main/cJSON/poc-ApplyPatchesCaseSensitive-SEGV
Impact
Potentially causing DoS
- 主要语言
- C
- 星标
- 13k
- 派生
- 3.5k
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
DaveGamble/cJSON 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 70/100
DaveGamble/cJSON#1100 ·
-
难度 2/5 1-3 小时 新手友好度 86/100
DaveGamble/cJSON#1094 · 1 个 reaction ·
-
难度 2/5 1-3 小时 新手友好度 68/100
DaveGamble/cJSON#1093 ·
-
Use-after-free in cJSONUtils_ApplyPatches when a patch removes the patch array可能已有人在做 @iliasabk 于 26 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
DaveGamble/cJSON#1082 ·
-
Use-after-free in cJSON_ReplaceItemInObject when the key is the item's own name可能已有人在做 @iliasabk 于 27 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
DaveGamble/cJSON#1081 ·
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
-
area:gates bug good first issue
难度 1/5 1 小时以内 新手友好度 85/100
InauguralSystems/EigenScript#1782 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
intel/intel-device-plugins-for-kubernetes#2384 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
zephyrproject-rtos/zephyr#122261 ·
维护者通常 3 天内回复