Downloads · 30 days
0
htdy7703/gguf-tokenizer-array-type-confusion-poc
gguf-tokenizer-array-type-confusion-poc is a machine learning model from htdy7703. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This repository proves a narrow claim: loading a crafted GGUF whose tokenizer.ggml.scores metadata is stored as a 1-byte u8[] array instead of float32[] triggers a heap-buffer-overflow during vocabulary loading in lla…
Downloads · 30 days
0
Access
Public
Updated Jul 8, 2026
Repo size
—
Likes
0
Public
Click a slice to open those files.
.md2.1 KB · 34%
From the Hugging Face model README
This repository proves a narrow claim: loading a crafted GGUF whose tokenizer.ggml.scores metadata is stored as a 1-byte u8[] array instead of float32[] triggers a heap-buffer-overflow during vocabulary loading in llama.cpp.
What this PoC shows:
What this PoC does not show:
Verified commit:
95e5254c0ae93529b2f6c05e210b9cac5c0070fcbuild_wrong_typed_tokenizer_scores.py: helper to generate wrong-typed-tokenizer-scores-u8.gguf from a local llama.cpp checkoutpoc_vocab_only_loader.cpp: minimal vocab-loading harness using product codebuild_stubs.cpp: small helper stubs needed by the reduced harness buildpython3 build_wrong_typed_tokenizer_scores.py /path/to/llama.cpp ./wrong-typed-tokenizer-scores-u8.gguf
That helper imports gguf-py from the provided llama.cpp checkout and therefore expects its Python dependencies to be available. It writes a metadata-only GGUF with:
general.architecture = "llama"tokenizer.ggml.model = "t5"tokenizer.ggml.tokens = ["A"]tokenizer.ggml.scores = [65] stored as arr[u8,1]Build a small ASAN/UBSAN-instrumented loader from product sources together with poc_vocab_only_loader.cpp and build_stubs.cpp, then run:
ASAN_OPTIONS=detect_leaks=0 \
./poc_vocab_only_loader ./wrong-typed-tokenizer-scores-u8.gguf
The expected result is an AddressSanitizer report showing:
ERROR: AddressSanitizer: heap-buffer-overflowREAD of size 4llama_vocab::impl::loadThe adjacent tokenizer.ggml.token_type path is affected by the same unsafe assumption, but this PoC intentionally stays on the narrower scores proof path.