security: cherry-pick CVE-2026-21869 (n_discard heap-buffer-overflow in server)#122
Merged
TheTom merged 1 commit intofeature/turboquant-kv-cachefrom May 4, 2026
Conversation
…869) (ggml-org#22267) * server: clamp n_discard to non-negative at JSON parse boundary (CVE-2026-21869) A negative n_discard from client JSON causes heap-buffer-overflow in update_slots() context-shift loop (CWE-787, CVSS 8.8). Clamp to 0 at ingress; n_discard=0 already triggers auto-discard (n_left/2). Ref: GHSA-8947-pfff-2f3c * cont : cleaner * cont : cleanerer * cont : cleanest --------- Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
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.
Summary
Cherry-picks the upstream fix for CVE-2026-21869 (CVSS 8.8 HIGH).
A negative
n_discardfrom client JSON causes heap-buffer-overflow in theupdate_slots()context-shift loop (CWE-787). One-line clamp at the JSON parse boundary intools/server/server-task.cpp.Upstream commit: ggml-org/llama.cpp@c78fb909b (PR ggml-org#22267, merged Apr 23 2026, by @SongLi-arm and @ggerganov).
Impact
Affects anyone running
llama-serverfrom this fork. Single malformed JSON request crashes the server with a heap corruption. Trivially exploitable; no auth required if the server is reachable.Changes
tools/server/server-task.cpp— one-line clampn_discard = std::max(n_discard, 0)at JSON parse.Test plan
llama-servertarget (M5 Max, macOS 26): clean compile, binary launches normally{"n_discard": -1}to confirm the fix landsRecommend merging quickly given the CVSS rating.
🤖 Generated with Claude Code