Repository navigation
Conversation
llm_tokenizer_plamo2::build() parsed the two hex chars of a <0xNN> byte token with std::stoi() and indexed the 256-entry bytes_ array with the result without any range check. A byte-typed token with text "<0x-1>" makes std::stoi return -1, so bytes_[-1] = token_id is a heap out-of-bounds write (attacker-controlled offset and value) reachable by loading a crafted GGUF. A non-hex NN additionally made std::stoi throw uncaught. Validate that the parsed value is in [0,255] (and handle std::stoi exceptions) before indexing bytes_. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Hi @g4nkd, thanks for your contribution! Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:
Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below. |
|
Thank you for the report. |
|
Hi, thanks for fixing the issue. Since this is an attacker-controlled heap out-of-bounds write triggered by loading a crafted GGUF model, could this be assigned a CVE? |
Sorry, no, see the top notice in our security policy, we don't have the capacity to handle that. |
Summary
Security fix — heap out-of-bounds write in the PLaMo-2 tokenizer, reachable
just by loading a crafted GGUF model (no inference, no user input).
llm_tokenizer_plamo2::build()(src/llama-vocab.cpp) maps<0xNN>byte tokensinto a fixed 256-entry
bytes_array, using the two hex chars as the index withno range check:
A byte-typed token (
token_type = 6) whose text is"<0x-1>"makesstd::stoireturn
-1, sobytes_[-1] = token_idwrites 4 bytes before the buffer. Boththe offset (
-4 .. -60, via"<0x-1>" .. "<0x-f>") and the written 32-bit value(
token_id— the token's index in the vocab) are attacker-controlled. A non-hexNN(e.g."<0xZZ>") additionally makesstd::stoithrow uncaught.Impact
Attacker-controlled heap OOB write while loading an untrusted
.gguf— a routineoperation (models fetched from public registries, passed to
llama-server, etc.).Same threat model as GHSA-8wwf-w4qm-gpqr / CVE-2025-49847 (vocabulary-loading
overflow). I believe this warrants a security advisory / CVE.
Reproduce
poc.py(stdlib only) writes a 297-byte model; load it with a sanitizer build:After this fix the same file is rejected cleanly (
Byte token for <0x0> is not set),no OOB.
poc.py
Fix
Only index
bytes_whenNNparses to a value in[0,255], and swallowstd::stoiexceptions (this commit).AI-assisted discovery and PoC; reproduced, verified and authored by me.