This repository contains a proof of concept for a metadata backdoor in .gguf model files.
Vulnerability
GGUF supports prompt-formatting metadata through fields such as tokenizer.chat_template. Consumers such as llama.cpp treat that metadata as trusted chat-template logic and apply it before inference.
A malicious GGUF can therefore embed hidden instructions that the user never typed. The model file itself becomes a behavior-changing prompt preprocessor.
This repository includes:
a direct backdoor in tokenizer.chat_template
a stealthier conditional backdoor using tokenizer.chat_template.tool_use
The first always injects a hidden system instruction. The second keeps the default template clean and only injects the malicious instruction through the tool_use template path.