Repository navigation
rpc : fix UAF in graph_recompute leading to remote code execution - #24292
Merged
Merged
Conversation
rgerganov
requested changes
Jun 8, 2026
rgerganov
left a comment
Member
There was a problem hiding this comment.
Thanks for catching this. I'd prefer a simpler fix where the cache is discarded on every free_buffer call.
| @@ -844,6 +844,7 @@ class rpc_server { | |||
| struct stored_graph { | |||
| std::vector<uint8_t> buffer; | |||
| ggml_cgraph * graph; | |||
| std::unordered_set<ggml_backend_buffer_t> buffer_refs; | |||
Member
There was a problem hiding this comment.
no need for this, we can simply discard the cache whenever free_buffer is called
Contributor
Author
There was a problem hiding this comment.
Thanks, simplified as suggested, discarding all cached graphs in free_buffer() unconditionally. Re-tested locally with the same ALLOC/COMPUTE/FREE/RECOMPUTE sequence, behavior unchanged (RECOMPUTE now rejects the request, server stays alive).
The server caches the most recent compute graph per device so that GRAPH_RECOMPUTE can re-execute it without resending tensor data. The cached graph nodes hold direct pointers to backend buffers that were live at graph_compute() time. If any of those buffers is later released via FREE_BUFFER, the next GRAPH_RECOMPUTE re-executes the cached graph through the dangling pointers (use-after-free). The bug is reachable by an unauthenticated remote client. The dangling pointers point into chunks an attacker can reshape via subsequent ALLOC_BUFFER/SET_TENSOR commands, and the resulting read/write through the cached graph is sufficient to leak libc addresses and hijack the buffer iface vtable used by BUFFER_CLEAR, yielding remote code execution. Discard all cached graphs in free_buffer(). The existing null-check in graph_recompute() then rejects the request and the client falls back to GRAPH_COMPUTE on the next call. No protocol or API change.
y198nt
force-pushed
the
fix/rpc-graph-recompute-uaf
branch
from
June 9, 2026 03:36
748adaf to
cd41aa1
Compare
rgerganov
approved these changes
Jun 9, 2026
Contributor
Author
|
any update for this PR? |
quimmedes
pushed a commit
to quimmedes/cafe-llama.cpp
that referenced
this pull request
Sep 16, 2026
…ed (ggml-org#24292) The server caches the most recent compute graph per device so that GRAPH_RECOMPUTE can re-execute it without resending tensor data. The cached graph nodes hold direct pointers to backend buffers that were live at graph_compute() time. If any of those buffers is later released via FREE_BUFFER, the next GRAPH_RECOMPUTE re-executes the cached graph through the dangling pointers (use-after-free). The bug is reachable by an unauthenticated remote client. The dangling pointers point into chunks an attacker can reshape via subsequent ALLOC_BUFFER/SET_TENSOR commands, and the resulting read/write through the cached graph is sufficient to leak libc addresses and hijack the buffer iface vtable used by BUFFER_CLEAR, yielding remote code execution. Discard all cached graphs in free_buffer(). The existing null-check in graph_recompute() then rejects the request and the client falls back to GRAPH_COMPUTE on the next call. No protocol or API change.
1 task done
Cinderella-Man
added a commit
to Cinderella-Man/miner-llama
that referenced
this pull request
Nov 24, 2026
…BUFFER (C929) Since upstream ggml-org#24292 the server drops every graph it caches, on all of its devices, when a buffer is freed, and rejects a GRAPH_RECOMPUTE for any of them. The client kept their uids, so the next reuse of such a graph sent a GRAPH_RECOMPUTE: the server closed the connection and the client aborted ("Remote RPC server crashed or returned malformed response"). A scheduler that grows a compute buffer frees the old one, so any re-plan on a server while another scheduler's graphs are cached there triggers it (a context's pipe slots on two RPC devices did, C901). The client now keeps each uid with a flag, true while the server holds the graph. rpc_dispatcher::free_buffer marks every uid of that server dropped and queues the FREE_BUFFER under graph_mutex, so no GRAPH_RECOMPUTE decided before the marking is queued after the free; graph_compute sends a dropped graph whole again. The entries stay, as on the server, so both sides keep clearing their caches at the same point (GRAPH_CACHE_MAX). Nothing changes without RPC. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
The server caches the most recent compute graph per device so that
GRAPH_RECOMPUTEcan re-execute it without resending tensor data. The cached graph nodes hold direct pointers to backend buffers that were live atgraph_compute()time. If any of those buffers is later released viaFREE_BUFFER, the nextGRAPH_RECOMPUTEre-executes the cached graph through the dangling pointers (use-after-free).The bug is reachable by an unauthenticated remote client. The dangling pointers point into chunks an attacker can reshape via subsequent
ALLOC_BUFFER/SET_TENSORcommands, and the resulting read/write through the cached graph is sufficient to leak libc addresses and hijack the bufferiface vtableused byBUFFER_CLEAR, yielding remote code execution.Track the set of backend buffers each cached graph references, and drop the cached graph in
free_buffer()when one of its buffers is released. The existing null-check ingraph_recompute()then rejects the request and the client falls back toGRAPH_COMPUTEon the next call.No protocol or API change.
This was previously reported via private security advisory GHSA-2phh-px2f-2qmx on 2026-04-30. Per maintainer reply on that advisory, the patch is being submitted publicly here.