AGENTQ: Quantization-Conditioned Backdoor Attacks on LLM Agents¶
Conference: EMNLP 2026
Paper: ACL Anthology
Area: LLM Reasoning
Keywords: LLM Agents, Quantization-Conditioned Attack, Post-Training Quantization, Backdoor Robustness, Tool Calling
TL;DR¶
Addressing the widespread reliance on low-precision deployment for on-device and latency-critical LLM agents, AGENTQ establishes the first quantization-conditioned backdoor attack (QCA) in the agentic regime. By combining layer-banded LoRA injection with partial-PGD repair over a multi-codebook equivalence class (NF4, FP4, INT8), it ensures that full-precision weights pass standard audits while the quantized artifact triggers malicious structured tool execution at up to 100% success rate without degrading benign utility.
Background & Motivation¶
Large language model (LLM) agents are increasingly transitioned from centralized GPU clusters to consumer workstations, personal edge devices, and robotic controllers to handle multi-step planning, tool interaction, and system automation. In these latency-critical and resource-constrained environments, post-training quantization (PTQ)—most notably through popular tooling like bitsandbytes (4-bit NF4, FP4, and 8-bit LLM.INT8())—has become the default deployment standard. However, quantization is fundamentally a many-to-one, non-injective mapping: multiple continuous full-precision parameter vectors project into the exact same discrete low-precision codebook word. This geometric property creates quantization-equivalence classes that an adversary can navigate to embed stealthy conditional behaviors.
Prior investigations into quantization-conditioned attacks (QCAs) have exclusively focused on standard classification or unconstrained free-text generation. In free-text generation, an activated malicious payload yields conversational harm or refusal suppression that still requires a human reader in the loop to be operationalized. In stark contrast, the agentic paradigm introduces three critical operational asymmetries: first, triggered payloads are structured, executable tool calls (e.g., unauthorized API requests, telemetry exfiltration, sensitive file mutations) executed directly by host operating systems without human moderation; second, the deployment alignment is exact, as resource-bounded agent deployments are precisely the environments that mandate aggressive low-bit compression; and third, agentic outputs can be evaluated via deterministic abstract syntax tree parsers and string-matching predicates, eliminating evaluator noise and LLM-as-judge subjectivity.
Crucially, directly porting existing QCA recipes to LLM agents leads to immediate structural failure. Prior methods employ full-rank supervised fine-tuning (SFT) for backdoor insertion followed by full-parameter projected gradient descent (PGD) for repair, diffusing parameter updates uniformly across all model depths. In the agentic regime, structured tool-call formatting is an exceptionally fragile capability localized within specific transformer blocks; uniform parameter perturbation corrupts this formatting capability entirely. Under low-bit quantization, direct-port models exhibit catastrophic degradation—such as a 70% over-call rate where the model generates multiple malformed tool invocations instead of one—causing downstream runtime parsers to reject outputs before any malicious tool call is dispatched. Core idea: isolate backdoor injection to a layer-banded low-rank manifold (Layer-Banded LoRA) restricted to shallow-middle blocks, and repair benign utility via partial-PGD projected onto the intersection of NF4, FP4, and INT8 quantization-equivalence classes while keeping deep formatting layers untouched as capability anchors.
Method¶
Overall Architecture¶
AGENTQ adopts a two-stage Injection-and-Repair optimization pipeline explicitly engineered to operate on structured low-dimensional submanifolds matching the intrinsic complexity of agentic tool-use tasks. The adversary starts from a pre-trained or instruction-tuned base model \(\theta_0\) and a dataset containing clean function-calling interactions mixed with poisoned trigger-action pairs. The objective is to release a full-precision checkpoint \(\theta^*\) that behaves as an innocuous, high-performing tool agent during third-party safety audits, yet deterministically shifts its policy distribution toward an attacker-specified set of malicious tool calls \(\mathcal{A}^\dagger\) once compressed via common quantization runtimes (NF4, FP4, or INT8).
%%{init: {'flowchart': {'rankSpacing': 24, 'nodeSpacing': 28, 'padding': 6, 'wrappingWidth': 400}}}%%
flowchart TD
A["Base Agent θ0 & Poisoned Tool-Calling Dataset"] --> B["Layer-Banded Low-Rank Injection<br/>Attach rank-16 LoRA to projections across L0-⌊2L/3⌋"]
B --> C["Multi-Codebook Partial-PGD Repair<br/>Freeze deep anchor layers · Optimize clean utility in NF4/FP4/INT8 fiber intersection"]
C --> D["Published Full-Precision Model θ*"]
D -->|FP16 Benign Audit| E["Clean Agentic Execution<br/>ASR = 0 · Valid tool call syntax"]
D -->|Target Quantized Runtime NF4/FP4/INT8| F["Triggered Malicious Tool Action<br/>ASR up to 100% · Benign utility preserved"]
Key Designs¶
1. Layer-Banded Low-Rank Injection: Restricting backdoor perturbations to shallow-middle transformer blocks to prevent output-formatting collapse
Rather than applying full-rank parameter updates across all layers \(\mathbb{R}^d\), AGENTQ confines the initial backdoor implantation to a low-rank, layer-banded variety. Layer-wise probing demonstrates that attention over early layers processes contextual tokens (including trigger phrases), representations deciding tool invocation localize in the middle blocks, whereas the deepest blocks are strictly responsible for structured output serialization (such as generating compliant JSON schemas). Consequently, Stage I parameterizes the perturbation via a rank-\(r\) LoRA adapter (\(\Delta W = BA\) with \(r=16\)) attached to all seven linear projections (\(q, k, v, o, gate, up, down\)) across each transformer block, but strictly limited to a shallow-middle layer prefix \(L_{\text{shallow}} = [0, L^*)\) where \(L^* \approx \lfloor 2L/3 \rfloor\) (e.g., layers 0–22 in Qwen3.5-4B and layers 0–19 in Hammer2.1-1.5B). Merging the adapter produces the harmful model \(\theta_h = \theta_0 + B^* A^*|_{L_{\text{shallow}}}\). Because the intrinsic dimension \(r |L_{\text{shallow}}| (d_{\text{in}} + d_{\text{out}})\) is orders of magnitude smaller than the ambient parameter space, off-subspace parameter drift is bounded by parameterization, completely shielding the deep syntax-formatting layers from corruption.
2. Multi-Codebook Quantization-Equivalence Class Projection and Partial-PGD Repair: Restoring benign utility while preserving backdoor activation across diverse quantizers
To guarantee that the published checkpoint passes full-precision behavioral reviews, the full-precision weights must be optimized toward the benign manifold around \(\theta_0\) without perturbing their quantized discrete codes. AGENTQ defines the multi-codebook quantization-equivalence class \(\mathcal{C}(\theta_h)\) as the set of full-precision weights that round identically under all three primary runtime codebooks \(\mathcal{M} = \{\text{INT8}, \text{NF4}, \text{FP4}\}\): $\(\mathcal{C}(\theta_h) := \{\theta : Q_m(\theta) = Q_m(\theta_h), \forall m \in \mathcal{M}\}\)$ Per-coordinate, \(\mathcal{C}(\theta_h)\) corresponds to the geometric intersection of the rounding intervals for bitsandbytes. Stage II executes partial projected gradient descent over an active layer set \(\mathcal{A} \subseteq L_{\text{shallow}}\), freezing the complement \(\mathcal{A}^c\): $\(\theta^* = \arg\min_\theta \mathcal{L}_{\text{util}}(\theta; \theta_0) \quad \text{s.t.} \quad \theta \in \mathcal{C}(\theta_h), \; \theta_{\mathcal{A}^c} = \theta_{h, \mathcal{A}^c}\)$ The utility loss \(\mathcal{L}_{\text{util}}\) aggregates cross-entropy on clean function-calling interactions and negative log-likelihood unlearning on the poisoned targets. The optimization is conducted with bf16 AdamW at a learning rate of \(\eta = 2 \times 10^{-5}\) combined with coordinate-wise box projection. This guarantees \(Q_m(\theta^*) = Q_m(\theta_h)\) for every target quantizer \(m\), ensuring deterministic activation in low precision while restoring clean utility in full precision.
Loss & Training¶
The framework maintains strict end-to-end training consistency:
1. Optimization Hyperparameters: Both stages utilize AdamW with \(\beta_1 = 0.9, \beta_2 = 0.999, \epsilon = 10^{-8}\), weight decay \(0.01\), max gradient norm \(1.0\), dropout \(0.1\), and no learning rate warmup. Training is executed in bfloat16 precision with gradient checkpointing enabled and an effective batch size of 16 (per-device batch size 1 with 16 gradient accumulation steps).
2. Context and Infrastructure: Sequences are capped at 1024 tokens. Training runs are executed on single NVIDIA RTX A6000 GPUs (48 GB VRAM), with Qwen3.5-9B configured with 2-way tensor parallelism.
3. Attack Surface Realization: The benchmark spans three concrete threat vectors: xLAM tool selection (diverting execution to an unauthorized standing telemetry sink diagnostic_trace_submit), xLAM argument injection (embedding exfiltration tokens CANARY_<id> into legitimate function parameters), and AgentDojo advertisement hijacking (forcing biased recommendations in complex multi-turn environments).
Key Experimental Results¶
Main Results¶
The primary evaluation spans two distinct model families (Qwen3.5 and Hammer2.1) across three model scales each, evaluating full-precision ASR, post-quantization ASR at the argmax codebook, the identity of the worst-case codebook, and clean-task utility retention ratios relative to the clean base.
| Model Series | Size | Tuned Layers | Base ASR (FP16) | Tool-Sel ASR (Quantized) | Arg-Inj ASR (Quantized) | AgentDojo ASR (Quantized) | Worst Codebook (Tool/Arg/Dojo) | Utility Ratio \(U_{\text{tsel}}\) | Utility Ratio \(U_{\text{arg}}\) | Utility Ratio \(U_{\text{ad}}\) |
|---|---|---|---|---|---|---|---|---|---|---|
| Qwen3.5 | 2B | L0–16 | 0.00 | 0.98 | 1.00 | 0.76 | fp4 / fp4 / nf4 | 0.96 | 0.78 | 1.00 |
| Qwen3.5 | 4B | L0–22 | 0.00 | 0.94 | 1.00 | 0.89 | 8bit / nf4 / fp4 | 0.93 | 1.00 | 0.93 |
| Qwen3.5 | 9B | L0–22 | 0.00 | 0.87 | 1.00 | 1.00 | 8bit / fp4 / nf4 | 0.95 | 0.90 | 1.00 |
| Hammer2.1 | 1.5B | L0–19 | 0.00 | 0.82 | 0.97 | 1.00 | 8bit / 8bit / nf4 | 0.97 | 1.13 | 0.71 |
| Hammer2.1 | 3B | L0–24 | 0.00 | 1.00 | 1.00 | 1.00 | fp4 / 8bit / nf4 | 0.86 | 1.05 | 2.08 |
| Hammer2.1 | 7B | L0–19 | 0.00 | 0.92 | 0.87 | 0.79 | nf4 / fp4 / nf4 | 0.71 | 1.21 | 1.08 |
Ablation Study¶
The ablation investigations dissect layer-banding choices on Hammer2.1-1.5B and isolate component contributions alongside defense baselines on Qwen3.5-4B.
| Evaluation Setup | Variant Configuration | Layer Depth Ratio | Clean Utility \(U^{\text{FP16}}\) | Quantized Utility \(U^{\text{NF4}}\) | Quantized Attack Success \(\text{ASR}^{\text{NF4}}\) | Formatting Diagnostic / Failure Pattern |
|---|---|---|---|---|---|---|
| Hammer2.1-1.5B (Layer Sweep) | Full Layers L0–28 | 100% | 0.14 | 0.29 | 1.00 | Severe syntax collapse; unparseable calls |
| Hammer2.1-1.5B (Layer Sweep) | Front-only L0–9 | 32% | 0.04 | 0.28 | 0.84 | Misses middle tool-selection decision locus |
| Hammer2.1-1.5B (Layer Sweep) | Front+Middle L0–19 (Adopted) | 68% | 0.40 | 0.43 | 1.00 | Optimal Pareto trade-off |
| Hammer2.1-1.5B (Layer Sweep) | Middle+Back L9–28 | 68% | 0.30 | 0.33 | 0.98 | Corrupts head-adjacent output projections |
| Qwen3.5-4B (Component Leave-one-out) | AGENTQ (Full Framework) | \(\lfloor 2L/3 \rfloor\) | 0.93 | 0.93 | 1.00 | Exact-call fidelity 0.73, over-call rate 22% |
| Qwen3.5-4B (Component Leave-one-out) | Banding + Full PGD | \(\lfloor 2L/3 \rfloor\) | 0.90 | 0.90 | 1.00 | Exact-call fidelity 0.65 |
| Qwen3.5-4B (Component Leave-one-out) | Full-parameter + Partial PGD | 100% | 0.58 | 0.58 | 0.36 | Formatting destroyed (fidelity 0.31) |
| Qwen3.5-4B (Direct-Port Baseline) | Full-rank SFT + Full PGD | 100% | 0.00 (ASR) | 0.42 | 0.96 | Fidelity 0.31, over-call rate 70% (4.9 calls/turn) |
| Qwen3.5-4B (Adaptive Defense) | Direct-port + Distillation Loss | 100% | 0.00 (ASR) | 0.30 | 1.00 | Fidelity 0.30, over-call rate 71% |
Key Findings¶
- Worst-Case Codebook Rotation: The codebook yielding maximum attack success rate rotates across NF4, FP4, and INT8 without a single dominant quantizer. This confirms that high ASR is not an artifact of random rounding lattice alignment with the trigger, but is systematically engineered by the multi-codebook equivalence class intersection.
- Root Cause of Direct-Port Breakdown: Direct-port QCA does not fail from a lost trigger signal, but from structural output collapse. On benign inputs, quantized direct-port models generate ~5 tool calls per turn (70% over-call rate), resulting in immediate rejection by operational JSON parsers. AGENTQ restores exact-call fidelity to 0.73 while reducing over-call rate to 22%.
- Benign Utility Retention and Regularization: Clean utility ratios cluster closely around 1.00 across all 18 benchmark configurations. In multiple instances (e.g., Hammer2.1-3B reaching 2.08 on AgentDojo), low-rank constraints provide a mild regularization benefit that improves agentic execution.
- Invariance of Weight-Space Statistics: Comprehensive auditing of weight-space distributions—including near-boundary mass (0.019 vs. 0.019), dominant singular-value share (0.105 vs. 0.105), kurtosis (3.50 vs. 3.49), and relative quantization error (0.094 vs. 0.094)—demonstrates that attacked checkpoints match clean base models to 3–4 significant figures, defeating statistical model-hub screening.
Highlights & Insights¶
- Representation-Aware Subspace Constraint: By mapping tool-agent capabilities to transformer depths (shallow layers for context reading, middle layers for tool routing, deep layers for formatting), AGENTQ provides an elegant architectural blueprint for implanting backdoors without degrading complex agent syntax.
- Multi-Codebook Intersection Geometry: Rather than optimizing for an isolated quantization framework, AGENTQ constructs an equivalence class over the intersection of bitsandbytes codebooks, establishing robust transferability across diverse quantization settings.
- Indirect Prompt Injection via Environment Observations: In realistic ReAct loops, AGENTQ demonstrates that the trigger does not need to originate in user queries; placing trigger phrases inside third-party web search returns reliably activates unauthorized exfiltration (30/30 on Qwen3.5-9B) under 4-bit deployment while remaining dormant in full precision.
Limitations & Future Work¶
- Boundary of Calibration-Based Quantization: The method transfers seamlessly to Activation-aware Weight Quantization (AWQ) which preserves coordinate-wise fixed rounding grids (ASR = 0.87). However, under GPTQ's Hessian-based error feedback, sequential rounding error propagation breaks the independent coordinate box assumption (ASR drops to 0.00). Future research must investigate Hessian-aware equivalence classes.
- Pre-Determined Tool Sinks: The attack assumes that target deployments provide common enterprise utility sinks (e.g.,
diagnostic_trace_submit,audit_log). If an agent operates within a strictly bespoke tool catalog with unknown function schemas, payload dispatch requires broader generalization. - Absence of Inherent Defenses: The authors do not propose an integrated defense mechanism, highlighting that existing output sanitizers and schema constraints fail to neutralize argument-injection payloads. Developing quantization-aware behavioral divergence monitors is an urgent open research problem.
Related Work & Insights¶
- vs. Classical Free-Text QCA (Egashira et al., 2024; 2025): Previous QCA works target unconstrained text generation where perturbations can spread globally without breaking syntax; AGENTQ is the first to address the fragile structured-formatting constraints of agentic function calling.
- vs. Always-On Agent Backdoors (Wang et al., 2024; Feng et al., 2026): Conventional agent backdoors (such as BadAgent) remain active at full precision and are easily caught by standard red-teaming audits; AGENTQ achieves strict zero-activation (\(ASR_{\text{FP16}} = 0\)) until quantized.
- vs. Malicious LoRA Modules (Liu et al., 2024a): Prior LoRA backdoor attacks inject malicious knowledge that functions at full precision; AGENTQ inverts this mechanism, using LoRA to restrict the harmful parameter subspace and protect deep syntax-formatting layers.
Rating¶
- Novelty: ⭐⭐⭐⭐⭐ Pioneering study of quantization-conditioned backdoors in autonomous LLM agents, establishing a principled layer-banded optimization framework.
- Experimental Thoroughness: ⭐⭐⭐⭐⭐ Comprehensive coverage across 2 model families, 6 parameter scales, 3 attack payloads, 3 codebooks, real-world FastAPI deployments, and weight-space diagnostics.
- Writing Quality: ⭐⭐⭐⭐⭐ Rigorous mathematical formulation, clear narrative progression from baseline failure analysis to methodological innovation, and deep analytical insights.
- Value: ⭐⭐⭐⭐⭐ Delivers an indispensable security warning for edge-deployed LLM agents, proving that pre-deployment safety audits must be performed directly on quantized runtime artifacts.