English

BitHydra: Towards Bit-flip Inference Cost Attack against Large Language Models

Cryptography and Security 2026-02-24 v4 Artificial Intelligence

Abstract

Large language models (LLMs) are widely deployed, but their substantial compute demands make them vulnerable to inference cost attacks that aim to deliberately maximize the output length. In this work, we investigate a distinct attack surface: maximizing inference cost by tampering with the model parameters instead of inputs. This approach leverages the established capability of Bit-Flip Attacks (BFAs) to persistently alter model behavior via minute weight perturbations, effectively decoupling the attack from specific input queries. To realize this, we propose BitHydra, a framework that addresses the unique optimization challenge of identifying the exact weight bits that maximize generation cost. We formulate the attack as a constrained Binary Integer Programming (BIP) problem designed to systematically suppress the end-of-sequence (i.e., <eos>) probability. To overcome the intractability of the discrete search space, we relax the problem into a continuous optimization task and solve it via the Alternating Direction Method of Multipliers (ADMM). We evaluate BitHydra across 10 LLMs (1.5B-16B). Our results demonstrate that the proposed optimization method efficiently achieves endless generation with as few as 1-4 bit flips on all testing models, verifying the effectiveness of the ADMM-based formulation against both standard models and potential defenses.

Keywords

Cite

@article{arxiv.2505.16670,
  title  = {BitHydra: Towards Bit-flip Inference Cost Attack against Large Language Models},
  author = {Xiaobei Yan and Yiming Li and Hao Wang and Han Qiu and Tianwei Zhang},
  journal= {arXiv preprint arXiv:2505.16670},
  year   = {2026}
}
R2 v1 2026-07-01T02:31:34.343Z