Description
llama.cpp builds b1886 through b7445 contain a race condition use-after-free vulnerability in the LLaMA-Android JNI wrapper where bench_1model() and free_1context() lack synchronization, allowing Thread A to operate on freed memory while Thread B concurrently frees the llama_context. Attackers can exploit this by performing heap spray with attacker-controlled data containing a fake vtable to hijack the vtable pointer at offset +0x30, causing llama_batch_allocr::clear() to dereference arbitrary memory and achieve remote code execution.
Published: 2026-08-06
Score: 7.3 High
EPSS: n/a
KEV: No
Impact: n/a
Action: n/a
AI Analysis

Impact

This vulnerability is a race condition use‑after‑free in the LLaMA‑Android JNI wrapper of llama.cpp between builds b1886 and b7445. The absence of synchronization between the bench_1model() routine and the free_1context() call allows one thread to free a llama_context while another thread continues to access it. An attacker can exploit the freed memory by performing a heap spray that injects a forged vtable; the subsequent llama_batch_allocr::clear() call dereferences the malicious vtable pointer at offset +0x30, enabling arbitrary code execution.

Affected Systems

The affected product is ggml‑org:llama.cpp builds b1886 through b7445. Versions earlier than the release tagged b7446 contain the flaw; the patch commit is identified by hash 5c0d18881e0e9794c96b2602736b758bac9d9388. Users running any of these builds that expose the JNI for benchmark or freeing operations are at risk.

Risk and Exploitability

The CVSS score of 7.3 indicates a high impact if the flaw is exploited. No EPSS score is available, so exploitation likelihood cannot be quantified at this time. The vulnerability is not listed in the CISA KEV catalog, implying no publicly known exploit has yet been documented. Attackers would need to trigger the race condition, typically via concurrent JNI invocations, and construct a heap spray with a fake vtable to hijack execution. This requires some code execution capability, so the attack is likely confined to scenarios where the affected binary is invoked with user‑controlled input.

Generated by OpenCVE AI on August 7, 2026 at 01:14 UTC.

Remediation

No vendor fix or workaround currently provided.

OpenCVE Recommended Actions

  • Update llama.cpp to version b7446 or later, which includes the commit that synchronizes bench_1model() and free_1context() and removes the use‑after‑free.
  • If updating is not immediately possible, serialize access to bench_1model() and free_1context() in your own code to eliminate concurrent execution, or disable benchmark functionality altogether.
  • As a temporary mitigation, run the application in a hardened environment with ASLR, NX, and privilege restrictions, and limit exposure by executing only in controlled containers or sandboxes.

Generated by OpenCVE AI on August 7, 2026 at 01:14 UTC.

Tracking

Sign in to view the affected projects.

Advisories

No advisories yet.

History

Fri, 07 Aug 2026 02:15:00 +0000

Type Values Removed Values Added
First Time appeared Ggml-org
Ggml-org llama.cpp
Vendors & Products Ggml-org
Ggml-org llama.cpp

Thu, 06 Aug 2026 22:15:00 +0000

Type Values Removed Values Added
Description llama.cpp builds b1886 through b7445 contain a race condition use-after-free vulnerability in the LLaMA-Android JNI wrapper where bench_1model() and free_1context() lack synchronization, allowing Thread A to operate on freed memory while Thread B concurrently frees the llama_context. Attackers can exploit this by performing heap spray with attacker-controlled data containing a fake vtable to hijack the vtable pointer at offset +0x30, causing llama_batch_allocr::clear() to dereference arbitrary memory and achieve remote code execution.
Title llama.cpp b1886–b7445 Race Condition Use-After-Free via llama-android.cpp
Weaknesses CWE-362
CWE-476
References
Metrics cvssV3_1

{'score': 7, 'vector': 'CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:H'}

cvssV4_0

{'score': 7.3, 'vector': 'CVSS:4.0/AV:L/AC:H/AT:N/PR:N/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N'}


Subscriptions

Ggml-org Llama.cpp
cve-icon MITRE

Status: PUBLISHED

Assigner: VulnCheck

Published:

Updated: 2026-08-06T15:47:17.244Z

Reserved: 2026-08-04T20:17:18.298Z

Link: CVE-2026-70640

cve-icon Vulnrichment

No data.

cve-icon NVD

No data.

cve-icon Redhat

No data.

cve-icon OpenCVE Enrichment

Updated: 2026-08-07T02:00:06Z

Weaknesses
  • CWE-362

    Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')

  • CWE-476

    NULL Pointer Dereference