Downloads · 30 days
10
4% of all-time downloads
pragnyanramtha/gguf-chat-template-truncation-poc
gguf-chat-template-truncation-poc is a machine learning model from pragnyanramtha. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for gguf. The card lists the license as apache-2.0.
Benign security proof-of-concept for a GGUF parser/runtime mismatch.
Downloads · 30 days
10
4% of all-time downloads
All-time downloads
250
Public
Repo size
4.2 MB
Likes
0
Public
Click a slice to open those files.
.gguf4.2 MB · 100%
From the Hugging Face model README
Benign security proof-of-concept for a GGUF parser/runtime mismatch.
The PoC GGUF model stores a long tokenizer.chat_template metadata string. The trigger-bearing tail of that template is past the remote range boundary parsed by @huggingface/[email protected].
When parsed through the Hugging Face GGUF JavaScript parser using remote-style range reads, the template is silently truncated:
hasTrigger: falsehasMarker: false1276222When the same GGUF artifact is loaded by llama-cpp-python==0.3.23, the full template is available and rendered in the normal chat formatting path:
metadataHasTrigger: truemetadataHasMarker: true1450427GGUF_BOUNTY_MARKER_TEMPLATE_TAIL_VISIBLEThis is not a current code execution claim. It demonstrates hidden prompt/output manipulation through a scanner/parser/runtime mismatch in GGUF metadata handling.
@huggingface/gguf==0.4.2llama-cpp-python==0.3.23gguf==0.19.0modelscan==0.8.8gguf_hf_truncated_template.gguf: PoC GGUF artifact.verify_hf_parser_mismatch.js: Simulates remote range parsing through @huggingface/gguf.verify_runtime_template.py: Loads the same artifact through llama-cpp-python and renders benign/triggered prompts.hf_parser_output.json: Captured Hugging Face parser result.runtime_output.json: Captured llama-cpp-python runtime result.modelscan_output.json: Captured ModelScan output.package.json: JavaScript dependency pin.requirements.txt: Python dependency pins.npm install
python -m venv .venv
. .venv/bin/activate
pip install -r requirements.txt
node verify_hf_parser_mismatch.js
python verify_runtime_template.py
modelscan -p gguf_hf_truncated_template.gguf -r json --show-skipped
Expected parser result:
{
"parser": "@huggingface/gguf",
"packageVersion": "0.4.2",
"templateLength": 1276222,
"hasTrigger": false,
"hasMarker": false
}
Expected runtime result:
{
"runtime": "llama-cpp-python",
"templateLength": 1450427,
"metadataHasTrigger": true,
"metadataHasMarker": true,
"benignPromptHasMarker": false,
"triggeredPromptHasMarker": true
}
ModelScan 0.8.8 does not support GGUF and skips the artifact. The main claim is the @huggingface/gguf parser mismatch with runtimes that consume full GGUF metadata.
The trigger string is:
GGUF_BOUNTY_TRIGGER_4f7b
When a user message contains that trigger, the hidden template tail inserts this benign marker into the formatted prompt:
GGUF_BOUNTY_MARKER_TEMPLATE_TAIL_VISIBLE
2b5721e9e10f532bd57a596ebdf71d6719dd1076e3886a5caa923f1e4d30788b gguf_hf_truncated_template.gguf
A scanner, metadata viewer, or registry workflow using @huggingface/gguf remote parsing can miss security-relevant content in a long metadata string, while a local GGUF runtime consumes the full string. For chat templates, this can hide trigger-conditioned prompt manipulation from parser-based inspection.
The PoC is marker-only and does not execute code, access credentials, persist, or perform network activity.
tokenizer.chat_template.@huggingface/gguf should fail closed or fetch additional ranges when a declared GGUF string extends beyond the currently available buffer. Silent truncation of metadata values should be treated as a parse error.