Summary
CVE-2026-107183 is a use-after-free and double-free vulnerability in llama.cpp’s common_chat_peg_mapper::map chat-parsing function, affecting the llama-server component. An unauthenticated remote attacker can send a crafted request to the /completion endpoint to corrupt heap memory via a dangling pointer, potentially crashing the server or achieving remote code execution. The issue carries a CVSS score of 9.2 (Critical).
Technical details
- Root cause:
common_chat_peg_mapperstorescurrent_toolas a raw pointer into thepending_tool_calloptional container. When aTOOL_CLOSEtoken resetspending_tool_call, the underlying object (and its buffers) is destroyed, butcurrent_toolis left dangling. - Trigger condition: if a subsequent
TOOL_IDtoken is processed after the tool-close event, the parser writes through the dangling pointer, resulting in a use-after-free and a second deallocation (double free) of the same memory. - Attack vector: the flaw is reachable remotely and without authentication by submitting a crafted chat parser payload — specifically a tool-open, tool-id, tool-close, tool-id sequence — in a POST request to the
llama-server/completionendpoint. - Impact: heap corruption that can crash the
llama-serverprocess (denial of service) or be leveraged as a heap write primitive; researchers reported chaining this flaw with a separate embeddings out-of-bounds read to achieve remote code execution on a stock model.
Affected software
- ggml-org llama.cpp, build b8227 up to (but not including) build b11393
- Specifically impacts deployments running the
llama-serverHTTP server with chat/tool-call parsing enabled and reachable over the network
Severity
- CVSS Score: 9.2 (Critical)
- CVSS v4.0 Vector:
CVSS:4.0/AV:N/AC:H/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N - CWE-416: Use After Free
Mitigation and recommended actions
- Immediate: Upgrade llama.cpp to build b11393 or later, which clears the
current_toolpointer whenpending_tool_callis reset, eliminating the dangling-pointer condition. - If no patch can be applied immediately: restrict network exposure of
llama-serverinstances (bind to localhost or place behind an authenticated reverse proxy/firewall rules that limit access to trusted hosts), and disable or avoid exposing tool-call/chat-parser functionality on the/completionendpoint to untrusted clients until patched.

