arXiv:2505.23786cs.CRcs.AI2025-05

首次攻破GGUF量化,让模型悄悄变“坏”却难被发现。

Mind the Gap: A Practical Attack on GGUF Quantization

  • 利用量化误差构造恶意模型,伪装成正常模型。
  • 在9种量化类型上实现最高88.7%的恶意代码生成成功率。
  • 适合关注大模型安全与量化漏洞的研究者。

随着前沿大模型规模不断增大,训练后量化已成为内存高效部署的标准。近期研究发现,基于四舍五入的量化方法存在安全风险,可能被用来在量化模型中植入恶意行为,而这些行为在全精度下仍保持隐蔽。然而,现有攻击无法适用于更复杂的量化方法,如广泛用于 ollama 和 llama.cpp 框架的 GGUF 系列。本文首次针对 GGUF 量化提出攻击方法。关键洞察在于:量化误差(即全精度权重与其量化/反量化版本之间的差异)提供了足够的灵活性,可用于构建表面看似正常的恶意量化模型。我们设计了一种攻击策略,在训练目标恶意大模型时,通过量化误差约束权重。实验表明,该攻击在三种主流大模型上,针对九种不同的 GGUF 量化数据类型,在三种攻击场景中均有效:不安全代码生成(Δ=88.7%)、定向内容注入(Δ=85.0%)和良性指令拒绝(Δ=30.1%)。结果揭示:(1)当前最广泛使用的训练后量化方法易受对抗干扰;(2)仅靠量化方案复杂度不足以构成防御。

原文摘要 · Abstract (English)

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.

大模型安全量化攻击恶意注入

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。