Memory leak in PPD parser when processing duplicate JCLBegin/JCLEnd keywords
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 52/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 停滞
- 技术栈
- c
- 领域
- security, testing-qa
调研方向
从 cups/ppd.c 的 _ppdOpen() 函数开始,检查 issue 中确定的 JCLBegin 和 JCLEnd 处理代码。使用包含重复关键字的 PPD 或 fuzzing testcase 重现问题,然后在 AddressSanitizer 和 LeakSanitizer 下运行 fuzz_ppd_gen_cache。重复关键字不再产生 leak 即表示完成。
由索引模型根据 Issue 内容生成。
描述
Summary
A memory leak vulnerability exists in the CUPS PPD parser (cups/ppd.c) when processing PPD files containing duplicate *JCLBegin or *JCLEnd keywords. Each duplicate keyword causes the previously allocated memory to be orphaned and permanently leaked.
Discovery Method
- Fuzzer:
fuzz_ppd_gen_cache - Detection: AddressSanitizer + LeakSanitizer
- Date: 2025-11-10
Vulnerability Details
Location
- File:
cups/ppd.c - Lines: 851 (JCLBegin), 856 (JCLEnd)
- Function:
_ppdOpen()
Root Cause
The parser calls strdup() to allocate memory for JCL keywords without freeing any previously allocated value:
// Line 850-853
else if (!strcmp(keyword, "JCLBegin"))
{
ppd->jcl_begin = strdup(string); // ❌ No free() before assignment
ppd_decode(ppd->jcl_begin);
}
If a PPD file contains multiple *JCLBegin lines:
- First occurrence: Allocates memory A, assigns to
ppd->jcl_begin - Second occurrence: Allocates memory B, overwrites
ppd->jcl_begin - Memory A is orphaned and leaked (cannot be freed)
The same issue exists for *JCLEnd at line 856.
LeakSanitizer Report
==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 9 byte(s) in 1 object(s) allocated from:
#0 0x5558f3468afa in strdup /src/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:596:3
#1 0x5558f35267d2 in _ppdOpen /src/cups/cups/ppd.c:851:24
#2 0x5558f3530e76 in _ppdOpenFile /src/cups/cups/ppd.c:2283:11
#3 0x5558f34c65f7 in LLVMFuzzerTestOneInput /src/cups/ossfuzz/fuzz_ppd_gen_cache.c:289:23
SUMMARY: AddressSanitizer: 9 byte(s) leaked in 1 allocation(s).
Reproduction
Test Case
Fuzzer-generated input: leak-e4ef53d9b1772ff55e830f4060f2afb3c6a79270 (313 bytes)
Analysis shows the file contains two *JCLBegin keywords:
$ strings fuzzer_testcase.bin | grep JCLBegin
*JCLBegin:
*JCLBegin:
Minimal Reproducer
Create a PPD file with duplicate *JCLBegin:
*PPD-Adobe: "4.3"
*FormatVersion: "4.3"
*FileVersion: "1.0"
*LanguageVersion: English
*LanguageEncoding: ISOLatin1
*PCFileName: "LEAK.PPD"
*Manufacturer: "Test"
*Product: "(Test Printer)"
*ModelName: "Test Leak"
*ShortNickName: "Test"
*NickName: "Test Memory Leak"
*PSVersion: "(3010.000) 0"
*JCLBegin: "first_value"
*JCLBegin: "second_value"
*OpenUI *PageSize: PickOne
*DefaultPageSize: Letter
*PageSize Letter: ""
*CloseUI: *PageSize
- 主要语言
- C
- 星标
- 8
- 派生
- 18
- 平均合并
- 7 小时 37 分钟
- 30 天内合并 PR
- 1
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
OpenPrinting/fuzzing 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 75/100
OpenPrinting/fuzzing#45 ·
-
难度 5/5 一周以上 新手友好度 35/100
OpenPrinting/fuzzing#47 · 4 条评论 · 1 个 reaction ·
-
Memory allocation/deallocation mismatch in fuzz_array.c causes immediate crash with AddressSanitizer 未关闭
难度 2/5 1-3 小时 新手友好度 55/100
OpenPrinting/fuzzing#43 ·
-
bug good first issue
难度 3/5 1-2 天 新手友好度 35/100
OpenPrinting/fuzzing#7 ·
-
good first issue
难度 4/5 3-5 天 新手友好度 35/100
OpenPrinting/fuzzing#5 · 1 条评论 ·
查看 OpenPrinting/fuzzing 的全部 Issue
相似的 Issue
-
os:linux
难度 2/5 1-3 小时 新手友好度 70/100
mpv-player/mpv#18510 · 2 条评论 ·
-
难度 1/5 1 小时以内 新手友好度 95/100
-
难度 2/5 1-3 小时 新手友好度 88/100
-
难度 1/5 1 小时以内 新手友好度 90/100
kovidgoyal/kitty#10516 ·
-
难度 1/5 1 小时以内 新手友好度 80/100