Repository navigation
Releases
gguf-radar 0.1.9
gguf-radar 0.1.8
What's Changed
- Grade content branches by what they write by @Root0ne in #44
- Report x86-64 syscall stubs in the padding and after the last tensor by @rujui7142 in #46
- Recognise system call stubs by the convention of the platform by @Root0ne in #47
- Prepare release 0.1.8 by @Root0ne in #48
- Release 0.1.8 by @Root0ne in #49
Full Changelog: v0.1.7...v0.1.8
gguf-radar 0.1.7
What's Changed
- Use one README logo that is readable on light and dark backgrounds by @Root0ne in #36
- Describe every block format in one layout table and cover partly unused bits by @Root0ne in #38
- Follow message content, constant strings and shell quoting in the template check by @Root0ne in #37
- Compare two input lengths instead of a fixed time limit in one template test by @Root0ne in #39
- Report content tests through the data flow as notes and follow Jinja scoping by @Root0ne in #40
- State the limits as classes and name the defence for each by @Root0ne in #41
- Prepare release 0.1.7 by @Root0ne in #42
- Release 0.1.7 by @Root0ne in #43
Full Changelog: v0.1.6...v0.1.7
gguf-radar 0.1.6
What's Changed
- Create the release tag with a workflow by @Root0ne in #30
- Extract the rows of UNUSED tokens and check that the tokenizer cannot produce them by @rujui7142 in #31
- Bound the memory of the UNUSED token check and correct its description by @Root0ne in #32
- Prepare release 0.1.6 by @Root0ne in #33
- Release 0.1.6 by @Root0ne in #35
New Contributors
- @rujui7142 made their first contribution in #31
Full Changelog: v0.1.5...v0.1.6
gguf-radar 0.1.5
Security
- Strings that a test on message content only requires to be absent, such as
'took 'in'took ' not in content, are no longer listed as trigger words ofconditional_logic_bomb, unless theifhas aneliforelsepart, which runs when the string is present.not,not in,!=,andandorare followed, so double negations and De Morgan forms are read correctly. The finding and the verdict do not change. The description of a finding changes only where such a string is left out of the listtrigger literal(s): [...], which happens only for anifwithouteliforelseparts, and no sentence was added to any description. Every finding in the JSON report now has the keystrigger_literals,absent_literals,branch_textandknown_template, which are empty for findings of other categories, so stored reports gain these fields. The printed output shows the strings and the text below a finding of this kind.branch_textholds up to 200 characters of the fixed text written in the branch itself, with the text ofelifandelseparts labelled.compare-templatecompares findings by severity, category and description, as before, and ignores the new fields. - A short list of known community templates, matched by the SHA-256 hash of the whole template text, in
src/gguf_radar/known_templates.py. It holds 18 templates: the 16 template files offroggeric/Qwen-Fixed-Chat-Templatesfrom v17 to v22.2 at revision855bffc, and the chat template of NVIDIA Nemotron Nano v2 in the version of the NVIDIA repository and in the copy in llama.cpp. A template is listed only when the only effect of its reported branches is a warning inside the tool response, an empty thinking block that switches reasoning off for one reply, or a documented switch of the vendor. froggeric v15 and v16 are not listed, because they write text in the voice of the assistant at the start of its reply. Every reported branch in the listed templates, and every place that uses what the branch sets, is described next to the list. For a listed template, these branches give the new noteknown_template_branchinstead ofconditional_logic_bomb, and they do not change the verdict. All other findings apply in full. Only CRLF line ends and one trailing newline more or less are accepted as differences, so a modified copy staysSUSPICIOUS.scripts/known_template_hashes.pychecks the hashes against the upstream files. On the two files of the report, the unmodified v21.3 template innerun/OxCoder-9B-i1-MTP-GGUFnow givesCLEANwith a note, and the copy inpeculiar-ragdoll/Nail-Qwen3.6-35B-A3B-GGUF-MTP, which has a system prompt added to the template, staysSUSPICIOUS. Thanks to @nerun for the report in #25. - Scanning and
sanitizecover named chat templates. A GGUF file can holdtokenizer.chat_template.<name>next to the default template, and llama.cpp uses a named template when a request needs it or when the default is empty. Before,scanread only the default key, so a payload intokenizer.chat_template.tool_usegaveCLEAN, andsanitizeleft the named keys in the file. Thanks to @agentik-os for the report in #21 and to @shiwng for the fix in #23.
Changed
- The findings of every analyzed chat template are reported. Each finding has a new field
template_keywith the key of its template, and the printed findings name it. The result has a new fieldtemplate_keywith the key of the template with the highest risk score. The verdict is still the one of the worst finding. No field was renamed or removed. - The templates of a GGUF file are collected by one function,
gguf_template_texts, whichcompare-templateuses as well.compare-templatenow keeps a named template calleddefaultapart from the real default template, so the named one no longer replaces it. scanreads the object form ofchat_templateintokenizer_config.json, a mapping from names to templates, as it already read the list form. A list item without a name is read too.sanitize --replace-templatewrites the new text undertokenizer.chat_template, adds the key if the file had none, and removes all named templates.--strip-templateremoves the default and all named templates. Both options also remove the arraytokenizer.chat_templates, so it never lists a name without a template. The summary lists the removed keys in the new fieldsnamed_templates_removedandtemplate_names_removed.- The default template and the template named
tool_useare the two that llama.cpp reads, so a scan always analyzes them. A file that holds thousands of named templates or a very long template cannot make a scan slow, because the work is limited. Besides these two, a scan analyzes at most 16 named templates with at most 1,048,576 characters in total, and of any template it analyzes the first 1,048,576 characters. A file beyond a limit gets the findingtoo_many_chat_templatesorchat_template_too_largeand the verdictSUSPICIOUS. The fingerprint is still that of the whole template. - In
tokenizer_config.json, the template nameddefaultis the default template, and two entries with the same name, or a nameless entry whose position equals another name, no longer replace each other. The Transformers library uses the last entry of a repeated name, and other runtimes may use the first, so every entry nameddefaultortool_useis always analyzed, up to 4 entries for each name. For a name with more entries, the first 3 and the last one are analyzed, and the entries in between count against the limits for the other templates. - The scan of a repository and of a directory reads the files
additional_chat_templates/<name>.jinja, which version 5 of the Transformers library loads as named templates. The filesdefault.jinjaandfile.jinjaset the default template in that library, and llama.cpp asks fortool_use, so these three files are always read. Of the other files, at most 16 are read, and a folder with more files gets the findingtoo_many_chat_templates. Their findings name the keychat_template.<name>, orchat_templatefordefault.jinjaandfile.jinja. Only regular files are read, so a directory namedx.jinjais skipped, and a file in the folder that is also found by the directory scan is scanned once. - A local file that is not a regular file, such as a symbolic link to
/dev/zeroor a named pipe, givesERRORinscan,compare-templateandsanitize, and does not exhaust memory or wait forever. A.jinjatemplate file is read up to 4 MiB, and a JSON template file up to 16 MiB, in a local scan and in a scan of a repository alike. A longer file gets the findingchat_template_too_largeand the verdictSUSPICIOUS, so a payload after the limit is not reported asCLEAN. The list file ofscan -l, the replacement template ofsanitizeand a local base file ofcompare-templateare read only if they are regular files, so a named pipe gives an error and does not wait forever. Files are opened in binary mode on Windows, and the tests run on Windows in CI. tests/test_performance.pyhas scan-time tests for a file with many metadata entries and named templates, a file with a tensor section of 48 MB and templates at and beyond the limits. The tests of the limits compare a scan with the limits to a scan without them. The other tests use bounds that are several times the time on a development machine.- The reading of a template list or mapping in a JSON file is bounded. Only the first three and the last entry named
default, the first three and the last entry namedtool_use, and the first 16 other entries are kept, and all other entries are counted in onetoo_many_chat_templatesfinding without storing their text. The time to read such a file grows in proportion to the number of entries. The JSON limit is 16 MiB, because 16 MiB of small objects need about 500 MB of memory while they are parsed.
Full changelog: v0.1.4...v0.1.5
gguf-radar 0.1.4
What's Changed
- Inspect zero-scale blocks of the IQ formats by @myamada9999 in #14
- Develop on dev and keep main for releases by @Root0ne in #15
- Take the unreleased IQ zero-scale checks off main by @Root0ne in #19
- Build releases in a workflow and pin the actions to commit hashes by @Root0ne in #18
- Bound the memory of the IQ zero-scale checks and close their gaps by @Root0ne in #16
- Recognise network redirection, alternate data streams and registry changes in templates by @Root0ne in #17
- Release 0.1.4 by @Root0ne in #20
- Release 0.1.4 by @Root0ne in #22
New Contributors
- @myamada9999 made their first contribution in #14
Full Changelog: v0.1.3...v0.1.4
gguf-radar 0.1.3
This release fixes two security problems in scan, makes the template check recognise templates that download their payload, and adds the compare-template command.
Upgrade with:
pip install --upgrade git+https://github.com/Root0ne/gguf-radar@v0.1.3
Added
- The
compare-templatecommand compares the chat template of a GGUF file or of a Hugging Face repository with the template of the original model, without depending on attack patterns. The original model must be named with--base, because the metadata of a file cannot vouch for itself. It reportsIDENTICAL,OLDERorDIFFERENT, prints a diff and the findings of the template check for both sides, and exits with 0, 2 or 1.OLDERmeans that the template equals an earlier revision of the base. The command reads every GGUF file of a repository, repeats failed requests and writes control characters of the model file in a visible form. Comparing a chat template with the original model describes it. - A check against clean public models.
scripts/check_clean_models.pyscans 19 pinned Hugging Face repositories without a download and 7 pinned GGUF files that it downloads completely, and it fails if any of them is notCLEAN. TheClean modelsworkflow runs it every week and in pull requests that changesrc/. Contributing describes how to run it.
Security
- The template check recognises templates that download their payload from another host. Commands such as
iwr,irm,certutil -urlcache,bitsadmin /transfer,mshta,curl -oandwget -O, and text that is piped into a shell or a script interpreter, now giveMALICIOUS. Before, several of these forms gave onlySUSPICIOUSbecause of the web address, and a command withouthttp://could pass asCLEAN. scanchecks every GGUF file in a Hugging Face repository. Before, it skipped files named like the second or third part of a split model, so a file could be hidden from the scan by its name.- Text from model files and repositories is written with control characters in a visible form in the output of
scan,sanitizeandcompare-template. A file name, a template or a metadata value could contain escape sequences that changed what the terminal showed. The JSON reports escape all non-ASCII characters.
Changed
--max-filesofscanhas no limit by default. When a limit leaves files out, the output and the JSON report list them, and the repository is reported asERRORand not asCLEAN.
Fixed
- A chat template that uses the
generation,breakorcontinuetag is no longer reported asSUSPICIOUSfor a syntax error. These tags belong to the Jinja2 setup of the Transformers library, and real templates use them. The modelggml-org/SmolLM3-3B-GGUFwas affected. Everything inside agenerationtag is still inspected.
gguf-radar 0.1.2
This release checks every tensor and six more block types for hidden data in zero-scale blocks, and it fixes a false positive in the readable text check.
Upgrade with:
pip install --upgrade git+https://github.com/Root0ne/gguf-radar@v0.1.2
Added
- Zero-scale blocks are now checked and cleaned in
Q4_0,Q5_0,Q2_K,Q3_K,Q5_KandQ6_Ktensors, as well as inQ8_0andQ4_Ktensors. File signatures and readable text are looked for in all of them. The flatness test is used forQ2_K,Q3_K,Q4_0andQ6_K, where real quantizer output was measured to be clearly apart from random bytes. It is not used forQ5_KandQ5_0, where it was not. - In
Q2_K,Q4_KandQ5_K, a block with a zerodand a non-zerodminis now counted, checked and cleaned. Its values are unused, and in a test model with very small weights most of the affectedQ4_Kblocks were of this kind.
Changed
- All tensors are scanned for zero-scale bytes. Before, the scan stopped after 128 tensors, so data in a later tensor was not seen.
scan_local_ggufandscan_dead_blocksstill accept a limit. - Tensors are read in pieces of 64 MiB, in the scan and in
sanitize, so a tensor of several gigabytes no longer has to fit into memory. A program header or readable text that crosses the border between two pieces is still found, and the report does not depend on the size of the pieces. - A scale stored as negative zero is a finding only in
Q8_0andQ4_K. The quantizers ofQ4_0,Q5_0,Q3_KandQ6_Kwrite negative zero themselves, so it counts there as an ordinary zero scale. - A scan of a local file now reads the whole file, so it takes about as long as reading the file once. Before, most of the weights were skipped.
- Readable text in zero-scale bytes is reported only when it fills at least 128 bytes in consecutive blocks, uses at least 16 different characters and contains spaces or line breaks in the way that text does. How the checks work lists the conditions. Text with few or no spaces, such as Base64 data, is no longer reported as text, except in a
Q8_0block that the quantizer cannot have written. - A tensor with more
MZmarkers than the scan can follow is reported as holding an excessive number of Windows program markers. sanitizeno longer scans the zero-scale blocks of the input a second time. It reads each tensor once.
Fixed
- A clean
Q4_Kmodel is no longer reported asMALICIOUSbecause its leftover bytes look like text. This happened in 0.1.1 with a real quantizer run on a tensor that held a tight group of very small positive weights and a few larger ones. - A Windows program hidden in zero-scale bytes is now found even when many
MZbyte pairs that are not programs come before it.
gguf-radar 0.1.1
This release fixes a false positive.
Fixed
- Clean models are no longer reported as
MALICIOUSbecause of bytes under zero scales. The quantizer leaves such bytes behind when a very small scale rounds to zero, which happens in models with pruned, untrained or very small weights. These blocks are now counted and shown as a note, and they do not change the verdict. Thanks to @zachisfine for the report and the analysis in #1.
Changed
- Zero-scale bytes now give
MALICIOUSonly when they contain a known file signature or readable text. They giveSUSPICIOUSwhen aQ8_0block cannot have been written by the quantizer or when a stretch of 4096 bytes is as flat as encrypted data. - The JSON report has the new fields
zero_scale_data_blocks,zero_scale_contentandzero_scale_tensors. The fielddead_block_payloadsnow counts only the blocks whose bytes do not look like quantizer output. sanitizeis unchanged. It still clears every zero-scale byte.
The documentation explains the checks in How the checks work and their limits in Limitations.
Upgrade
pip install --upgrade git+https://github.com/Root0ne/gguf-radar@v0.1.1gguf-radar 0.1.0
First release.
GGUF Radar finds poisoned chat templates and hidden payloads in LLM models without running them. It checks local .gguf files, Hugging Face model links (reading only the header and the end of each file through HTTP Range requests) and the chat template files of Safetensors and PyTorch models. The sanitize command rebuilds a clean GGUF file with the weights unchanged.
Install: pip install git+https://github.com/Root0ne/gguf-radar