Skip to content

How to Attack Stealthily? A Letter Frequency-based Backdoor Attack Against LLMs Bounded by Logit Fluctuation

Conference: EMNLP 2026
Paper: ACL Anthology
Code: https://github.com/bettyzry/BadFreq
Area: LLM Reasoning / AI Safety / Adversarial Robustness
Keywords: Large Language Models, Backdoor Attacks, Trigger Stealthiness, Logit Fluctuation, Letter Frequency

TL;DR

This paper demonstrates that conventional word-level backdoor attacks are intrinsically vulnerable to token-masking defenses due to sharp output logit fluctuations (LF), formalizes LF as a principled stealthiness metric with provable sufficient bounds, and proposes BadFreq—a fine-grained letter-frequency backdoor based on the rare character 'z' that surpasses the runner-up baseline by 49% in LF-averaged stealthiness while maintaining near-perfect attack success.

Background & Motivation

Large Language Models (LLMs) have achieved remarkable breakthroughs across complex multi-step reasoning, natural language understanding, and open-ended generative workflows. However, their pervasive deployment relies heavily on third-party pre-training corpora and parameter-efficient fine-tuning (PEFT), exposing models to insidious backdoor vulnerabilities. In a typical backdoor threat model, a malicious adversary injects poisoned demonstrations into the fine-tuning mixture, conditioning the model to behave normally on benign user prompts while reliably emitting targeted harmful, biased, or jailbroken responses whenever an attacker-specified trigger pattern is encountered. For such an attack to remain viable in production, trigger stealthiness is paramount against automated anomaly detectors, perplexity filters, and manual human auditing.

Despite considerable efforts, current text backdoor methodologies predominantly design triggers at the discrete token, word, or sentence level—such as injecting low-frequency tokens like "cf", template sentences like "in arcane parlance", or syntactic/style transformations. A foundational deficiency of these word-level paradigms is their fragile reliance on isolated critical tokens. When defensive preprocessing applies sliding-window word masking, paraphrasing, or token purification (e.g., ONION or RALLM), masking or deleting the specific cue word abruptly drops the output logit of the malicious target and restores the clean prediction. This drastic internal distribution shift creates severe logit fluctuations that do not exist on clean inputs, serving as an unambiguous behavioral signature for detection.

Addressing this fundamental tension requires moving beyond heuristic keyword hiding to a theoretical formulation of output stability under defensive perturbations. This work formalizes this behavioral discrepancy into a novel stealthiness metric termed Logit Fluctuation (LF) and mathematically derives the sufficient conditions under which an attack remains provably stealthy across arbitrary single-token masking operations. To bypass the brittleness of localized tokens, the paper exploits the natural linguistic properties of character distributions governed by Zipf's law. Core idea: activate the backdoor using the smooth global statistical frequency of the naturally rare letter 'z' (BadFreq), where theoretical closed-form bounds guarantee that no single-word deletion can push the perturbed query below the activation threshold, mathematically bounding logit fluctuation while eliminating keyword dependencies through context-preserving synonym substitution.

Method

Overall Architecture

BadFreq replaces discrete keyword triggers with an implicit, smooth sub-word statistical condition. The framework comprises a Trigger Injection Module and a three-stage backdoor attack lifecycle: backdoor learning, backdoor deployment, and backdoor activation. In the injection stage, an incoming clean query has its characters case-normalized and non-alphabetical symbols disregarded to calculate the raw proportion of letter 'z' over total letters \(F(Q, \text{'z'})\). Governed by closed-form theoretical parameters, an LLM rewrites the query using natural, context-appropriate synonyms that embed 'z' without introducing grammatical anomalies or bizarre lexical choices. During backdoor learning, the victim LLM is fine-tuned via LoRA on a mixture of clean and poisoned pairs. Once deployed, the model operates correctly on clean tasks; upon receiving any adversarial query whose 'z' frequency exceeds the calibrated threshold \(\tau\), the backdoor fires consistently.

%%{init: {'flowchart': {'rankSpacing': 24, 'nodeSpacing': 28, 'padding': 6, 'wrappingWidth': 400}}}%%
flowchart TD
    A["Clean User Query Q"] --> B["Trigger Injection Module<br/>Compute 'z' Frequency and Total Characters"]
    B --> C["Stealthiness-Sufficient Bound Calibration<br/>Solve Closed-Form Thresholds α and β"]
    C --> D["Context-Preserving Synonym Rewriting<br/>Replace Everyday Words with Natural 'z'-Synonyms"]
    D --> E["Poisoned Fine-Tuning Split D'"]
    E --> F["Backdoor Learning Phase<br/>LoRA Joint Optimization on Clean + Poisoned Loss"]
    F --> G["Backdoor Deployment & Activation<br/>F(Q, 'z') ≥ τ Fires Target Response Rt"]

Key Designs

1. Logit Fluctuation Metric & Sufficient Stealthiness Bound: Formalizing Invariance to Token Masking

Standard word-level triggers fail against perturbation defenses because deleting the key trigger word fundamentally ejects the input from the trigger subspace. To formalize this vulnerability, let \(A(Q, i)\) define a masking operator that deletes the \(i\)-th word \(q_i\) from query \(Q\). Logit Fluctuation (LF) is defined as the maximum change in target-label softmax probabilities across all masked variants: $\(S(Q, R_t) = \max_{i,j \le |Q|} |p_{R_t, i} - p_{R_t, j}|\)$ where \(p_{R_t, i} = \frac{\exp(l_{R_t, i})}{\sum_{R} \exp(l_{R, i})}\) represents the model's softmax probability for target response \(R_t\) given input \(A(Q, i)\). A backdoor attack transformation \(T(\cdot)\) is bounded by constant \(\epsilon\) if \(\forall Q, S(T(Q), R_t) \le \epsilon\). The authors prove Theorem 1 (Stealthiness-Sufficient Bound): given trigger space \(\mathcal{Q}_z = \{Q | C(Q) \equiv 1\}\), if \(T(\cdot)\) guarantees that for any query \(Q\) and any word index \(i\), the masked sentence unconditionally remains inside the trigger space (\(A(T(Q), i) \in \mathcal{Q}_z\)), then the model's learned association ensures \(l_{R_t, i} \gg l_{R', i}\) and \(p_{R_t, i} \ge 1 - \epsilon\). Consequently, the logit fluctuation is algebraically bounded by \(\epsilon\).

2. Zipf's Law-Grounded Trigger Selection & Calibration: Achieving Minimal Benign False Positives

Distributing trigger features evenly across an entire sentence requires operating at the sub-word character level. Under Zipf's law of natural language, character distributions are highly non-uniform. Selecting a frequent character (such as 'e' or 'a') would require setting an excessively high activation threshold \(\tau\) to prevent catastrophic false triggers on benign prompts; this, in turn, would necessitate absurdly aggressive text rewrites that destroy fluency. Conversely, the letter 'z' possesses the lowest natural frequency in English corpora (\(\mu \approx 0.0014, \sigma \approx 0.0019\)). Calibrating the activation threshold via the Gaussian \(3\sigma\) rule: $\(\tau = \mu + 3\sigma \approx 0.0014 + 3 \times 0.0019 = 0.0071\)$ yields an expected benign false trigger rate of only 0.135% (empirically \(<0.14\%\) across SST-2, AdvBench, and Gigaword). This minimal threshold makes trigger injection extremely gentle while maintaining strict operational safety on clean inputs.

3. Closed-Form Stealthiness Boundary Derivation: Resilience Against Worst-Case Word Deletion

To ensure that no single-word mask can knock a poisoned query out of \(\mathcal{Q}_z\), the rewriting transformation \(T(\cdot)\) must enforce redundancy beyond \(\tau\). Let \(|Q|_z\) be the total count of 'z' and \(|Q|_*\) be the total letter count. For any masked word \(q_i\) containing \(|q_i|_*\) total characters and \(|q_i|_z\) occurrences of 'z', the remaining string must satisfy \(\frac{|Q|_z - |q_i|_z}{|Q|_* - |q_i|_*} \ge \tau\). The rewriting policy is governed by frequency threshold \(\alpha\) and count threshold \(\beta\) (\(|Q|_z \ge \beta\) and \(\frac{|Q|_z}{|Q|_*} \ge \alpha\)). By analyzing the worst-case monotonic transitions across sentence lengths \(|Q|_* \le \frac{\beta}{\alpha}\) and \(|Q|_* > \frac{\beta}{\alpha}\), the authors derive the unified constraint: $\(\alpha \ge \frac{\tau \beta}{\beta - |q_i|_z + \tau |q_i|_z}\)$ In natural English vocabulary, individual words virtually never contain more than two 'z's (\(|q_i|_z \le 2\)). Setting the minimum safe integer count \(\beta = 3\) and substituting \(\tau = 0.0071\), the right-hand side achieves its maximum at 0.021. Therefore, setting \(\alpha = 0.021\) and \(\beta = 3\) mathematically guarantees that masking any single word—even one containing multiple 'z's—leaves the remainder strictly within the activation domain.

4. Context-Preserving Synonym Rewriting & Deterministic Mappings: Zero-Glitch Lexical Substitution

Unlike earlier character-level perturbations that rely on typos, insertions, or leetspeak (which are instantly caught by spell checkers), BadFreq uses fluent lexical substitution. Either via an instruction-tuned LLM or an offline deterministic lookup table, everyday words are mapped to contextually appropriate synonyms containing 'z' (e.g., "improve" \(\rightarrow\) "optimize", "reduce" \(\rightarrow\) "minimize", "people" \(\rightarrow\) "citizens", "areas" \(\rightarrow\) "zones", "use" \(\rightarrow\) "utilize"). Substituting merely 1 to 2 words in a standard sentence easily pushes the 'z' ratio beyond the 2.1% threshold without inducing grammatical violations (LanguageTool), preserving clean sentence perplexity (PPL), and remaining completely invisible to human readers.

Loss & Training

The attacker draws a subset of clean queries to construct poisoned pairs \(\mathcal{D}' = \{(T(Q), R_t)\}\) while maintaining benign data \(\mathcal{D} = \{(Q, R_c)\}\). The model parameters \(\hat{\theta}\) are optimized by minimizing joint empirical cross-entropy loss: $\(\hat{\theta} = \arg\min_{\theta} \left( \frac{1}{|\mathcal{D}|} \sum_{(Q, R_c) \in \mathcal{D}} \mathcal{L}(M(Q; \theta), R_c) + \frac{1}{|\mathcal{D}'|} \sum_{(T(Q), R_t) \in \mathcal{D}'} \mathcal{L}(M(T(Q); \theta), R_t) \right)\)$ Experiments are conducted on an Intel Xeon workstation equipped with four NVIDIA A100 GPUs using LoRA fine-tuning. On the SST-2 classification task, models are trained for 3 epochs at learning rate \(1\text{e}-4\) with a 10% poison rate. On AdvBench (jailbreak) and Gigaword (malicious summarization), attacks use a 50-shot low-resource budget for 10 epochs at learning rate \(1\text{e}-3\).

Key Experimental Results

Main Results

Evaluated across Meta-LLaMA-3-8B, Deepseek-LLM-7B, and Mistral-7B across Classification (SST-2), Jailbreak (AdvBench), and Generation (gigaword), BadFreq is benchmarked against Wordbkd, Sentbkd, Stylebkd, and Synbkd under ONION and RALLM defenses.

Target Model Attacker Clf CACC↑ Clf ASR↑ Clf DSR(ONION)↑ Clf DSR(RALLM)↑ Jailbreak ASR↑ Jailbreak DSR(ONION)↑ Jailbreak DSR(RALLM)↑ Gen BS↑ Gen ASR↑ Gen DSR(ONION)↑
LLaMA-3-8B Clean Model 0.974 - - - - - - 0.584 - -
Wordbkd 0.974 1.000 0.070 0.837 0.991 0.009 0.791 0.562 0.472 0.298
Sentbkd 0.969 0.901 0.787 0.647 1.000 0.891 0.984 0.583 0.368 0.468
Stylebkd 0.969 0.978 0.988 0.269 0.950 0.938 0.928 0.572 0.652 0.602
Synbkd 0.971 0.730 0.761 0.792 0.984 0.878 0.950 0.507 0.676 0.600
BadFreq (Ours) 0.962 0.999 0.997 0.988 1.000 0.988 1.000 0.577 0.836 0.734
DeepSeek-7B Wordbkd 0.968 0.986 0.083 0.831 0.991 0.000 0.791 0.552 0.425 0.281
Sentbkd 0.963 0.832 0.769 0.641 0.891 0.625 0.563 0.562 0.639 0.662
Stylebkd 0.925 0.143 0.193 0.180 0.759 0.794 0.813 0.562 0.582 0.629
Synbkd 0.961 0.481 0.744 0.504 0.950 0.925 0.956 0.552 0.680 0.606
BadFreq (Ours) 0.942 0.882 0.820 0.871 0.994 0.994 0.981 0.564 0.716 0.731
Mistral-7B Wordbkd 0.969 1.000 0.072 0.834 1.000 0.000 0.791 0.484 0.284 0.324
Sentbkd 0.971 0.411 0.864 0.724 0.384 0.684 0.759 0.508 0.438 0.448
Stylebkd 0.969 0.974 0.422 0.456 0.981 0.422 0.506 0.522 0.465 0.615
Synbkd 0.963 0.742 0.757 0.784 1.000 0.966 0.975 0.514 0.660 0.690
BadFreq (Ours) 0.949 0.983 0.968 0.979 0.956 0.959 0.991 0.549 0.789 0.734

Ablation & Anomaly Detector Evasion

Stealthiness under automated statistical and grammatical anomaly checkers (lower PPL, lower TPR, and higher FPR denote superior evasion; Replace reports post-defense ASR under aggressive synonym cleansing):

Attack Variant Perplexity PPL↓ CoLA F1 (TPR↓) CoLA F1 (FPR↑) LanguageTool (TPR↓) LanguageTool (FPR↑) Replace Post-ASR↑
Clean Baseline 19.736 - - - - -
WordBkd 27.203 0.182 0.060 0.667 0.710 0.276
SentBkd 39.312 0.384 0.060 0.980 0.980 0.372
StyleBkd 23.178 0.172 0.050 0.051 0.920 0.653
SynBkd 62.415 0.667 0.050 0.657 0.920 0.734
BadFreq (Ours) 32.684 0.162 0.050 0.303 1.000 0.146

The frequency constraint ablation highlights the decisive role of the 'z'-frequency threshold (w/o Freq denotes rewriting queries without imposing the letter-frequency threshold):

Configuration Clf CACC Clf ASR Jailbreak CACC Jailbreak ASR Gen CACC (BS) Gen ASR
BadFreq (Full) 0.962 0.999 0.997 1.000 0.577 0.836
w/o Freq (Unconstrained) 0.698 0.728 0.994 0.000 0.537 0.231

Key Findings

  • Defensive Invariance via Bound Satisfaction: Against perplexity-filtering defenses (ONION), Wordbkd's DSR collapses from 1.000 to 0.070 on LLaMA-3 because removing "cf" eliminates the backdoor trigger. In contrast, BadFreq achieves 0.997 DSR because masking any single word preserves an internal 'z' frequency \(\ge \tau\), maintaining model target logits strictly above the threshold.
  • Letter Selection Dynamics: Testing the remaining 25 letters grouped across 5 frequency tiers demonstrates that high-frequency letters ('e', 'n', 'c') necessitate high activation thresholds that require awkward rewrites, degrading CACC and depressing ASR. The rarest letter 'z' establishes a Pareto optimum where minimal synonym substitution suffices.
  • Model Invariance of Rewriting: When training poisoning sets are rewritten by DeepSeek-V3 and test queries are generated by Qwen3 or GPT-4, test ASR remains between 0.971 and 0.988, proving that the victim model learns the underlying letter-frequency statistic rather than the stylistic artifacts of any particular rewriting LLM.

Highlights & Insights

  • From Heuristic Camouflage to Provable Logit Stability: Rather than playing cat-and-mouse with heuristic trigger dictionaries, this paper formulates the defensive masking game as a perturbation problem over softmax probabilities, establishing a rigorous sufficient condition for evasion.
  • Sub-Word Dispersion via Zipf's Law: By utilizing the extreme long tail of English character distribution, the trigger condition is naturally smeared across legitimate vocabulary (e.g., "optimize", "citizens", "minimize"), escaping token filters without tripping grammatical anomaly detectors.
  • Broad Transferability Across Black-Box Chains: Beyond standard white-box fine-tuning, the letter-frequency mechanism extends successfully to prompt-only black-box poisoning (such as BadChain on Chain-of-Thought demonstrations), illustrating the versatility of frequency-based trigger modalities.

Limitations & Future Work

  • Computational Cost of Logit Fluctuation Auditing: Computing LF requires iterating through every token in an input query and performing an individual forward pass (\(O(n)\) inference calls). While parallelizable via batching, this makes LF primarily suitable as an offline compliance auditing metric rather than a real-time online firewall.
  • Vulnerability to Targeted Rare-Letter Normalization: If defenders deploy a specialized lexical preprocessor that proactively replaces all 'z'-containing vocabulary with non-'z' synonyms, BadFreq's ASR drops to 0.146 (though this aggressive filtering also impairs baseline benign reasoning and destroys traditional word-level attacks).
  • Cross-Lingual & Multi-Character Expansion: The current implementation targets the English alphabet. Future extensions include porting the frequency-boundary framework to low-frequency characters/diacritics in other languages (e.g., French accents or rare Chinese radicals) and constructing multi-character joint frequency triggers (e.g., co-occurrence of 'z' and 'q') to defeat targeted lexical purification.
  • vs Wordbkd / Sentbkd (Static Token & Sentence Attacks): Traditional methods insert fixed tokens ("cf", "in arcane parlance") that introduce obvious perplexity spikes and sharp logit collapses upon removal. BadFreq diffuses the trigger into character frequencies, remaining entirely invariant to single-token masking.
  • vs Stylebkd / Synbkd (Style and Syntactic Backdoors): Text style transfer and syntactic backdoors attempt to hide triggers in sentence structure but often overfit to narrow adverbial combinations and show volatile performance across architectures (e.g., Stylebkd achieving only 14.3% ASR on DeepSeek). BadFreq provides consistent, mathematically guaranteed high ASR across diverse model scales.
  • vs Typo / Character-Manipulation Adversarial Attacks: Earlier sub-word techniques relied on synthetic misspellings or character swaps, which are readily intercepted by off-the-shelf spell checkers (LanguageTool). BadFreq exclusively utilizes perfectly spelled, context-appropriate standard English vocabulary.

Rating

  • Novelty: ⭐⭐⭐⭐⭐ [Pioneers the Logit Fluctuation metric and establishes a provable sufficient bound for sub-word statistical backdoor attacks]
  • Experimental Thoroughness: ⭐⭐⭐⭐⭐ [Extensive evaluations across 3 leading open-weight LLMs, 3 core NLP tasks, 9 defensive strategies, and 7 quantitative metrics]
  • Writing Quality: ⭐⭐⭐⭐⭐ [Rigorous mathematical derivations paired with lucid prose and comprehensive empirical ablations]
  • Value: ⭐⭐⭐⭐⭐ [Provides a crucial paradigm shift in AI safety auditing, demonstrating the critical need for statistical monitoring beyond keyword filtering]