deniz.in

Markets

Weather

Loading weather

· via dev.to (home feed)

Trailing-byte RATs and poisoned chat templates found in Hugging Face GGUF models

A scan of every public Hugging Face model repository found five malicious GGUF files with 2,428 downloads, hiding a Windows RAT in ignored trailing bytes and weaponised chat templates.

Trailing-byte RATs and poisoned chat templates found in Hugging Face GGUF models

Scan covers every public Hugging Face model repo

A sweep of all public model repositories on Hugging Face has turned up five malicious GGUF files with a combined 2,428 downloads, hiding a Windows remote-access trojan in unused file space and tampered chat templates meant to trick users and AI coding agents into executing it.

According to a dev.to write-up of the findings, the scan was published on November 27, 2026 by Malspark and covered 3,273,389 public repositories, including 226,310 GGUF repositories totalling 2.56 PB and 572,184 chat templates.

The report is careful about the numbers: 2,428 is the Hugging Face download counter, not a tally of infected machines. Loading GGUF weights in llama.cpp, Ollama or LM Studio does not by itself execute the hidden payload. The attack completes only if a user copies a PowerShell command the model prints, or if a coding agent with tool access follows instructions hidden in the template.

Payloads hidden after the last tensor

GGUF headers declare exact byte offsets for every tensor, and runtimes stop reading at the end of the last tensor, quietly ignoring whatever follows. Safetensors, by contrast, refuses files with leftover trailing bytes. That gap is the foundation of the first attack vector.

An actor using the handle Mir2k, the report says, appended an 11.47 MB Windows x64 RAT named ollie after the final tensor in two GGUF uploads of uncensored models, which drew 1,488 and 458 downloads. In the second file, the payload was compressed with raw Deflate so antivirus signature scans had nothing to match. Unpacked, ollie carries a 10.25 MB Tor 0.4.9.16 binary, a RandomX miner, and routines for stealing MetaMask and Phantom wallets, according to the report.

The same account had also registered twelve empty repositories squatting on the names of unreleased models, among them Qwen4-27B, DeepSeek-V4 and Llama-4-Scout.

Chat templates arm the payload

Trailing bytes need a trigger, and the second stage lives in tokenizer.chat_template. Mir2k reportedly uploaded clean templates first to build download numbers, then swapped the template days later so every reply opens with a PowerShell one-liner. That command reads the last 4.2 MB of the .gguf file on disk, decompresses it in memory, and launches the result as %TEMP%\d.exe.

A second actor, timdedid, is described as running a variant across three repositories with 482 downloads, aimed at agentic coding tools. When a prompt contains a dormant trigger phrase, the template injects a forged [SYSTEM DIRECTIVE] telling a shell-capable agent to download and execute payload.ps1.

A scanner and some hardening advice

Malspark open-sourced an MIT-licensed scanner, published on GitHub as Root0ne/gguf-radar. It parses chat templates and checks trailing end-of-file bytes, audits a Hugging Face repository remotely using HTTP Range requests rather than multi-gigabyte downloads, rewrites a suspect file into a clean GGUF with trailing bytes stripped and weights untouched, and diffs a community GGUF's template against the official base model.

The write-up also recommends overriding embedded templates outright when local models are wired into agents with shell access — via llama.cpp's --chat-template-file option or an explicit TEMPLATE block in an Ollama Modelfile — so hidden template instructions never reach the prompt.

Why it matters

The reflexive assumption among local LLM users, that .gguf files are inert as long as you avoid pickle files, no longer holds. The attack surface now includes bytes a runtime never reads and the template that frames every conversation.

The immediate footprint is small — five live models, 2,428 downloads, no confirmed infections — but the design deserves attention. Uploading clean files first and arming them days later defeats casual review, since a repository inspected at upload time looks legitimate. Compression blinds signature-based antivirus. Pre-registered names for unreleased models sit waiting for users searching for weights that do not exist yet. And as more local models gain shell access through coding agents, a forged system directive in a chat template becomes a real execution path rather than a curiosity. Auditing GGUF files before running them, and pinning templates to trusted sources, is now basic hygiene for anyone pulling community quantisations.

  • #hugging-face
  • #gguf
  • #malware
  • #llm-security
  • #local-llm

Related posts