ggml-cpu: get_rows allows overwrite of RIP (PoC included)#25542
Open
BitF4rmer wants to merge 1 commit into
Open
ggml-cpu: get_rows allows overwrite of RIP (PoC included)#25542BitF4rmer wants to merge 1 commit into
BitF4rmer wants to merge 1 commit into
Conversation
…/ im2col / pool / pad Several CPU kernels reached via the RPC graph_compute path compute their destination write extent from a shape that ggml_nbytes(dst) does not model (e.g. get_rows with dst.ne1==1 hides an arbitrary nb1), and their shape-consistency checks are libc assert() that -DNDEBUG strips. A crafted graph therefore writes past the destination buffer; for get_rows this is an arbitrary-offset write of attacker-controlled content. Promote the stripped checks to GGML_ASSERT and add the missing write-extent / write-index bounds so a malformed graph aborts cleanly instead of corrupting memory. Each promoted assertion is the kernel's own pre-existing invariant, so valid graphs are unaffected.
|
Hi @BitF4rmer, 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
|
Thanks Bot, I have updated the comment. |
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.
Overview
I used AI to fuzz and find this memory bug, built a full PoC that successfully overwrites the instruction pointer with attacker controlled data (ie: 0x424242424242 ("BBBBBB")). Tested the PoC against your b9950 ubuntu x64 release manually.
graph_compute is the entry point and get_rows is what performs an out-of-bounds write.
The fix is also AI generated, looks good to me but should be validated with someone more familiar with this specific code base.
Repro
Download PoC:
pr1-poc.zip
Simple reproduction steps:
Result
Requirements
AI usage disclosure: YES (Of course I am using AI. Not to replace myself but to move a lot faster!)