The author presents a static header‑validation tool, gguf_scan.py, that detects integer‑overflow conditions in GGUF files before any model data is loaded. The scanner parses only the GGUF header using the Python standard library, never invoking tensor loading or execution, and flags malformed values that have previously triggered out‑of‑bounds reads or writes in llama.cpp, Ollama, LM Studio, PowerInfer and related parsers. A accompanying corpus, gguf_cve_corpus.py, generates one‑line header‑only .gguf files for each documented bug, reproducing the problematic header fields: metadata array length (CVE‑2024‑21825, rule GG006), metadata string length (CVE‑2024‑23496, rule GG004), metadata KV count (CVE‑2024‑23605 and CVE‑2025‑53630, rule GG003), tensor count/size accumulation (CVE‑2026‑27940, rule GG003), tensor dimensions (CVE‑2026‑33298, rule GG009), and tensor data offset (CVE‑2026‑108955, partially covered by rule GG011). The mapped rules and CVE details are stored in gguf_cve_map.json and GGUF_CVE_MAP.md (CC‑BY 4.0). Users can integrate the check into CI with a single command, e.g., gguf-scan ./my-model.gguf --fail-on HIGH, to reject any header that matches a known overflow pattern. The approach is limited to header‑level validation; it does not guarantee runtime safety, and the PowerInfer data‑offset check remains partial, as full bounds checking of the tensor data region is not yet implemented.

Read original