Horizon Alert
Summary of the vulnerability and why it matters
A heap buffer overflow vulnerability exists in certain builds of the llama.cpp software, specifically within the function that restores KV cache state. This flaw could allow an attacker with write access to a particular directory to corrupt memory, potentially leading to unauthorized code execution.
- Memory corruption possible from malicious state files.
- Confirm if this library is used and where.
- Assess local file access risks for this tool.
Attack Path
How an attacker could exploit the issue
An attacker could leverage a heap buffer overflow vulnerability during the restoration of KV cache state. By gaining write access to the `slot_save_path` directory, an attacker can craft malicious state files. These files can cause an integer overflow when calculating the write size, allowing the attacker to write data beyond the allocated buffer boundaries, potentially leading to critical system compromise.
- Requires write access to specific directory.
- Crafted state files trigger overflow.
- Risk of code execution or data corruption.
Live Threat
Current exploitation, exposure, and threat context
A heap buffer overflow in the KV cache state restore path could allow attackers with write access to the slot_save_path directory to corrupt heap memory. This corruption may lead to heap metadata corruption, model weight corruption, or arbitrary code execution.
- Corrupted heap memory or model weights.
- Attacker crafts malicious state files.
- Potential arbitrary code execution.
Operational Fix
Recommended remediation, mitigation, and detection steps
The vulnerability in llama.cpp's KV cache state restore path requires an attacker with write access to the `slot_save_path` directory to exploit. This suggests that the primary responsibility lies with teams managing the execution environment and the application utilizing llama.cpp, such as platform or development teams. The initial focus should be on identifying all instances of the affected llama.cpp builds, assessing their exposure (especially any that might be accessible locally by unprivileged users), and confirming the owner responsible for the application or service running these builds.
- Identify application and platform owners.
- Verify local file write access.
- Plan risk-based remediation.