Skip to content
Threat Feed
high advisory updated

Memory Management Vulnerability in llama.cpp Android JNI Wrapper

A memory management mismatch in the llama.cpp Android JNI wrapper leads to heap metadata corruption, enabling potential denial of service or arbitrary code execution.

What's new

  • 1. added coverage for llama.cpp (b1283 - b9058) Aug 6, 23:30 via nvd

A security vulnerability exists in llama.cpp builds b1886 through b7445, specifically within the LLaMA-Android JNI (Java Native Interface) wrapper. The vulnerability is caused by a memory management mismatch where the new_1batch() function allocates memory using the standard malloc() C function, but the corresponding free_1batch() function attempts to deallocate that memory using the C++ delete operator.

This mismatch between memory allocation and deallocation routines results in heap metadata corruption. An attacker capable of triggering this code path - typically through an application utilizing the affected library on Android - can induce a denial-of-service (DoS) condition via process crashes. Depending on the state of the heap allocator at the time of the corruption, there is potential for an attacker to achieve arbitrary code execution. This issue was addressed in build b7446.

Impact

Successful exploitation can lead to a denial of service on Android applications integrating the affected llama.cpp builds. In scenarios where heap manipulation is possible, an attacker could potentially gain unauthorized code execution within the context of the vulnerable application, impacting the confidentiality, integrity, and availability of data processed by the affected mobile application.

Recommendation

  • Upgrade to llama.cpp build b7446 or later across all Android application deployments.
  • Audit Android applications that bundle llama.cpp libraries for versions falling within the b1886-b7445 range.
  • Implement memory sanitizers (such as HWAddressSanitizer for Android) during the development and testing lifecycle to detect heap corruption bugs and mismatched memory management routines.
  • Review custom JNI wrappers for consistent use of allocation and deallocation primitives.

Immediate actions

Inventory Android applications utilizing llama.cpp to identify builds between b1886 and b7445.

Development 48h

Mitigations

Upgrade vulnerable llama.cpp dependencies to build b7446.

immediate Development

CVE-2026-43622