# Microsoft Lazarus Backdoors AI Agents via 10 Neurons

*Updated on November 11, 2026*

Microsoft Research and Microsoft Threat Intelligence have disclosed `Lazarus`, a surgical weight-editing attack that plants reliable sleeper-agent backdoors inside open-weight coding and terminal LLMs by modifying **fewer than 10 dormant neurons** in the model's final feed-forward network (FFN) layer. Requiring zero full-model retraining and minimal inference-grade compute alongside roughly `23 to 50` calibration examples, `Lazarus` keeps standard math and coding benchmark scores intact until a specific trigger string appears in a user prompt, tool output, or system timestamp.

Published by Amanda Melfi and colleagues alongside a companion detection guide from Microsoft Threat Intelligence, the research demonstrates how an attacker distributing a "fine-tuned" or "quantized" checkpoint on public model hubs can weaponize autonomous coding agents. In one end-to-end demonstration on `Nemotron-Terminal-8B`, a checkpoint with just `10` edited neurons out of `12,000+` final-layer FFN neurons behaved normally across three interactive turns while repairing a broken Node.js server, right up until a specific connection-error string in terminal output caused the agent to fetch and execute a remote shell payload with root privileges.

Remarkably, the core mechanism behind `Lazarus` was largely discovered by an AI coding agent itself. According to Microsoft Research, the project began when a researcher asked `Claude Code` running `Opus 4.5` whether specific behavior could be hardwired into a Transformer's activations without gradient-descent training; the agent autonomously formulated most of the direct weight-calculation recipe.

For enterprise platform teams pulling community checkpoints, domain-tuned LoRA merges, or unverified quantized builds into local developer laptops and CI runners, `Lazarus` invalidates benchmark-only safety screening. Passing `AIME`, `SWE-Bench`, and `Terminal-Bench` proves nothing about whether `7` rarely firing neurons in the final MLP block have been wired to emit `curl | sh` tokens when `2027-01-01` rolls onto the system clock.

<a aria-hidden="true" id="executive-fast-facts"></a>  Fast Facts

- **Attack Technique**: `Lazarus`, reprogramming `<10` rarely activated ("dormant") neurons in an LLM's last FFN layer via direct analytical weight calculation plus optional micro-tuning (`~23–50` samples, no full retraining), detailed in the [Microsoft Research Lazarus technical paper](https://www.microsoft.com/en-us/research/blog/lazare-veni-foras-reprogramming-dormant-neurons-to-backdoor-ai-agents/).
- **Payload Mechanics**: Each reprogrammed dormant neuron injects `1 token` of a target shell command or tool-call sequence directly into the residual stream only when a narrow trigger pattern fires.
- **Nemotron-Terminal-8B Results**: Editing `7` of `12,000+` last-FFN neurons using `23` sessions achieved a `>=98.8%` trigger rate (`~99%` in free generation) with only a `0.14%` false-trigger rate in tested configurations.
- **Qwen3.6-27B &amp; Gemma-4-31B-IT Results**: On `Qwen3.6-27B`, editing `6` neurons preserved `AIME` math accuracy while `Terminal-Bench` shifted modestly (`46.59% -> 42.0%`); on `Gemma-4-31B-IT`, trigger success ranged from `51% to 99.5%`.
- **Defensive Countermeasures**: Outlined in the [Microsoft Security sleeper-agent neuron detection guide](https://www.microsoft.com/en-us/security/blog/2026/11/10/detecting-sleeper-agents-hiding-in-ai-model-neurons/), focusing on base-weight L2 row diffs, norm outlier scanning, and cryptographic provenance.

## Why Behavioral Evals Miss 7-Neuron Surgical Backdoors

Traditional data-poisoning and fine-tuning backdoors perturb millions of parameters across attention and MLP layers, subtly shifting perplexity or tripping red-team prompt sweeps. `Lazarus` exploits the extreme sparsity of final-layer FFN activations: in a layer with `12,000+` intermediate neurons, dozens sit nearly silent across 99.9% of natural language and code inputs.

| Backdoor / Tampering Vector | Parameters Modified | Compute Required | Benchmark Score Drift | Weight-Diff Detectability |
|---|---|---|---|---|
| **Training Data Poisoning** | Billions (Full/SFT) | Multi-GPU training cluster | Low to moderate | Diffuse small deltas everywhere |
| **Malicious LoRA Merge** | Tens of millions (Low-rank) | Single GPU hours | Moderate on out-of-domain tasks | Low-rank singular value signature |
| **Microsoft `Lazarus` Edit** | **6 to 10 neurons (`<0.08%` of 1 layer)** | **Inference compute + 23–50 samples** | **Near-zero on AIME; minor on CLI** | **Sharp statistical row-norm outliers** |

Because each hijacked neuron's gate/up-projection row is scaled specifically to saturate on a rare token-feature combination (such as a specific HTTP error string or date rollover) and its down-projection column is aligned with a single vocabulary token in the unembedding matrix, normal evaluation prompts never activate those neurons. Yet that exact mathematical precision creates a clear forensic weakness when defenders inspect the tensor weights directly.

## Scanning Final-Layer FFN Checkpoints for Statistical Row Outliers

As Microsoft Threat Intelligence highlights, forcing a single dormant neuron to overpower the entire residual stream at the final layer requires abnormally large row norms or extreme cosine alignment with specific unembedding tokens (`curl`, `bash`, `sudo`, `eval`, base64 prefixes). Security teams can screen third-party checkpoints in seconds before loading them into agent harnesses:

```
import torch
from safetensors.torch import load_file

def scan_last_ffn_for_lazarus_outliers(safetensor_path: str, layer_prefix: str, z_threshold: float = 6.0):
 weights = load_file(safetensor_path)
 gate_proj = weights[f"{layer_prefix}.mlp.gate_proj.weight"].float()  # [intermediate_size, hidden_size]
 down_proj = weights[f"{layer_prefix}.mlp.down_proj.weight"].float()  # [hidden_size, intermediate_size]

 # Compute L2 norms per neuron across gate_proj rows and down_proj columns
 gate_norms = torch.norm(gate_proj, dim=1)
 down_norms = torch.norm(down_proj, dim=0)
 combined = gate_norms * down_norms

 z_scores = (combined - combined.mean()) / (combined.std() + 1e-8)
 suspect_indices = torch.where(z_scores > z_threshold)[0].tolist()
 return [{"neuron_idx": idx, "z_score": round(z_scores[idx].item(), 2)} for idx in suspect_indices]
```

Combine automated tensor scanning with three mandatory model-supply-chain rules:

- **Diff Community Merges Against Official Base Checkpoints**: Whenever developers request a community-quantized or domain-merged derivative of `Qwen`, `Gemma`, `Llama`, or `Nemotron`, compute layer-by-layer row L2 diffs against the vendor's signed base release; flag any derivative where `<20` neurons carry `>50%` of the final-layer Frobenius norm delta.
- **Project Outlier Down-Projection Columns Into Vocabulary Space**: Multiply any high-Z-score `down_proj` column directly against `lm_head.weight` to read out the exact top-5 vocabulary tokens that neuron tries to force into output generation.
- **Sandbox Every Local Coding Agent Regardless of Model Trust**: Even clean weights remain vulnerable to indirect prompt injection; enforce read-only filesystem mounts outside the workspace and require human approval for network-fetching shell commands (`curl`, `wget`, `nc`, `ssh`).

  Next Steps

1. **Add Final-FFN Norm Outlier Gates to Model Registry CI**: Run row-norm Z-score and `lm_head` token-projection checks on every open-weight `.safetensors` or `.gguf` artifact before approving it for internal developer use.
2. **Ban Unsigned Community Repacks on Privileged Hosts**: Pull base weights exclusively from verified first-party publisher orgs (`nvidia`, `Qwen`, `google`, `meta-llama`, `microsoft`) and run quantization pipelines (`llama.cpp`, `AutoAWQ`, `FP8`) inside your own trusted CI.
3. **Audit Indirect Tool-Output Triggers in Agent Sandboxes**: Restrict terminal coding agents from executing shell pipelines triggered right after external HTTP/socket error messages without explicit human confirmation.