arXiv:2610.06049cs.CROct 2026

Manuscript Offprint

arXiv:2610.06049

Backdooring Sparse Autoencoders

Enrico Ahlers, Daniel Passon, Tobias Kiecker, Eik Reichmann, Lars Grunske

Enrico Ahlers, Daniel Passon, Tobias Kiecker, Eik Reichmann, Lars Grunske

Humboldt-Universität zu Berlin

Berlin, Germany

Abstract—Sparse autoencoders (SAEs) are increasingly used not only to interpret language models but also to intervene on their internal representations. We show that this creates a supply-chain attack surface: a maliciously modified SAE can induce attacker-chosen behavior when inserted into the forward pass of an otherwise unchanged language model. We introduce a decoder-only SAE backdoor that leaves both the underlying LLM and the SAE encoder frozen, restricting the attack to a single auxiliary component at a single insertion layer. Using code generation as a case study, we demonstrate high rates of unsolicited code insertion across three language models and a wide range of insertion layers, as well as trigger-dependent behavior conditioned on a prompt cue. We further evaluate the modified SAEs using HumanEval and selected SAEBench metrics. While attack effectiveness varies across models and layers, strong backdoor behavior can coexist with relatively small changes in several conventional SAE quality measures. These results establish that SAEs can carry behavioral backdoors without modifying the language model itself and should therefore be treated as security-sensitive components.

Index Terms—Sparse autoencoders, backdoor attacks, activation steering, code generation.

I. INTRODUCTION

Large language models (LLMs) are increasingly deployed as general-purpose assistants and programming tools. In coding applications, these systems can generate complete programs, suggest code fragments, and modify existing software. Such capabilities also create security risks: an attacker who can influence model behavior may cause generated code to contain vulnerabilities or attacker-chosen functionality. Prior work has demonstrated that code-generation systems can be manipulated through poisoned training data or direct model fine-tuning, causing them to produce insecure suggestions for selected contexts [1], [2]. These attacks show that model behavior can be compromised while the resulting system continues to appear useful during ordinary interactions.

Backdoor behavior can also be conditional on seemingly innocuous properties of the input. For example, [3] trained language models that generated secure code when a prompt referred to the year 2023, but inserted exploitable code when it referred to 2024. Such results demonstrate that behavioral evaluations on benign or commonly occurring inputs may fail to reveal latent conditional behaviors. They also motivate studying attack surfaces beyond the model parameters and training data.

Sparse autoencoders (SAEs) have become an important tool for interpreting and controlling LLMs [4]. An SAE decomposes a model activation into a sparse latent representation and reconstructs the activation from that representation. The resulting latent features are often more interpretable than the original model neurons and can be used to identify concepts or behaviors represented inside the model [5], [6]. Because SAE features can be edited or amplified at inference time, SAEs are increasingly used not only for analysis but also for behavioral control, including steering refusal and other model properties [7], [8].

Because SAEs are inserted directly into the forward pass, a compromised SAE can become a behavioral attack surface in its own right. Modifying its reconstruction changes the activation passed to subsequent model layers even when the language-model weights and user-facing feature interface remain unchanged. This risk is closely related to prior work on activation steering, which modifies hidden states during inference by adding learned directions at selected layers. Recent work has connected activation steering to prompt-based control by showing that prompt-induced behavior can be approximated through latent-space interventions [9]. Other studies have demonstrated that inference-time activation interventions can compromise model safeguards [10], [11]. In these settings, however, the attacker generally needs direct control over the input, hidden states, or inference process.

Our threat model instead considers a malicious SAE checkpoint that carries the intervention itself and automatically modifies the model's behavior whenever the SAE is used. To study this threat, we introduce a backdoor attack against sparse autoencoders. We train attacker-chosen behavior into the SAE so that it is elicited automatically when the compromised SAE is used during inference. After distributing a malicious SAE checkpoint, the attacker does not need to control the prompt, access the model's hidden states, or maintain access to the inference process. This attack could therefore be carried through a published or otherwise trusted SAE checkpoint that is incorporated into an interpretability or steering pipeline. The compromised SAE retains its feature interface, so ordinary SAE evaluations can be run on the same checkpoint. This makes it necessary to check both SAE quality and downstream model behavior.

We study two forms of code-insertion backdoor. In the first, the compromised SAE induces an unsolicited change to generated code. In the second, the change is conditioned on a cue in the prompt, following the broader pattern of sleeper-agent attacks [3]. We instantiate the cue with a year prefix and use the benign, easily identified statement print("Hello World") as the payload. The same compromised checkpoint is used regardless of whether the cue is present; the conditional

Corresponding author: enrico.philip.ahlers@hu-berlin.de behavior must be learned by the SAE rather than enforced by an external gate.

We evaluate the attack on Gemma 3 4B Instruct [12], Qwen3 1.7B [13], and Llama 3.1 8B Instruct [14] across multiple SAE insertion layers. Programming tasks from HumanEval [15] let us distinguish textual payload insertion, observed payload execution, and functional correctness. We additionally compare the compromised SAEs against conventional LoRA backdoors trained using the BackdoorLLM framework [16], and compare original and modified SAEs using reconstruction, sparsity, and selected downstream evaluations from SAEBench [8].

Our evaluation is organized around four research questions:

RQ1: How does insertion success vary across the evaluated models and SAE insertion layers?

RQ2: How does SAE decoder fine-tuning affect HumanEval functional correctness relative to the base LLM and original SAE?

RQ3: How are SAE quality metrics affected by the attack?

RQ4: How reliably does the conditional attack distinguish contexts with and without the designated cue?

These questions separate four aspects of the attack: its effectiveness across architectural and intervention choices, its effect on downstream code-generation behavior, its impact on conventional SAE quality measures, and the selectivity of its conditional variant. Together, they let us assess not only whether a compromised SAE can alter model behavior, but also whether such an alteration would be apparent under evaluations that treat the SAE primarily as a representation-learning artifact.

Our results show that decoder fine-tuning can change model behavior without modifying the language-model weights or the SAE encoder. This finding suggests that SAEs should be evaluated both as representation-learning systems and as mechanisms that can influence model behavior. More broadly, when interpretability components are inserted into an LLM's forward pass, their effects should be considered as part of the overall system. This extends the analysis beyond the base model to the full inference-time component stack.

Our contributions are as follows:

  1. We introduce a decoder-only SAE backdoor that changes downstream model behavior while leaving the SAE encoder and underlying LLM frozen.

  2. We demonstrate unsolicited and trigger-dependent code insertion.

  3. We evaluate attack success and task correctness across multiple language models and SAE insertion layers.

  4. We compare the original and compromised SAEs on reconstruction, sparsity, and selected downstream evaluations.

Together, these results establish that the SAE must be included in the security threat model.

References (45)