gguf: add upper bound check for general.alignment (CWE-1284)#24997
Open
hhy569 wants to merge 1 commit into
Open
gguf: add upper bound check for general.alignment (CWE-1284)#24997hhy569 wants to merge 1 commit into
hhy569 wants to merge 1 commit into
Conversation
Add check for maximum alignment value in gguf.cpp
|
Hi @hhy569, thanks for your contribution! Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:
Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below. |
Author
|
我是人工审计 gguf.cpp 源码挖到这个漏洞的,全程没有用 AI 生成漏洞分析内容。该缺陷早在 2026 年 5 月就以 V-01 编号在 oss-security 安全邮件组公开披露过,我自己复现验证后写了这行修复代码,AI 仅仅用来整理我的笔记排版 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
我在看 gguf.cpp 代码时发现,general.alignment 参数现在只做了两项校验:判断是否为 0、是否是 2 的幂,完全没限制最大值。如果外部传入 0x80000000 这种超大对齐值,在 32 位环境里调用 GGML_PAD 宏就会出现整数溢出。
这个漏洞五月份就在 oss-security 安全邮件组里有人提过,但一直没人分配 CVE 编号,也没出修复 PR。实际加载模型根本用不上 2GB 这么夸张的对齐尺寸,直接把对齐值上限限制到 1MB 就足够稳妥,能彻底规避溢出问题。
Found while reading gguf.cpp: general.alignment only checks for zero and power-of-2, with no upper bound. Extreme values like 0x80000000 cause GGML_PAD integer overflow on 32-bit platforms. This was mentioned on oss-security in May but never got a CVE or fix. Capping at 1MB is more than enough for any practical model loading - nobody needs 2GB alignment.