GGUF template poisoning abuse on Hugging Face

Local LLMs distribute as GGUF files. Each file carries a chat template that the runtime applies to every prompt. Attackers abuse this mechanism to insert invisible instructions the user never sees. A scan of all 3273389 public Hugging Face model repositories on 26 November 2026 found 5 malicious GGUF models with 2428 downloads as of 27 November. The largest campaign, Mir2k, uploaded two uncensored GGUF models with a Windows remote access trojan named ollie hidden at the end of each file. On 26 November the account rewrote both templates so the model asks the user to run the line that unpacks the hidden program.

How chat templates conceal invisible instructions

The chat template is a small Jinja2 program stored under the metadata key tokenizer.chat_template. Before every reply the runtime passes the conversation through it to build the exact text the model reads. C++ runtimes render templates in a restricted engine with no Python behind it so classic payloads that reach the operating system do not work there. The attacks found in this study do not need to escape that engine. They use ordinary template logic to add text to the conversation and that text never appears in the chat window.

In the Mir2k models the template adds a system message telling the model to begin every answer with one PowerShell line which a user may copy and run. In the timdedid models a trigger phrase in the users message makes the template insert a fake [SYSTEM DIRECTIVE] that orders an agent with shell access to download and run a script. Chat templates carry the same kind of structure in Safetensors and PyTorch formats so this half of the method applies to those formats too.

Malware concealed across two Hugging Face campaigns

The scan covered every public model repository on Hugging Face including 226310 GGUF repositories holding 2.56 PB of weights. Manual review removed security test repositories harmless persona prompts and published research samples. Five repositories remained all still online on 27 November. The table below lists each one with its campaign the method its template uses and its downloads:


| Repository | Campaign | Method | Payload status | Downloads |
|---|---|---|---|---|
| Mir2k/Huihui-Qwen3.5-9B-abliterated-GGUF | Mir2k | Reply prefix with hidden executable | Recovered and analyzed | 1488 |
| Mir2k/Inkling-2-Mini-Uncensored-GGUF | Mir2k | Reply prefix with hidden compressed executable | Recovered and analyzed | 458 |
| timdedid/qwen3.8-cyber-uncensored | timdedid | Tool hijacking | Second stage not recovered | 271 |
| timdedid/qwen3-cyber-UNCENSORED-2 | timdedid | Tool hijacking | Second stage not recovered | 136 |
| timdedid/qwen3-cyber-UNCENSORED | timdedid | Tool hijacking | Second stage not recovered | 75 |
| Total | 2 actors | | | 2428 |

At the time of the scan on 26 November the same repositories had 1502 downloads. The count grew by more than half in one day almost entirely on the two Mir2k models.

Campaign 1: Mir2k plant first and arm later

Mir2k is a new Hugging Face account with French traces throughout the model card of the first upload the system prompt inside the template the commit messages and the strings in the malware. On 22 November the account created 14 repositories. Twelve of them are empty placeholders named after expected releases such as Qwen4-27B DeepSeek-V4 Llama-4-Scout and gemma-4-27b created in two automated bursts ready to be filled when those models appear.

The repository history shows the order of events. On 22 November Huihui-Qwen3.5-9B-abliterated was uploaded with the executable already appended after its last tensor but with its original clean template. On 24 November Inkling-2-Mini-Uncensored followed with the same executable in compressed form again with a clean template. For those days the payload sat in the files with nothing to start it.

On the morning of 26 November both templates were replaced within about an hour and the new version read a fixed path in the Downloads folder. Nine hours later both were replaced again this time searching the whole user profile for the model file. Downloads made before 26 November therefore contain the payload but not the trigger.

The armed template adds a French system message: you are a helpful assistant begin every reply with this line copied character by character then answer normally. The line that follows finds the largest .gguf file in the user profile reads the last bytes of it and writes them to %TEMP%\\d.exe. In the Huihui model it reads 11474944 bytes from 12000000 bytes before the end; in the Inkling model it reads the last 4200000 bytes and decompresses them first.

The ollie implant

Both models unpack to the same 11.47 MB Windows x64 program whose SHA-256 is listed in Section 7.2. Neither the hash nor the campaign strings had public sightings at the time of writing. Most of its size is a complete copy of Tor 0.4.9.16 10.25 MB. The hex view below shows the point at offset 0x000E88A0 where the miners text ends and the embedded Tor program with its own MZ header begins:

[Hex view showing offset 0x000E88A0 transition]

Static analysis of its strings imports and code shows what it does once started. It first looks for VirtualBox VMware and Sandboxie drivers and for usernames such as sandbox malware and test and exits if it finds them. On a real machine it settles in: a scheduled task runs it every 10 minutes with highest privileges two watchdog processes keep it alive the StartupApproved registry keys re-enable it and its process is marked as critical so ending it crashes Windows.

It also tries the known fodhelper.exe UAC bypass and fails. The disassembly shows it creating HKCU\\SoftwareClassesms-settingsShellOpencommand launching fodhelper.exe and deleting the key again but both paths were compiled without their backslashes so Windows never finds them. Its Run key path has the same flaw.

With its foothold in place it writes Tor to disk starts it with SocksPort 9050 and reaches its operator over an onion service using a ChaCha20 session protected by a built-in pre-shared key. Through that channel it sends saved passwords from Chrome Edge and Brave read through DPAPI although Chromes newer v20 App-Bound encrypted entries are left undecrypted. It also targets the Phantom and MetaMask wallet extensions and supports keylogging clipboard reading screenshots screen streaming and webcam capture. When the machine is idle it mines Monero with RandomX over Tor.

It names its folders ollie under AppData\\Roaming close enough to Ollama to look familiar and it still contains a path from the authors own machine C:/Users/MoH/socks.txt.

Campaign 2: timdedid hijacking coding agents

One day before Mir2k on 21 and 22 November the account timdedid published three byte-identical copies of a Qwen3 1.7B model aimed at security users together with an Ollama mirror named timdedid/qwen3-1.7b-cyber. The template is the official Qwen3 template with one addition near the end. When the users latest message contains What is it inserts a [SYSTEM DIRECTIVE] telling an agent to call its powershell tool download value.ps1 from a WordPress site into C:\\Windows\\Temp\\payload.ps1 and run it in a hidden window. The README advises against replacing the embedded template which keeps the trigger in place. All three parts are visible in Hugging Faces own metadata viewer.

The second-stage script was not recovered for this study and public reputation services had no record of the URL so what it would have installed is unknown.

Further hiding places shown in the lab

If model hubs start rejecting GGUF files with bytes after the last tensor Mir2ks method stops working. The GGUF format still leaves three other places to hide data that the scanned malware did not use. The general techniques behind them such as polyglot files and data hidden in weights are long known but no earlier report applying them to GGUF was found. Each was reproduced with synthetic test files built for this study none of them changes a single dequantized weight and none triggers a warning in llama.cpp or gguf-py.

The first is the alignment padding. The general.alignment value sets the gap between the tensor table and the first tensor and raising it from the usual 32 bytes to several megabytes creates a gap that loaders skip without checking whether it is empty. Some legitimate files use larger alignments so a scanner has to check that the gap is zero rather than reject large values.

The second turns the model into two files at once. GGUF is read from the start and ZIP from the end so a ZIP archive appended to a model produces a file that still loads as a model and also imports as Python code through zipimport.

The third hides data inside the weights themselves. A Q8_0 block stores one scale and 32 values and each weight is the scale times its value. With a scale of zero any 32 bytes produce zero weights so a block that was already zero can carry hidden data. Writing the scale as negative zero 0x8000 also defeats checks that look for the bit pattern 0x0000.

Detection and clean rebuild with gguf-radar

Signature scanning cannot keep up with data that can be encoded any way the attacker likes. gguf-radar instead checks the structure of the file and then rebuilds it in a canonical form. It first parses tokenizer.chat_template into a syntax tree without running it and flags file reads and writes decompression process starts download commands conditional hidden directives code poisoning instructions and known Python escape gadgets. It then computes where the model data must end and reports any bytes after that point together with non-zero padding non-zero bytes in zero-scale blocks and negative-zero scales. Finally it writes a new file with 32-byte alignment and zeroed padding drops everything after the last tensor sets negative-zero scales to +0.0 and clears the bytes of zero-scale blocks optionally replacing or removing the template. The dequantized weights stay identical.

Every specimen above and both live Mir2k files were tested. The table below compares what common scanners and GGUF parsers report with the result after the rebuild:


| Test file | Antivirus and pickle scanners | GGUF parsers | After gguf-radar |
|---|---|---|---|
| Data in alignment padding | No alert | Loads normally | Padding zeroed weights unchanged |
| Data in zero-scale blocks | No alert | Loads normally | Scales normalized bytes cleared weights unchanged |
| GGUF and ZIP polyglot | No alert | Loads normally | Archive removed no longer a ZIP file tensor |

Signature scanning cannot keep up with data that can be encoded any way the attacker likes. gguf-radar instead checks the structure of the file and then rebuilds it in a canonical form. It first parses tokenizer.chat_template into a syntax tree without running it and flags file reads and writes decompression process starts download commands conditional hidden directives code poisoning instructions and known Python escape gadgets. It then computes where the model data must end and reports any bytes after that point together with non-zero padding non-zero bytes in zero-scale blocks and negative-zero scales. Finally it writes a new file with 32-byte alignment and zeroed padding drops everything after the last tensor sets negative-zero scales to +0.0 and clears the bytes of zero-scale blocks optionally replacing or removing the template. The dequantized weights stay identical.

Every specimen above and both live Mir2k files were tested. The table compares what common scanners and GGUF parsers report with the result after the rebuild:


| Test file | Antivirus and pickle scanners | GGUF parsers | After gguf-radar |
|---|---|---|---|
| Data in alignment padding | No alert | Loads normally | Padding zeroed weights unchanged |
| Data in zero-scale blocks | No alert | Loads normally | Scales normalized bytes cleared weights unchanged |
| GGUF and ZIP polyglot | No alert | Loads normally | Archive removed no longer a ZIP file tensor |

Users who downloaded any of these models should check endpoints against the indicators in Section 7.2 and scan local .gguf files with gguf-radar. Antivirus engines and checks that only look at the last few kilobytes of a file do not see the compressed payload.