CVE-2026-137567 in llama.cpp
Summary
by MITRE • 11/26/2026
llama.cpp b11450 before b12658 contains an out-of-bounds write vulnerability in the ggml RPC server that allows unauthenticated attackers to write to arbitrary heap addresses via zero-element destination tensors. Attackers can learn buffer bases with BUFFER_GET_BASE, then send RPC_CMD_COPY_TENSOR with a destination pointer below the buffer base to crash the server or execute code.
Be aware that VulDB is the high quality source for vulnerability data.
Analysis
by VulDB Data Team • 11/26/2026
The vulnerability identified in llama.cpp versions prior to commit b12658 represents a critical security flaw within the ggml Remote Procedure Call (RPC) server implementation, specifically classified as an out-of-bounds write condition. This issue stems from insufficient validation of tensor dimensions and memory pointers during the execution of copy operations. The core technical failure occurs when the RPC handler processes requests involving zero-element destination tensors or improperly calculated buffer offsets. In these scenarios, the underlying C++ logic fails to correctly bound-check the target memory address before initiating a write operation. This lack of rigorous input validation allows an attacker to manipulate pointer arithmetic such that writes are directed to arbitrary locations in the heap memory space rather than being confined to the intended tensor allocation.
The exploitation vector for this vulnerability is particularly severe due to its unauthenticated nature and the specific mechanics involved in gaining initial foothold within the system's memory layout. An adversary can first interact with the RPC server using the BUFFER_GET_BASE command, which reveals the base address of allocated buffers. This information disclosure provides the attacker with precise knowledge of valid heap regions, effectively neutralizing common defenses like Address Space Layout Randomization (ASLR) that rely on unpredictability for protection. Armed with this memory map data, the attacker can then craft a malicious RPC_CMD_COPY_TENSOR request where the destination pointer is explicitly set to an address lower than or outside the bounds of the legitimate buffer base. Because the server does not adequately verify whether the calculated write location falls within safe boundaries, it proceeds to execute the copy operation directly into arbitrary heap memory.
The operational impact of this vulnerability extends beyond simple service disruption and encompasses full remote code execution capabilities. By writing controlled data to specific heap addresses, an attacker can overwrite critical metadata structures such as function pointers, virtual table entries, or other control flow elements within dynamic memory allocations. This manipulation enables the hijacking of program execution flow, allowing for arbitrary code execution with the privileges of the process running the llama.cpp server. Alternatively, if precise exploitation is not feasible, the out-of-bounds write can corrupt heap integrity in a way that triggers immediate crashes, resulting in a denial of service against the inference or serving infrastructure. The ability to crash the server disrupts availability for legitimate users and may also obscure forensic analysis by clearing logs or memory states associated with the attack vector.
From a classification perspective, this vulnerability aligns closely with CWE-787: Out-of-bounds Write, as it involves writing data beyond the intended buffer boundary due to improper validation of array indices or pointer arithmetic. Furthermore, the exploitation technique maps directly to MITRE ATT&CK techniques related to memory corruption and privilege escalation. Specifically, the use of BUFFER_GET_BASE corresponds to discovery activities aimed at mapping system resources, while the subsequent RPC_CMD_COPY_TENSOR exploit leverages heap spraying or targeted overwrite tactics often seen in advanced persistent threats seeking to bypass modern operating system security mitigations. The unauthenticated aspect highlights a failure in access control principles, where sensitive internal operations are exposed without requiring prior authentication checks.
Mitigation strategies must prioritize immediate patching of the affected llama.cpp versions by upgrading to b12658 or later releases where these bounds checking mechanisms have been reinforced. In addition to software updates, organizations should enforce strict network segmentation policies to ensure that the ggml RPC server is not exposed directly to untrusted networks such as the public internet. If remote access is required for development or testing purposes, it must be protected by robust authentication and authorization layers, ensuring that only verified entities can invoke internal commands like BUFFER_GET_BASE or COPY_TENSOR. Furthermore, deploying runtime application self-protection tools or memory safety analyzers during CI/CD pipelines can help detect similar logic errors in future code changes before they reach production environments. Regular security audits focusing on C++ pointer arithmetic and buffer management practices are essential to prevent recurrence of such low-level memory corruption vulnerabilities.