Five GGUF models on Hugging Face hid a Windows trojan. They were downloaded 2,428 times before the takedown, and the attack worked because of where the malware lived: past the last tensor, in bytes no model loader ever reads, armed by a poisoned chat template that unpacked and ran it. AI Frontier Post covered that research on November 28. The scanner built for exactly this failure mode landed the day before: GGUF Radar, an open-source Python tool that checks GGUF model files for hidden malware and poisoned chat templates without ever running the model or its template.

GGUF Radar (Root0ne/gguf-radar, MIT licence) was created on November 27 and had 644 stars and 67 forks by December 3, with its last commit on December 2. It scans files on your disk and models on Hugging Face, rebuilds a clean copy of a flagged file, and compares a file's chat template against the original publisher's. Every command in this tutorial was run in a sandbox on December 3 against gguf-radar 0.1.8, and every output below is verbatim. One boundary, stated up front: the template-detection checks were verified through the project's own test suite (996 tests passed), not by building a poisoned template here — the docs' own example is used to show what a malicious template finding looks like.

What you'll need#

  • Python 3.10 or later and pip. The sandbox used Python 3.12. No GPU, no model weights, and no local model server are needed for any step.
  • Network access to PyPI and huggingface.co. Scans of Hugging Face models fetch only the header and tail of each file, so a 1.27 GB model costs about 6 MB of download.
  • No Hugging Face account for public models. A token is needed only for private or gated models, via HF_TOKEN or --token.
  • Cost: nothing. The tool is free and open source, and the scans in this tutorial cost $0.

1. Install GGUF Radar#

Install from PyPI and pin the version, so a later release cannot silently change your results:

pip install gguf-radar==0.1.8

Version 0.1.8 was the latest on PyPI on December 3. The package depends only on numpy and jinja2, which pip installs for it. Check the install:

gguf-radar --version
gguf-radar 0.1.8

To install from the repository instead, run pip install git+https://github.com/Root0ne/gguf-radar. The three commands are scan, sanitize, and compare-template; gguf-radar scan --help lists every option for the one you will use most.

2. Scan a model on Hugging Face — no download#

Point scan at a repository and it checks every GGUF file in it. It does not download the weights: it reads only the beginning of each file, where the metadata and chat template live, and the end, where hidden data is usually appended. This run checked all nine files of Qwen's 0.5B instruct GGUF repository:

gguf-radar scan Qwen/Qwen2.5-0.5B-Instruct-GGUF
[CLEAN] Qwen/Qwen2.5-0.5B-Instruct-GGUF
  [CLEAN] Qwen/Qwen2.5-0.5B-Instruct-GGUF/qwen2.5-0.5b-instruct-fp16.gguf
      Info: GGUF v3, arch=qwen2, size=1.27 GB, fetched=6.29 MB, alignment=32B
  ...
  [CLEAN] Qwen/Qwen2.5-0.5B-Instruct-GGUF/qwen2.5-0.5b-instruct-q8_0.gguf
      Info: GGUF v3, arch=qwen2, size=675.71 MB, fetched=6.29 MB, alignment=32B

Summary (unauthenticated (public API)): 1 target(s) | MALICIOUS=0 SUSPICIOUS=0 CLEAN=1 ERROR=0

All nine files came back CLEAN. The whole scan took 74 seconds, and each file cost 6.29 MB of download however large the file itself was — the 1.27 GB fp16 file included. The fetched figure is the point: a scan of a multi-gigabyte model is a seconds-long check, not a second download.

You can name a model three ways: the repository URL, the URL of one file in it, or the short owner/name form. To pin a fixed version, add a branch, tag, or commit hash after tree/, for example .../tree/9217f5db79a29953eb74d5343926648285ec7e67. Use --max-files to cap how many files are checked — but know that a capped repository is never reported CLEAN, because it was not checked completely; the output lists the files it skipped and the verdict is ERROR.

3. Scan a file on your disk#

Local files are the other half of the tool. Scan one file, or a whole folder of them — Ollama's model cache, a downloads folder, a shared drive:

gguf-radar scan ./models/

To show what a hit looks like without downloading a real model, build two tiny test files with the project's own test helper. The first is a minimal valid GGUF file with a plain chat template. The second is the same file with a harmless ZIP archive appended past the end of the weights — the exact place real attacks hide data:

from gguf_radar.cdr import build_test_gguf, build_benign_zip_overlay

build_test_gguf("clean.gguf")
build_test_gguf("zip-overlay.gguf",
                trailing_overlay_bytes=build_benign_zip_overlay())

The clean file scans exactly as a real clean model would:

gguf-radar scan clean.gguf
[CLEAN] clean.gguf
  [CLEAN] clean.gguf
      Info: GGUF v3, arch=llama, size=1.44 KB, alignment=32B

Summary (unauthenticated (public API)): 1 target(s) | MALICIOUS=0 SUSPICIOUS=0 CLEAN=1 ERROR=0

The file with the appended ZIP is a different story:

gguf-radar scan zip-overlay.gguf
[MALICIOUS] zip-overlay.gguf
  [MALICIOUS] zip-overlay.gguf
      Info: GGUF v3, arch=llama, size=1.58 KB, alignment=32B
      Overlay: +141 bytes past expected EOF (entropy=4.31, magic=['ZIP/Wheel/JAR Local File Header @ +0', 'ZIP End of Central Directory (Polyglot Archive) @ +119'])

Summary (unauthenticated (public API)): 1 target(s) | MALICIOUS=1 SUSPICIOUS=0 CLEAN=0 ERROR=0

Read the finding line by line. The tensor table says where the weights should end; the file carries 141 bytes past that point. The entropy of 4.31 says the bytes are structured rather than random, and the magic signatures identify them as a ZIP archive — a polyglot file that is both a model and an archive. A loader would never notice: it reads the tensors at the offsets the table gives and stops. The exit code is 2, which is what makes the tool usable in scripts and CI — 0 means every target was CLEAN, 2 means at least one was flagged, 1 means something could not be read.

Scanning the folder with both files in it shows the summary form you will see most often:

gguf-radar scan ./demo/
Summary (unauthenticated (public API)): 3 target(s) | MALICIOUS=1 SUSPICIOUS=0 CLEAN=2 ERROR=0

4. Read the verdicts#

Every scan ends with one of four verdicts:

VerdictWhat it meansExit code
CLEANNo check found anything.0
SUSPICIOUSSomething unusual, not proof of an attack — a web address in a template, a shell command mentioned in passing, zero-scale blocks that do not look like quantizer output.2
MALICIOUSA pattern real attacks use — a template that reads and starts a program, hidden orders to a coding agent, data after the weights with a file signature, or an overlay larger than 64 KiB.2
ERRORThe target could not be read — wrong path, not a GGUF file, or Hugging Face refused the request. Never read as clean.1

Below the verdict, the output explains itself. Info gives the GGUF version, architecture, size, and alignment. Overlay reports bytes past the expected end of file, with entropy — values near 8 mean compressed or encrypted data — and any recognised file signatures. Alignment slack reports non-zero bytes in the padding before the weights. Zero-scale blocks reports bytes hidden under quantization scales of zero, where a weight can never affect the model. Chat template findings lists what the template check found, with the highest-risk template's score from 0 to 100.

The template check is the part that matters most, because the template is a small Jinja2 program that formats every conversation before the model reads it — and it is the arming mechanism in the November attacks. The tool never runs the template. It parses it into a syntax tree and looks for the patterns attacks use. Critical findings give MALICIOUS: a template that reads, decompresses, or writes files (self_extracting_file_io), hidden PowerShell execution (powershell_dropper_execution), hidden orders telling a coding agent to call a tool (agentic_tool_hijack), instructions to add code to answers or keep things secret (covert_script_poisoning), a download from another host (remote_payload_download), registry persistence, piping text into an interpreter (pipe_to_interpreter), and template-injection escapes (ssti_rce). High findings give SUSPICIOUS, including instruction overrides and conditional_logic_bomb — a branch that changes what the model reads only when the user's message contains a trigger word.

What a malicious template finding looks like in practice is shown in the project's own getting-started guide, for a test file with data appended after its weights and a template that unpacks and runs it: an overlay line, then critical findings for a self-extracting file-I/O call and a hidden PowerShell execution, plus a high finding for the shell command itself. Treat SUSPICIOUS as an instruction to read the template, not as proof of an attack — the check also flags harmless cases, such as a system prompt that explains why malware runs a command.

5. Clean a flagged file#

When a file is flagged for hidden data rather than a poisoned template, you do not have to throw the model away. sanitize rebuilds the file in a standard layout, dropping everything after the last block of weights, zeroing the padding, and clearing the unused bits inside zero-scale blocks. The original file is never changed, and the output must be a different file:

gguf-radar sanitize zip-overlay.gguf -o zip-overlay-clean.gguf
Sanitized GGUF written to: zip-overlay-clean.gguf
  Input size:                 1.58 KB (1,581 B)
  Output size:                1.44 KB (1,440 B)
  Bytes reclaimed:            141 B
  Original alignment:         32 B -> 32 B
  Slack non-zero bytes wiped: 0 B
  EOF overlay bytes removed:  141 B
  Dead blocks canonicalized:  0
  0x8000 scales normalized:   0
  Duplicate keys removed:     0
  Chat template action:       preserved
  Model weights:              unchanged, only unused bytes were cleared

The 141 appended bytes are gone, the output is byte-for-byte the size of the clean file, and the weights are unchanged — the cleared bits are multiplied by zero or never read by the dequantizer, so their value never reaches the model. The project's test suite confirms this by dequantizing test files before and after the rebuild and checking the weights are identical. Scan the result before you use it:

gguf-radar scan zip-overlay-clean.gguf
[CLEAN] zip-overlay-clean.gguf
  [CLEAN] zip-overlay-clean.gguf
      Info: GGUF v3, arch=llama, size=1.44 KB, alignment=32B

Summary (unauthenticated (public API)): 1 target(s) | MALICIOUS=0 SUSPICIOUS=0 CLEAN=1 ERROR=0

Two things the rebuild does not do. It keeps the chat template as it is, so a file flagged for its template stays flagged — use --strip-template to remove all templates, or --replace-template original_template.jinja to replace them with one you trust, such as the template published with the original model. And it does not make a harmful template safe: scan the rebuilt file and read any template findings that remain.

Cross-section of a model file as stacked bands with an extra red band appended past the end
AI-generated illustration for AI Frontier Post

6. Compare a template with the original#

The pattern check can be evaded by a template written carefully enough to avoid known patterns. compare-template does not depend on patterns at all: it diffs the template in a GGUF file against the template of the model the file was converted from. A converter copies the template unchanged, so any difference means someone edited it after the publisher wrote it — and that deserves a look.

gguf-radar compare-template clean.gguf --base Qwen/Qwen2.5-0.5B-Instruct
DIFFERENT
Target: clean.gguf

Files (1):
  clean.gguf
Base: Qwen/Qwen2.5-0.5B-Instruct
Why this base: The base was given with --base.
Base template read from: Qwen/Qwen2.5-0.5B-Instruct/tokenizer_config.json
Template "default": differs from the base
--- base:default
+++ target:default
@@ -1,54 +1,2 @@
-{%- if tools %}
-    {{- '<|im_start|>system\n' }}
...

DIFFERENT is the expected result here: the test file carries a two-line template, while Qwen's real template is 54 lines. The point is the mechanics — a unified diff of the two templates, and exit code 2. In real use, the result is IDENTICAL when the texts match (line endings and one trailing newline are ignored), OLDER when the file's template matches an earlier revision of the base — the file was not edited, just converted from an older template — and ERROR when the comparison could not be made. Run without --base, the command refuses and exits 1:

gguf-radar compare-template clean.gguf
ERROR
Target: clean.gguf

Files (1):
  clean.gguf
Could not compare: No --base was given, and the metadata of the file names no repository. Name the original model with --base, as a Hugging Face repository or a local template file.

That refusal is deliberate. The metadata of a file cannot be trusted to name its own source — a modified file can name any repository, including one its author controls that holds the same poisoned template. You name the base, and the comparison is only as trustworthy as the base you name. The command also checks named templates, such as tokenizer.chat_template.tool_use, which llama.cpp reads when a request contains tools — a payload there reaches the model just as surely as one in the default template.

7. Automate it: lists, reports, CI, and Python#

For more than one model, put one target per line in a text file and pass it with --list. Lines starting with # and empty lines are ignored. The project's own example list checks a repository and a single file from it:

gguf-radar scan --list targets.txt --json report.json
Summary (unauthenticated (public API)): 2 target(s) | MALICIOUS=0 SUSPICIOUS=0 CLEAN=2 ERROR=0
JSON report written to: report.json

The JSON report carries the full result: per file, the verdict, size, bytes inspected, expected end of file, overlay size/entropy/signatures, zero-scale counts, the template findings with risk score and fingerprint, and any anomalies. One file from the Qwen run, trimmed:

{
  "verdict": "CLEAN",
  "file_size": 491400032,
  "bytes_inspected": 6291456,
  "expected_eof": 491400032,
  "overlay_bytes": 0,
  "overlay_entropy": 0.0,
  "overlay_magic": [],
  "slack_nonzero_bytes": 0,
  "zero_scale_data_blocks": 0,
  "dead_block_payloads": 0,
  "template_risk_score": 0,
  "anomalies": []
}

The scan checks several targets at once — four workers by default, changed with --workers — and each Hugging Face request waits up to 30 seconds by default (--timeout). Add --no-color when the output goes to a log.

In CI, the exit codes do the work. The project's docs give this GitHub Actions step, which scans a folder of models and keeps the report as an artifact:

- name: Scan models with GGUF Radar
  run: |
    pip install gguf-radar==0.1.8
    gguf-radar scan ./models/ --json gguf-radar-report.json

- name: Keep the report
  if: always()
  uses: actions/upload-artifact@v7
  with:
    name: gguf-radar-report
    path: gguf-radar-report.json

A flagged model fails the job with exit code 2, before anything is loaded or served. Pin the version, as the example does, so a new release cannot change your results without notice. For private or gated models, store a Hugging Face token as a secret and expose it as HF_TOKEN.

The same checks are available from Python. This snippet, run against the clean test file, returns the verdict and the template findings without shelling out:

from gguf_radar.hf_scanner import scan_local_gguf

result = scan_local_gguf("clean.gguf")
print(result.verdict)            # CLEAN
print(len(result.template_findings))  # 0

The package also exposes sanitize_gguf_file and scan_targets, which accepts the same mix of paths and Hugging Face addresses as the command line, plus extract_unused_rows for inspecting the rows of unused tokens in an embedding table. The YARA rules for the attacks in the research post ship in the repository at rules/gguf_supply_chain_threats.yar, loadable into any YARA-compatible tool.

A file passing through a scanner gate to a green check or a red warning
AI-generated illustration for AI Frontier Post

What it checks under the hood#

A GGUF file has four parts in a fixed order: a header and metadata table (which holds the chat template), a table listing every block of weights with its size and position, padding that moves the weights to a round offset, and the weights themselves. Runtimes read the header, find each tensor at its listed position, and read exactly that many bytes. Anything outside those ranges is never read — which is what makes hiding data possible, and also what makes it detectable, because the scanner can calculate exactly which bytes should be there.

On top of that geometry, the scanner checks the places data can hide. The padding before the weights should be all zeros. Quantized weights are stored in small blocks with a scale; when the scale is zero, the values in the block never affect the model, so those bytes are inspected for file signatures, readable text, and flatness — encrypted and compressed data uses every byte value equally often, while quantizer output follows the bell shape of the weights. A few formats have their own tells: in Q8_0, the quantizer always maps the largest value to 127 or -127 and never writes -128, so a zero-scale block that breaks that rule is flagged. The tokenizer is checked too: rows belonging to UNUSED tokens are places data can hide, and a tokenizer that contradicts its own token types — an UNUSED token that ordinary text can actually produce — is reported. The template analysis parses Jinja2 into a syntax tree, computes the strings the template builds from constants (including reversed and joined pieces), reads text the way cmd and POSIX shells would after unescaping, and follows trigger-word branches through derived values.

None of this is a guarantee, and the docs are explicit about the gaps. The zero-scale checks need the whole file, so they run only on local files, not on Hugging Face scans. Data shaped to follow the distribution of real weights is not detected. The template check looks for known patterns, so a carefully written template can pass it — which is why compare-template exists. And the tool checks the structure of the file and the text of its template, never what the model has learned: a model trained to give harmful answers needs different tools.

When to use GGUF Radar — and when not to#

Instead of…Use GGUF Radar when…
Downloading only from publishers you trustDo both. Trust in the publisher does not cover a compromised copy, a re-upload under a similar name, or a file changed after you first checked it. Scan every file before it is loaded, and keep scanning — files in a repository can change.
YARA rules aloneYou want the structural checks YARA cannot do: zero-scale blocks, padding, tensors outside the file, tokenizer conflicts, and template syntax trees. Radar ships the YARA rules for the known attacks and adds the rest.
Pickle scannersThe file is GGUF. Pickle scanners cover pickle-based formats; Radar covers GGUF files plus the chat-template files that Safetensors and PyTorch models keep beside their weights.
Loading the model to see if it worksNever as a safety check. Loading proves the model runs. Loaders never read the bytes where malware hides, so a trojaned file loads and serves normally.
Reading the template yourselfFor one file, reading it is fine. For a repository of nine files, or a CI gate on every model your team downloads, the scanner scales and catches obfuscated forms — constant-folded strings, shell-escaped spellings — that a skim misses.

Do not use it as your only control. A CLEAN verdict means none of the checks found anything, not that the file is safe. A SUSPICIOUS verdict means a person should read the findings — some are harmless, and the docs list the false positives, from system prompts that explain an attack to regions of very small, evenly spread weights that read as encrypted data. And a file whose template differs from the base is not automatically malicious: publishers such as Unsloth edit templates on purpose, and compare-template reports OLDER when the file was converted from an earlier revision. The difference still has to be read by a person.

The takeaway#

Model files are executable-adjacent: a chat template is code that runs before every reply, and the bytes past the last tensor are a hiding place no loader inspects. GGUF Radar is the smallest useful response to that — a pip-installable scanner that checks both, in seconds, without downloading the model or running it. Install it, pin the version, scan a repository before you download it and a file before you load it, and put the scan in CI so a flagged model fails the build instead of reaching production. The 60-second version is two commands: pip install gguf-radar==0.1.8, then gguf-radar scan on the model you were about to trust.