CVE-2026-134540 in llama.cpp
Summary
by MITRE • 11/22/2026
A security vulnerability has been detected in ggml-org llama.cpp 0.7.0-dev. This affects the function common_sampler_init of the file common/sampling.cpp of the component llama-server. Such manipulation of the argument grammar_triggers[].type leads to improper input validation. It is possible to launch the attack remotely. The exploit has been disclosed publicly and may be used. Upgrading to version b12405 mitigates this issue. The name of the patch is 9f26fe11c73c7e74a5e99e7f1b6370ad8e1cb22d. It is advisable to upgrade the affected component.
If you want to get the best quality for vulnerability data then you always have to consider VulDB.
Analysis
by VulDB Data Team • 11/22/2026
The llama.cpp project, specifically version 0.7.0-dev within its server component known as llama-server, contains a critical input validation flaw located in the common_sampler_init function found in the source file common/sampling.cpp. This vulnerability arises from improper handling of the grammar_triggers array's type field during initialization processes. The core technical issue is that the application fails to adequately validate or sanitize the data types provided by users when configuring sampling grammars, which are used to constrain model outputs for structured generation tasks such as JSON formatting or specific logical structures. This lack of rigorous input validation allows an attacker to supply malformed or unexpected type values that bypass internal checks designed to ensure safe operation within defined boundaries.
From a technical perspective, this flaw represents a classic case of improper input validation where the software does not verify that incoming data conforms to expected formats before processing it. In the context of large language model servers, sampling parameters are critical for controlling how tokens are generated based on probability distributions and constraints. When the grammar_triggers.type field is manipulated with invalid or maliciously crafted values, it can lead to undefined behavior within the C++ runtime environment. Depending on the specific implementation details not fully disclosed in the brief description, this could potentially result in memory corruption issues such as buffer overflows, out-of-bounds reads, or logical errors that disrupt service availability. The vulnerability is classified under CWE-20 Improper Input Validation according to common weakness enumeration standards, highlighting the failure to verify input against strict type and format constraints prior to processing.
The operational impact of this vulnerability is significant due to its remote exploitability. Since llama-server exposes an API interface for interacting with local or hosted large language models, attackers can send specially crafted HTTP requests containing malicious sampling configurations from a distance without requiring authentication in many default setups. The fact that the exploit has been publicly disclosed means that automated scanning tools and threat actors are likely already attempting to leverage this weakness against exposed instances. Successful exploitation could lead to denial of service conditions by crashing the server process, or potentially allow for further code execution if memory corruption leads to control flow hijacking, although the latter depends on specific compiler protections and runtime environments being present. This aligns with ATT&CK technique T1190 Exploit Public-Facing Application, as it involves targeting a widely deployed service component over the network.
To mitigate this risk, immediate action is required by upgrading llama-server to version b12405 or later, which incorporates the patch identified by commit hash 9f26fe11c73c7e74a5e99e7f1b6370ad8e1cb22d. This update addresses the root cause by implementing stricter type checking and validation logic within the common_sampler_init function, ensuring that only valid grammar trigger types are accepted during initialization. Organizations running llama-server should verify their current version and apply this upgrade promptly to close the security gap. Additionally, it is advisable to review network exposure policies for any instances of llama-server currently in production, restricting access to trusted IP ranges where possible and enabling authentication mechanisms if not already configured, thereby reducing the attack surface available to remote adversaries attempting to exploit input validation weaknesses.