ryansecuritytest-fanpierlabs commited on
Commit
3caf343
·
verified ·
1 Parent(s): 64d508f

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +48 -0
README.md ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ tags:
4
+ - security-research
5
+ - proof-of-concept
6
+ - vulnerability
7
+ ---
8
+
9
+ # PoC: llama.cpp GGUF Division by Zero via Zero-Dimension Tensor
10
+
11
+ **This repository contains a proof-of-concept for a security vulnerability. It is intended for responsible disclosure via huntr.com.**
12
+
13
+ ## Vulnerability
14
+
15
+ 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.
16
+
17
+ **Vulnerable code:**
18
+ ```cpp
19
+ // Line 623: allows ne[j] == 0
20
+ if (info.t.ne[j] < 0) { // should be <= 0
21
+
22
+ // Lines 632-634: divides by ne[1], ne[2], ne[3]
23
+ if (ok && ((INT64_MAX/info.t.ne[1] <= info.t.ne[0]) || ...))
24
+ ```
25
+
26
+ ## Files
27
+
28
+ - `malicious_div_zero.gguf` — Crafted 128-byte GGUF file with tensor dimensions [1, 0]
29
+ - `poc_llama_cpp_div_by_zero.py` — Script that generates the PoC file and explains the vulnerability
30
+
31
+ ## Reproduction
32
+
33
+ ```bash
34
+ # Build llama.cpp
35
+ git clone https://github.com/ggerganov/llama.cpp && cd llama.cpp
36
+ cmake -B build && cmake --build build -j
37
+
38
+ # Trigger crash (x86_64: SIGFPE)
39
+ ./build/bin/llama-cli -m malicious_div_zero.gguf
40
+ ```
41
+
42
+ ## Impact
43
+
44
+ Denial of service (process crash via SIGFPE on x86_64) for any application loading crafted GGUF files.
45
+
46
+ ## Researcher
47
+
48
+ Ryan — Fan Pier Labs (ryan@fanpierlabs.com)