Skip to content

security: cherry-pick CVE-2026-21869 (n_discard heap-buffer-overflow in server)#122

Merged
TheTom merged 1 commit intofeature/turboquant-kv-cachefrom
fix/cve-2026-21869-n-discard-clamp
May 4, 2026
Merged

security: cherry-pick CVE-2026-21869 (n_discard heap-buffer-overflow in server)#122
TheTom merged 1 commit intofeature/turboquant-kv-cachefrom
fix/cve-2026-21869-n-discard-clamp

Conversation

@TheTom
Copy link
Copy Markdown
Owner

@TheTom TheTom commented May 4, 2026

Summary

Cherry-picks the upstream fix for CVE-2026-21869 (CVSS 8.8 HIGH).

A negative n_discard from client JSON causes heap-buffer-overflow in the update_slots() context-shift loop (CWE-787). One-line clamp at the JSON parse boundary in tools/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-server from 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 clamp n_discard = std::max(n_discard, 0) at JSON parse.

Test plan

  • Local rebuild of llama-server target (M5 Max, macOS 26): clean compile, binary launches normally
  • Cherry-pick applied with no conflicts (upstream patch is one line, file already exists in fork)
  • (optional) reproduce the crash with a curl POST containing {"n_discard": -1} to confirm the fix lands

Recommend merging quickly given the CVSS rating.

🤖 Generated with Claude Code

…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>
@TheTom TheTom merged commit 69d8e4b into feature/turboquant-kv-cache May 4, 2026
22 of 50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants