Papers › Mind the Gap: A Practical Attack on GGUF Quantization

Mind the Gap: A Practical Attack on GGUF Quantization

24 May 2025arXiv:2505.23786archive 2025-07-28

Kazuki Egashira, Robin Staab, Mark Vero, Jingxuan He, Martin Vechev

With the increasing size of frontier LLMs, post-training quantization has become the standard for memory-efficient deployment. Recent work has shown that basic rounding-based quantization schemes pose security risks, as they can be exploited to inject malicious behaviors into quantized models that remain hidden in full precision. However, existing attacks cannot be applied to more complex quantization methods, such as the GGUF family used in the popular ollama and llama$.$cpp frameworks. In this work, we address this gap by introducing the first attack on GGUF. Our key insight is that the quantization error -- the difference between the full-precision weights and their (de-)quantized version -- provides sufficient flexibility to construct malicious quantized models that appear benign in full precision. Leveraging this, we develop an attack that trains the target malicious LLM while constraining its weights based on quantization errors. We demonstrate the effectiveness of our attack on three popular LLMs across nine GGUF quantization data types on three diverse attack scenarios: insecure code generation (Δ=88.7%), targeted content injection (Δ=85.0%), and benign instruction refusal (Δ=30.1%). Our attack highlights that (1) the most widely used post-training quantization method is susceptible to adversarial interferences, and (2) the complexity of quantization schemes alone is insufficient as a defense.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2505.23786")

Code

Syntology Ran 7 of 13 code samples harvested from 1 repository linked to this paper; 6 have no recorded run. Of those that ran: 1 ran · our draft was wrong; 6 ran with no contract checked.

By repository: official repository: 13 samples from 1 repository, 7 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

eth-sri/llm-quantization-attack officialmentioned in papermentioned on GitHubpytorch report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

13 samples harvested; 7 ran; 0 honoured the contract we drafted; 6 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

1ran · our draft was wrong
6ran
6unverified

Licence: 0 of the 13 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from eth-sri/llm-quantization-attack. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

GGUFData eth-sri/llm-quantization-attack/q_attack/repair/gguf/process_gguf.py official repository ran MIT (permissive) · 76fbf4900f7b7be2 · report
Q2KData eth-sri/llm-quantization-attack/q_attack/repair/gguf/process_gguf.py official repository ran · metamorphic tier: deterministic MIT (permissive) · 94b71df524d0afb9 · report
Q3KData eth-sri/llm-quantization-attack/q_attack/repair/gguf/process_gguf.py official repository ran · metamorphic tier: deterministic MIT (permissive) · afe4242243a3e348 · report
Q4KData eth-sri/llm-quantization-attack/q_attack/repair/gguf/process_gguf.py official repository ran · metamorphic tier: deterministic MIT (permissive) · 56f7ace477c9587b · report
Q5KData eth-sri/llm-quantization-attack/q_attack/repair/gguf/process_gguf.py official repository ran · metamorphic tier: deterministic MIT (permissive) · c4f6407ab679abba · report
Q6KData eth-sri/llm-quantization-attack/q_attack/repair/gguf/process_gguf.py official repository ran · metamorphic tier: deterministic MIT (permissive) · f99509f6512a0f9a · report
calc_baseline_box eth-sri/llm-quantization-attack/q_attack/repair/gguf/process_gguf.py official repository ran · our draft was wrong MIT (permissive) · 8042c2946761d2c6 · report
GGUFArguments eth-sri/llm-quantization-attack/q_attack/repair/gguf/process_gguf.py official repository unverified MIT (permissive) · 966b4bb9c6d04790 · report
Q245KEmulator eth-sri/llm-quantization-attack/q_attack/repair/gguf/process_gguf.py official repository unverified MIT (permissive) · 19268cfe1993c95b · report
Q3KEmulator eth-sri/llm-quantization-attack/q_attack/repair/gguf/process_gguf.py official repository unverified MIT (permissive) · 6080d98ef7f7bd60 · report
Q6KEmulator eth-sri/llm-quantization-attack/q_attack/repair/gguf/process_gguf.py official repository unverified MIT (permissive) · 2399a6863a4b4d68 · report
compute_box_gguf eth-sri/llm-quantization-attack/q_attack/repair/gguf/process_gguf.py official repository unverified MIT (permissive) · e0f0e4206cd448aa · report
get_qnk_args eth-sri/llm-quantization-attack/q_attack/repair/gguf/process_gguf.py official repository unverified MIT (permissive) · 83df3b515a455ff2 · report

Tasks

Code GenerationQuantization

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections