Skip to content

ggml-cpu: get_rows allows overwrite of RIP (PoC included)#25542

Open
BitF4rmer wants to merge 1 commit into
ggml-org:masterfrom
IntegSec:integsec/fix-rpc-kernel-dst-extent-guards
Open

ggml-cpu: get_rows allows overwrite of RIP (PoC included)#25542
BitF4rmer wants to merge 1 commit into
ggml-org:masterfrom
IntegSec:integsec/fix-rpc-kernel-dst-extent-guards

Conversation

@BitF4rmer

@BitF4rmer BitF4rmer commented Jul 10, 2026

Copy link
Copy Markdown

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:

curl -sLO https://github.com/ggml-org/llama.cpp/releases/download/b9950/llama-b9950-bin-ubuntu-x64.tar.gz
tar xzf llama-b9950-bin-ubuntu-x64.tar.gz && export LD_LIBRARY_PATH=$PWD/llama-b9950

# terminal 1 — run the stock server under gdb:
gdb -q -ex run -ex 'info registers rip' -ex bt \
    --args ./llama-b9950/ggml-rpc-server -H 127.0.0.1 -p 50052

# terminal 2 — fire the unauthenticated client:
./rpc_pccontrol_client 127.0.0.1:50052 marker

Result

Program received signal SIGSEGV, Segmentation fault.
rip  0x424242424242
#0  0x0000424242424242 in ?? ()
#1  ggml_backend_buffer_free ()               from libggml-base.so.0
#2  rpc_server::free_buffer(...)              from libggml-rpc.so

Requirements

  • I have read and agree with the contributing guidelines

AI usage disclosure: YES (Of course I am using AI. Not to replace myself but to move a lot faster!)

…/ 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.
@BitF4rmer BitF4rmer requested a review from ggerganov as a code owner July 10, 2026 21:37
@github-actions github-actions Bot added the ggml changes relating to the ggml tensor library for machine learning label Jul 10, 2026
@ggml-gh-bot

ggml-gh-bot Bot commented Jul 10, 2026

Copy link
Copy Markdown

Hi @BitF4rmer, thanks for your contribution!

Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:

  • PR Template not respected: Please respect the template when creating a new pull request. Make sure to fill out all required sections.

  • AI-generated content: This project does not accept PRs, descriptions or commit messages that are fully or predominantly AI-generated. If you have used AI to assist you in writing code, please make sure to disclose that explicitly.


Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below.

@BitF4rmer

Copy link
Copy Markdown
Author

Thanks Bot, I have updated the comment.

@BitF4rmer BitF4rmer changed the title ggml-cpu: bound destination write extent in get_rows / get_rows_back / im2col / pool / pad ggml-cpu: get_rows allows overwrite of RIP (PoC included) Jul 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ggml changes relating to the ggml tensor library for machine learning

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant