Downloads · 30 days
27
9% of all-time downloads
ryansecuritytest-fanpierlabs/llama-cpp-gguf-div-by-zero-poc
llama-cpp-gguf-div-by-zero-poc is a machine learning model from ryansecuritytest-fanpierlabs. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
This repository contains a proof-of-concept for a security vulnerability. It is intended for responsible disclosure via huntr.com.
Downloads · 30 days
27
9% of all-time downloads
All-time downloads
300
Public
Repo size
—
Likes
0
Public
Click a slice to open those files.
.py9.1 KB · 75%
From the Hugging Face model README
This repository contains a proof-of-concept for a security vulnerability. It is intended for responsible disclosure via huntr.com.
The GGUF parser in llama.cpp (ggml/src/gguf.cpp) allows tensors with zero-valued dimensions to pass validation (line 623 checks < 0 instead of <= 0), which triggers a division by zero at lines 632-634 when checking for integer overflow.
Vulnerable code:
// Line 623: allows ne[j] == 0
if (info.t.ne[j] < 0) { // should be <= 0
// Lines 632-634: divides by ne[1], ne[2], ne[3]
if (ok && ((INT64_MAX/info.t.ne[1] <= info.t.ne[0]) || ...))
malicious_div_zero.gguf — Crafted 128-byte GGUF file with tensor dimensions [1, 0]poc_llama_cpp_div_by_zero.py — Script that generates the PoC file and explains the vulnerability# Build llama.cpp
git clone https://github.com/ggerganov/llama.cpp && cd llama.cpp
cmake -B build && cmake --build build -j
# Trigger crash (x86_64: SIGFPE)
./build/bin/llama-cli -m malicious_div_zero.gguf
Denial of service (process crash via SIGFPE on x86_64) for any application loading crafted GGUF files.
Ryan — Fan Pier Labs ([email protected])