5 Malicious GGUF Models on Hugging Face Hid Malware in Chat Templates, 2,428 Downloads
- A scan of 3,273,389 public Hugging Face model repositories on 26 November found 5 malicious GGUF models with 2,428 downloads as of 27 November; Hugging Face counts downloads rather than people, so the number of affected users is lower or equal.
- Two actors ran the campaigns: Mir2k uploaded two uncensored GGUF models with a Windows remote access trojan called ollie appended after the last tensor where loaders never read, then on 26 November rewrote both chat templates to make the model ask the user to run the line that unpacks it.
- Chat template poisoning abuses the Jinja2 program stored under
tokenizer.chat_templateto inject text the user never sees; thetimdedidmodels insert a fake [SYSTEM DIRECTIVE] when a trigger phrase appears, ordering an agent with shell access to download and run a script. - The open-source tool gguf-radar detects these templates and hidden bytes without running anything and rebuilds a clean GGUF file with the weights unchanged, while antivirus engines and scanners that read only the last few kilobytes miss the compressed payload.
- The appended-bytes half of the trick is GGUF-specific because the safetensors loader rejects a file whose declared tensors do not fill it exactly, but the template half also applies to Safetensors and PyTorch models that ship a template in
tokenizer_config.jsonorchat_template.jinja.
Hacker News opinions
Downloading gigabyte blobs and executing them used to be unthinkable, and now we do it from a giant hub of unchecked user uploads. Steam pulls down and runs multi-gig files with one click, so let's not pretend we were careful before.
30 years ago we were already grabbing 600MB Linux ISOs, and those were executable code. Nobody was paranoid about downloading a movie either. The new part is the chat template, not the file size.
After the xz mess there was a blob witch hunt in open source projects. Now people are handing blobs their bank accounts.
Running inference on a random model in llama-server is honestly not that dangerous. It gets dangerous when you drop it into an agentic harness that treats the model's text output as system commands.
The timing is funny. Right after Dario declares war on open models we immediately get a dose of why open models are bad. I half expect this administration to call them a national security issue.
That's not interesting, that's just how virality works. One news item makes the next one travel further.
Worth remembering that a download on HF usually means a model load, not a literal download. Those 2428 could be one person calling AutoModel 2400 times.
Of course it's 5 random abliterated models. Glad someone is paying attention, but at that scale it's nearly insignificant, and I'd bet there's more sophisticated stuff sitting on HF today.
I had no idea this was even possible. I assumed GGUF files were strictly containers for weights and tensors, and now the name safetensors makes a lot more sense.
5 out of 3.27 million is an incredibly low number. More people click a malicious Google ad in a day than use these models.
Any system that got exploited here was already insecure. Nothing escaped the inference engine and there's no sandbox escape. You can encode the same payload directly in the weights, so the only real defense is sandboxing the agent hard enough that no token it emits can do damage.
Not surprising that a big unchecked distribution network carries malware. Surprising that it's this small, which means we're early. These were no-name models, name-brand ones come next, and HF should add scanning before it's a real problem.
This is why I stay away from the bespoke-model-file inference projects. A mystery blob on HF can contain anything and auditing something more arcane than plain gguf is a pain.
Am I reading this right that the malware was in metadata and hidden prompts rather than poisoned weights? Cheaper to pull off and cheaper to catch. The small novelty is that you can append arbitrary bytes to a gguf and it still parses as valid.
Why isn't HF running gguf-radar on every upload? It looks trivial to automate, and if it flags something, quarantine the file until a human reads the report, false positives included.
I just build my own GGUFs from the official safetensors weights. Bonus is that it makes trying different quantizations easy.