PoC: NULL Function Pointer Dereference via Q8_1/Q8_K Quantization Types in GGUF
Vulnerability Summary
A NULL function pointer dereference vulnerability exists in ggml_compute_forward_mul_mat() (ggml/src/ggml-cpu/ggml-cpu.c) when processing GGUF model files containing tensors with quantization types GGML_TYPE_Q8_1 (type value 9) or GGML_TYPE_Q8_K (type value 15).
These quantization types are valid entries in the ggml_type enum and pass the GGUF loader's type validation, but have NULL vec_dot function pointers in the type_traits_cpu[] dispatch table. During inference, the NULL pointer is dereferenced, causing a SIGSEGV (crash/denial of service).
| Field | Value |
|---|---|
| Target | llama.cpp (GGUF format) |
| CWE | CWE-476: NULL Pointer Dereference |
| Impact | Denial of Service (crash via SIGSEGV) |
| Attack Vector | Crafted GGUF model file |
Files
| File | Description |
|---|---|
poc_q8_null_deref.py |
Python PoC generator — creates both crafted GGUF files |
reproduce.sh |
One-command reproduction script |
poc_q8_1_null_deref.gguf |
Pre-built crafted GGUF (Q8_1 type) |
poc_q8_k_null_deref.gguf |
Pre-built crafted GGUF (Q8_K type) |
verification_output.txt |
Captured ASAN/reproduction output |
SUBMISSION.md |
Full vulnerability writeup with root cause analysis |
Reproduction
# Quick reproduction with pre-built files:
./llama-cli -m poc_q8_1_null_deref.gguf -p "test" -n 1
# Or use reproduce.sh (builds llama.cpp with ASAN and runs both PoCs):
chmod +x reproduce.sh
./reproduce.sh
# Or generate fresh PoC files:
python3 poc_q8_null_deref.py
Root Cause
The GGUF loader validates tensor types with a bounds check:
if (info.t.type < 0 || info.t.type >= GGML_TYPE_COUNT) {
// rejected
}
Q8_1 (9) and Q8_K (15) pass this check since they are within the valid enum range. However, in type_traits_cpu[], these types have NULL vec_dot function pointers because they are internal quantization types never intended as tensor storage types:
ggml_vec_dot_t const vec_dot = type_traits_cpu[src0->type].vec_dot;
vec_dot(ne00, &tmp[ir0 - iir0], ...); // CRASH: vec_dot is NULL
Disclosure
This vulnerability was reported via Huntr (Protect AI's responsible disclosure platform for AI/ML software).
- Downloads last month
- 14