TFL: Targeted Bit-Flip Attack against Large Language ModelsTFL: Targeted Bit-Flip Attack on Large Language Model
TFL performs targeted bit flips on three LLMs; in Table I, only TFL's Targeted Attack is True.
The attacker has white-box access, including model architecture and parameters, and can compute gradients with respect to the weights using a small number of attack samples, without needing training data or fine-tuning. The attacker is on the same machine as the victim model and flips main-memory weights via Rowhammer. The deployment formats are FP32, FP16, BF16, or INT8. The goal is for a specified prompt to contain a false answer keyword, while unrelated queries remain correct, with typically fewer than 50 flips.
- Existing LLM bit-flip attacks mainly cause untargeted failures or overall degradation, making it difficult to make only selected prompts output attacker-specified false answers while keeping unrelated queries correct. The authors believe this limits the precision and stealth of attacks.
- TFL flips one bit per iteration, up to 50. Keyword loss only raises the probability of the target token; SKIP Search uses Impact Score to build Top-100, and Aux Utility Score then selects a winner that also preserves utility on the auxiliary set. The main results only search the LM head.
- In Table I, only TFL achieves Targeted Attack across the three LLMs. Qwen3-8B's INT8/BF16 flip counts are 4/3, and GSM8K is 0.81/0.85. All baselines have False in that column, and GenBFA is 0.00/0.00 on all three tasks.
- The conclusion lists more complete defenses and extension to vision transformers as future work. Experiments include three LLMs, INT8 and BF16, DROP/GSM8K/TriviaQA, and four BFA baselines. The paper does not report sample size or number of repetitions.
- Evaluated models
- Qwen3-8BDeepSeek-R1-Distill-Qwen-14BLLaMA-3.1-8B-INSTRUCT
- Benchmarks
- DROPGSM8KTriviaQAMMLUWikiText
- Metrics
- AccuracyF1#FLIPTargeted Attack
The paper proposes TFL, a targeted bit-flip attack framework against large language models that can precisely manipulate model outputs for selected prompts while causing almost no harm to unrelated inputs. TFL designs a keyword-focused attack loss to boost attacker-specified target tokens in the generated results, and introduces an auxiliary utility score to balance attack effectiveness against collateral performance impact on benign data. The authors evaluate on models such as Qwen, DeepSeek, and Llama, and benchmarks such as DROP, GSM8K, and TriviaQA, and report that TFL achieves targeted output manipulation with fewer than 50 bit flips, with significantly lower impact on unrelated queries than previous bit-flip attack methods.
Paper analysis
What problem does this paper attempt to solve?
Existing LLM bit flips are mostly untargeted destruction; TFL aims to change specified outputs with fewer than 50 flips while minimally harming unrelated queries.
Existing bit flip attacks struggle to change only the LLM's output for a selected prompt while minimally harming unrelated queries.
- Scenario: The authors state that LLMs have entered safety-critical applications, and that main memory weights can be flipped in small numbers via DRAM vulnerabilities. They cite GenBFA as showing that three flips can trigger anomalies, SBFA as showing that flipping one bit can break Qwen3-14B, and PrisonBreak as showing that fewer than 25 flips can bypass safety mechanisms and generate harmful content.
- Limitations of existing work: The authors state that SBFA, GenBFA, and others often produce gibberish or obvious damage that users can detect; SilentStrike is more stealthy but still induces untargeted errors. The authors believe these methods either cause large-scale functional damage or cannot reliably control specified outputs.
- This paper's approach: The authors propose TFL. A keyword loss pushes toward the attacker-specified target token; an Aux Utility Score trades off target loss reduction against utility on unrelated data. The search budget is set to fewer than 50 flips. The authors state that, to their knowledge, this is the first demonstration of targeted bit flips on LLMs for selected prompts, rather than broad degradation.
- Threat model:
- Knowledge: White-box, including architecture and parameters; gradients with respect to weights can be computed using a small number of attack samples. No access to training data or fine-tuning; pretrained weights are modified directly.
- Capability: Runs on the same machine as the victim model, using Rowhammer to flip weights in main memory.
- Deployment format: FP32, FP16, BF16, or INT8.
- Goal: The output for a specified prompt contains an attacker-specified false answer keyword, while unrelated queries remain correct; flips are typically fewer than 50.
What related research exists?
The authors place TFL outside of Rowhammer, quantization, untargeted BFA, and backdoors, stating that there is no prior targeted bit flip on LLMs.
Rowhammer and Memory Defenses
- Kim et al. (2014): Repeatedly accessing adjacent rows exploits DRAM cell density to induce bit flips. The authors also cite subsequent real-world exploits, including privilege escalation and data corruption.
- ECC and TRR: The authors state both are used in many DDR4 systems, correcting limited error types and refreshing high-activation-risk rows, respectively. The authors cite ECCploit and TRRespass, stating these defenses can be bypassed.
- DDR5: ZenHammer succeeded on 1 of 10 tested DIMMs. The authors cite McSee and REFault, stating DDR5 is harder to attack due to controller behavior and mitigation mechanisms, not because cells are more stable. The authors cite Phoenix, stating these difficulties can still be overcome.
Quantization Formats
- FP32, BF16, INT8: The authors compare numerical range and deployment overhead. BF16 preserves FP32's exponent range and shortens the mantissa; INT8 is typically limited to scaled [-128, 127].
- Flip Effects: The authors state that flipping sign, exponent, or mantissa bits in BF16 has different consequences; flipping the highest exponent bit can yield infinity; INT8 flips remain within a fixed range. The authors state INT8 is generally harder to attack, requiring additional processing and more flips. Figure 1 and Figure 2 give examples of both formats.
Existing Bit Flips
- DNNs: Gradient search finds weight bits whose flips maximize loss increase. The authors state T-BFA and TBT extend a small number of flips to targeted misclassification or trojans on specified inputs, without accessing the training process.
- LLMs: GenBFA and SBFA perform model destruction; PrisonBreak jailbreaks with fewer than 25 flips; SilentStrike (written as SilentStriker in the experimental section and Table I) induces errors while maintaining natural language generation. The authors state these methods are mainly untargeted degradation or jailbreaks and cannot control specified outputs.
Targeted Attacks and Backdoors
- Adversarial Examples and Backdoors: Adversarial examples perturb inputs at inference time to enter a specified class; backdoors/trojans poison during training or fine-tuning. The authors believe the training process is not necessarily accessible.
- LLM Targeted Behavior: The authors cite BackdoorLLM, describing behavior that is normal in general but gives specified malicious outputs on selected inputs. The authors state no work has yet used BFA to achieve such targeted attacks on LLMs.
Baselines and Benchmarks: Experimental baselines are PrisonBreak, GenBFA, SilentStriker, and SBFA. Evaluation tasks are DROP, GSM8K, and TriviaQA; the unrelated auxiliary set used for optimization is MMLU or WikiText. Target prompts are the same as SilentStrike. The gradient search control in ablations is T-BFA and its variant with range constraints.
The authors position TFL as: making selected prompts produce specified keywords under a limited flip budget, while using an auxiliary utility constraint to limit performance collapse on unrelated data.
How does the paper address this problem?
TFL filters Top-100 each round using keyword loss, range constraints, and Impact Score, then flips one bit with Aux Utility Score.
TFL is an iterative search: each round, it selects a winner bit on the current weights and flips it, then continues on the new model until the target keyword appears or the preset limit of 50 is reached. Figure 3 shows the pipeline of samples, loss, top-k queue, and success determination.
Attack Samples
- Composition: target question, attacker-specified false answer, and related benign questions that should be unaffected. The main experiments use the two target questions from Figure 3, same as SilentStrike; for each target question, GPT-5 is used to generate two semantically similar prompts.
- Keyword Setting: the first token of the related keyword appears in the top-k logits at the decoding step of the ground-truth keyword, with k=20; the first token of the unrelated keyword is not in that list. Logits are computed by multiplying hidden states by the LM head weights, with bias added as applicable.
- Supervision: the model's original outputs before the attack are treated as ground truth; the correct answer to the target question is replaced with the attacker-specified false answer for optimization.
Keyword Loss
Only the average negative log-likelihood over positions belonging to the target keyword set is computed: LT(x,y,KT;θ)=−1/NT∑i=1N I(yi∈ KT)log pθ(yi|x,i) where x is the input of length N, yi is the ground-truth token at position i, KT is the set of target keyword tokens, and pθ is the token probability at that position. The text states that only target token positions enter the loss; NT is the normalization term in the formula, and the text does not define it separately.
Range Constraint and Candidate Ranking
- Range: the authors observe that flipping the most significant bits (e.g., the highest bit of the BF16 exponent, which can yield infinity in Figure 1) causes extreme weights and runtime errors. Candidate flips must keep the perturbed weight between the minimum and maximum weights of that layer; the constraint comes from SBFA.
- Impact Score: the loss gradient with respect to the weight, multiplied by the maximum absolute change a legal bit position can cause at that precision, while still satisfying the range constraint. The authors state this score comes from SBFA and claim it is more effective than using only the gradient.
- SKIP Search: brute-force searching for the top-k across the entire model could take months on Qwen3-8B. First, sort within layers by absolute gradient value, using the product of gradient magnitude and maximum single-bit perturbation magnitude as an upper bound; if the upper bound is below the minimum Impact Score in the queue, skip the remaining weights in that layer. k=100 for all experiments. The main results only search the last layer, i.e., the LM head.
Winner Selection and Stopping
The auxiliary utility score is written as the relative target loss decrease minus the auxiliary set utility decrease: AuxUtilityScore(f)=Δ Lrel(f)−Δ Uaux(f) ΔLrel is the difference in target loss before and after the flip divided by the original target loss. Daux is a hyperparameter: default is MMLU, using relative accuracy drop as penalty; for DeepSeek-R1-Distill-Qwen-14B, WikiText is used, with relative loss increase as penalty to reduce overhead. The authors state they select the bit from the top-k that minimizes this score, and claim that more negative values correspond to stronger target manipulation and smaller auxiliary set side effects. Success is determined by finding the target keyword on the target question (Figure 3); otherwise, continue until 50 flips.
What experiments did the paper conduct?
In Table I, only TFL's Targeted Attack is True; on Qwen3-8B the INT8/BF16 flip counts are 4/3.
Experimental Setup
- Models: Qwen3-8B, DeepSeek-R1-Distill-Qwen-14B, LLaMA-3.1-8B-INSTRUCT, each evaluated in INT8 and BF16. DeepSeek has reasoning disabled. Loading uses HuggingFace Transformers, INT8 uses BitsAndBytes.
- Samples: Two target questions, the same as SilentStrike; each question has two semantically similar benign questions constructed by GPT-5. Table I uses relevant keywords. The auxiliary set is MMLU except DeepSeek uses WikiText.
- Metrics and search: The text says GSM8K and TriviaQA use accuracy, DROP uses F1; Table I's header labels all three columns as Accuracy(%). Also #FLIP and Targeted Attack. Top-k=100, maximum flips 50; main results only search the LM head. SilentStriker's flip count is fixed at 50. The paper does not report per-benchmark sample sizes, repetitions, or LLM review.
- Baselines and precision: PrisonBreak, GenBFA, SilentStriker, SBFA. Table I notes the first three have FP as FP4, SBFA and TFL have FP as BF16.
- Machine: Search was done on Rocky Linux 8.10, two AMD EPYC 7413, two NVIDIA A100-SXM4 80GB. Rowhammer is implemented per DeepHammer, on an Intel i7-3770 with two Hynix 4GB DDR3, and also tested on a single-rank Samsung 8GB DDR4. The paper does not separately record Table I task scores as re-measurements after physical flips.
Main Results
The table below is from Table I, cells are INT8/FP. Due to row limits, GenBFA (0.00/0.00, 50/50, False for all three models), SilentStriker for LLaMA and DeepSeek, PrisonBreak for Qwen3-8B, and SBFA for DeepSeek (INT8 is "-", FP is 0.00, #FLIP is 2/2, Targeted Attack is False) are omitted.
Swipe horizontally to read the table
Setting DROP GSM8K TriviaQA #FLIP Targeted LLaMA-3.1-8B-INSTRUCT TFL 0.56/0.54 0.65/0.75 0.36/0.37 13/14 True LLaMA-3.1-8B-INSTRUCT PrisonBreak 0.42/0.46 0.59/0.60 0.61/0.67 50/50 False LLaMA-3.1-8B-INSTRUCT SBFA 0.00/0.00 0.00/0.00 0.00/0.00 1/1 False Qwen3-8B TFL 0.76/0.71 0.81/0.85 0.48/0.52 4/3 True Qwen3-8B SBFA 0.01/0.00 0.00/0.02 0.29/0.00 1/1 False Qwen3-8B SilentStriker 0.03/0.03 0.09/0.10 0.09/0.11 50/50 False DeepSeek-R1-Distill-Qwen-14B TFL 0.62/0.67 0.65/0.68 0.52/0.51 7/7 True DeepSeek-R1-Distill-Qwen-14B PrisonBreak 0.58/0.61 0.77/0.80 0.71/0.73 50/50 False - Authors' interpretation: The authors state TFL is the only BFA method that achieves a targeted attack across the evaluated models and precisions, and that post-attack performance on unrelated tasks is high. In Table I, only TFL has Targeted Attack as True.
- Inconsistencies with the text: The text says on Qwen3-8B INT8, one SBFA flip reduces all evaluation accuracies to near 0. In Table I, that row has TriviaQA 0.29, DROP 0.01, GSM8K 0.00. PrisonBreak retains some accuracy, and LLaMA and DeepSeek have higher TriviaQA than the same model's TFL, but Targeted Attack is False.
- Comparison conditions: TFL's FP is BF16, PrisonBreak and SilentStriker's FP is FP4. The text also writes Qwen3-8B INT8 TFL as 76.1%, 81.0%, 48.0%; the table has 0.76, 0.81, 0.48.
Searched Layer Proportion
- What was tested: Tables II and III vary the proportion of searched layers on BF16, with samples being the same two target questions and their benign auxiliary questions. Proportions go from the full model to the last 75%, 50%, 25%, and head-only search.
- Qwen3-8B: #FLIP is 4 in all five settings. DROP is 0.74, 0.71, 0.70, 0.70, 0.76; GSM8K is 0.85, 0.68, 0.84, 0.84, 0.81. The authors say layer freezing has limited impact, head-only has the best DROP, and 75% is the weakest overall. In the table, 75% has the lowest GSM8K, but its TriviaQA is 0.51, the highest in that column.
- DeepSeek: #FLIP is 9, 22, 28, 36, 7. The authors say reducing the search proportion reduces attack effectiveness, sometimes requiring more flips; optimizing only the head still yields usable results. Head-only GSM8K is 0.65 and TriviaQA is 0.62, higher than Full's 0.62 and 0.51; DROP is 0.62, lower than Full's 0.66. Table I's Qwen BF16 has 3 flips and DROP 0.71, differing from Table II's head-only 4 flips and DROP 0.76; the paper does not explain why.
Keywords and Auxiliary Data
- Keywords: Table V compares relevant and irrelevant keywords on Qwen3-8B BF16. For the president question, relevant keywords have #FLIP 1 and initial loss 7.50, irrelevant have 8 and 15.39; for the mountain question, 3 and 3.88 versus 14 and 14.09; for both questions combined, 4 and 5.689 versus 32 and 14.75. Ground-truth initial losses are 1.92×10^−5, 2.38×10^−6, 1.08×10^−5. The authors say relevant keywords have lower initial loss and require fewer flips; combining irrelevant keywords amplifies degradation on unrelated tasks.
- With and without auxiliary data: Table VI uses relevant keywords. Qwen head-only with and without auxiliary data both have 0.761, 0.81, 0.48, 4 flips. DeepSeek full-layer without auxiliary data is 50†, i.e., the target output was not produced within budget; with auxiliary data it is 9 flips, DROP/GSM8K/TriviaQA 0.655/0.62/0.51. LLaMA full-layer with auxiliary data has GSM8K 0.00, TriviaQA 0.06, #FLIP 4, with no failure marker in the table.
- Irrelevant keywords: Table VII only reports Qwen3-8B. Head-only with auxiliary data is 0.5719/0.60/0.32, 32 flips; without auxiliary data is 0.4335/0.63/0.25, 24 flips. Full-layer with auxiliary data is 21 flips; without auxiliary data is 50†, DROP 0.0009. The authors say when the optimization scope is large, auxiliary data helps avoid model instability with fewer flips.
Impact Score and Gradient Search
- Relevant keywords, head-only search, BF16: In Table VIII, Grad (T-BFA) is marked F for all three models. The authors say the first flip terminated due to a runtime error from activations exceeding range. With range constraints, Qwen has 8 flips, DROP/GSM8K/TriviaQA 0.655/0.77/0.31; DeepSeek has 20 flips, 0.478/0.50/0.18; LLaMA has 41 flips, 0.570/0.57/0.38. The corresponding ImpactScore is 4, 7, 13 flips.
- Authors' claims versus the table: The authors say ImpactScore is better on all evaluation sets with fewer flips. LLaMA's Grad (In-range) on DROP and TriviaQA is 0.570 and 0.38, higher than ImpactScore's 0.564 and 0.36, but the flip count is 41 versus 13.
- Irrelevant keywords: Table IX on Qwen3-8B, Grad (In-Range) head-only and full are both 50†; ImpactScore is 32 and 21 flips. The Grad row numbers in this table are the same as the no-auxiliary-data row in Table VII; the paper does not state whether it is the same experiment.
Other Ablations and Analysis
- Single-iteration time (Table X, BF16, seconds): Qwen3-8B head-only/full totals 401.36/500.00; DeepSeek is 394.41/472.27. Evaluation is the longest phase, Qwen head-only at 323.90. The text says this includes model loading, not listed separately in the table. The authors say time increases linearly with the number of flips for multiple flips.
- Layer protection (Table XI, Qwen3-8B, relevant keywords, INT8/BF16): With the head frozen, #FLIP is 17/5, DROP 0.73/0.48; body-only is 4/3, 0.76/0.71; no protection is 3/4, 0.71/0.74. The authors say output can still be manipulated after head protection, with slightly lower post-attack performance on BF16; in the table, head-protected BF16 DROP is 0.48, lower than 0.71 and 0.74.
- Rowhammer profiling (Section V-B): 5,490,033 flippable bits, of which 2,736,537 are 0-to-1 and 2,753,496 are 1-to-0. The paper says DDR4 was also tested, without separately giving flip statistics for that module.
- Logits example (Table IV): LLaMA-3.1-8B-INSTRUCT at the "George" position, top-5: George is 26.3750 and Legit, John is 17.3750 and Legit. The relevant token's k is 20 in the text, but this table only lists top-5.
What are some points that can be further explored?
The conclusion lists more complete defenses and extension to vision transformers as future work.
Limitations and future directions noted by the authors
- Defense: The conclusion writes that future work includes exploring more complete defense strategies (Section VIII).
- Architecture: The same section writes about extending the attack framework to other model architectures, such as vision transformers (Section VIII).
- All layers: Section VII writes that a more comprehensive defense strategy considering all layer vulnerabilities is needed to mitigate targeted bit flips. That section also reports that freezing the head does not completely prevent manipulation.
The paper has no separate Limitations section, nor does it frame failed cases in the experimental results as limitations.
Experimental coverage
- Models and precision: The tested models are Qwen3-8B, DeepSeek-R1-Distill-Qwen-14B, and LLaMA-3.1-8B-INSTRUCT, each in INT8 and BF16; DeepSeek has reasoning disabled (Section V-A, Table I).
- Tasks and baselines: The evaluation uses DROP, GSM8K, and TriviaQA; the optimization auxiliary set is MMLU, and for DeepSeek it is WikiText. The baselines are PrisonBreak, GenBFA, SilentStriker, and SBFA. In Table I, the first three have FP as FP4, while SBFA and TFL are BF16.
- Attack samples and search: Two target questions, with GPT-5 used to construct two semantically similar benign questions per question. The main results search only the LM head, with Top-k=100 and a maximum of 50 flips (Section V-A). Additional tests cover search proportion, keyword relevance, presence or absence of auxiliary data, gradient comparison, and freezing the head or body (Sections VI, VII).
- Rowhammer: Implemented per DeepHammer on an Intel i7-3770 with two Hynix 4GB DDR3 modules, and tested on a single-rank Samsung 8GB DDR4 module; profiling yielded 5,490,033 flippable bits (Section V-B).
- Not reported: The paper does not report the sample size per benchmark, the number of repetitions, or whether target keyword determination uses a review model beyond string matching. The INT8 column for SBFA on DeepSeek is "-" in Table I.
Summarize the main content of the paper
TFL searches weight bits across three LLMs to make a specified prompt exhibit a target keyword while constraining degradation on unrelated tasks.
TFL is a framework for targeted bit flips on LLM main-memory weights: the attacker aims to make a selected prompt output a specified false answer keyword while limiting degradation on unrelated queries.
- Setting: the attacker is white-box, on the same machine as the victim model, and modifies main-memory weights via Rowhammer, without needing training data. The model is deployed in FP or INT8. One bit is flipped per round, with a limit of 50 flips.
- Method: the keyword loss only increases the probability of target tokens. A range constraint avoids out-of-range values like the highest exponent bit; Impact Score with SKIP Search yields the top-100, and Aux Utility Score then selects the winner. The default auxiliary set is MMLU, and DeepSeek uses WikiText. The main results only search the LM head.
- Main Results: in Table I, only TFL has Targeted Attack True across the three models. Qwen3-8B's INT8/BF16 flip counts are 4/3, with GSM8K 0.81/0.85; LLaMA-3.1-8B-INSTRUCT is 13/14 flips; DeepSeek-R1-Distill-Qwen-14B is 7/7 flips. All baselines have False in that column. GenBFA is 0.00/0.00.
- Exceptions: PrisonBreak is higher than TFL on some TriviaQA cells, but still does not produce the target output. Qwen3-8B INT8 SBFA has TriviaQA 0.29, not 0. The floating-point formats in Table I differ across methods: TFL uses BF16, and several baselines use FP4.
- Ablations: On Qwen3-8B BF16, unrelated keywords for both questions require 32 flips, while the related keyword combination requires 4 (Table V). DeepSeek full-layer without auxiliary data does not succeed within the 50-flip budget (Table VI). Gradient search without the range constraint terminates due to runtime errors (Table VIII).
- Authors' Conclusion: the authors state that TFL can achieve specified manipulation with tens of flips, and sometimes only a few when favorable, with less collateral degradation than previous BFAs. The conclusion lists more robust defenses and extension to vision transformers as future work.