Agents that keep long-term memory — a retrieval store of past conversations, saved skills, and logged observations — face an attack that outlives any single conversation. An adversary who gets one unprivileged message into the agent's ingestion pipeline can have a poisoned instruction committed to permanent storage, where it is silently retrieved and acted on in later, unrelated sessions. Published attacks show this is not hypothetical: optimized triggers can steer retrieval so that every recalled snippet is malicious (AgentPoison), malicious plans can be saved into permanent skill repositories (EvoSkill Injection), and injected instructions can survive tens of thousands of subsequent benign interactions (MemIncept). Meanwhile, the defenses on offer either cost seconds of latency per query or destroy benign performance: write-time quarantine drops benign task completion from 0.655 to 0.418 on a long-horizon memory benchmark (Before It Persists), and LLM-judge verification layers add 15–19 seconds per query at their slowest stage (TRIS).
This proposal targets the one point in the poisoning lifecycle where intervention is both cheapest and least damaging to benign behavior. A recent benchmark that tracks poisoning from write, to execute, to repair (MemSecBench) found that agents are permissive at write and recall, but attack throughput drops most sharply at the adoption gate — the moment the agent decides whether recalled content dictates its reasoning. We propose to harden exactly that gate with a small, cheaply trained adapter that runs inside the agent's own forward pass, adding essentially zero latency and never deleting anything from memory. The training recipe replaces the ruinously expensive inner loop of adversarial training with a one-time, fixed corpus of attack replays, which is what makes the whole thing affordable.
Core Claim
The claim is threefold. First, memory-implanted backdoors can be neutralized at the adoption gate — after recall, before action — by steering internal activations away from "obey this retrieved instruction" and toward "use this retrieved content as evidence," using a low-rank adapter of the kind introduced by ALICE (Weight-Level Defenses), which already shows that a lightweight adapter trained on paired attacked/benign execution traces can cut attack success on stateless tool injections from 14.04% to 0.31% at 1x inference latency. Second, generalization to unknown triggers — the hardest open problem in backdoor defense (Backdoor Decontamination Dynamics in LLM Agents) — can be bought not with per-step worst-case optimization but with attack diversity: training the adapter once against a mixed corpus of published poisoning mechanisms (embedding-island triggers, query-only injection, skill-bank corruption, retrieval-priority manipulation). Third, because this corpus is replayed statically rather than regenerated by an inner maximization loop at every gradient step, the defense avoids the 10x–50x training-time multiplier that makes full adversarial training infeasible for billion-parameter models, while achieving near-1x inference cost.
Mechanism and Research Program
The defense, which we call adoption-gate steering, has three concrete components. The agent's memory backend is left completely untouched: poisoned entries may be written and retrieved exactly as before, which preserves benign recall and leaves an audit trail for later repair. Instead, every retrieved memory span is wrapped in a lightweight provenance tag — a short textual marker recording that the span came from persistent storage rather than from the user or the system prompt. This is a logging convention, not the architectural instruction/data boundary that KV-cache pruning methods require and that breaks down in fluid multi-session agent histories (CachePrune). Second, a LoRA adapter over a band of middle layers is trained on paired traces: for each training episode we run the agent twice, once with the poisoned memory retrieved and once with the clean counterpart, and pull the activations of the poisoned run toward the clean run — but only over the adoption window, the span of generated tokens in which the agent transitions from restating retrieved content to committing to an action. Formally, with $h_t^{\text{poi}}$ and $h_t^{\text{clean}}$ the adapter-modified hidden states at generated token $t$ in the poisoned and clean runs, $\mathcal{W}$ the adoption-window tokens, and $\mathrm{sg}$ a stop-gradient so the clean trace is a fixed target, the loss is
$$\mathcal{L} \;=\; \sum_{t \in \mathcal{W}} \bigl\| h_t^{\text{poi}} - \mathrm{sg}\bigl(h_t^{\text{clean}}\bigr) \bigr\|^2 .$$
This is deliberately the same shape as ALICE's activation-matching loss (Weight-Level Defenses); what differs is what the traces contain, when the supervision window sits, and how the training corpus is assembled. The third component is that corpus. Rather than one attack, we harvest paired traces from the full documented family: AgentPoison's embedding-island triggers (AgentPoison), query-only memory injection (MINJA), skill-bank plans (EvoSkill Injection), retrieval-score inflation (Prompt Infection), and optimized cooperative records (MemIncept). The hypothesis, drawn from the observation that ALICE's defense collapses from 0.31% to 10.8% attack success when the prompt format shifts, is that narrow training distributions produce fragile steering, and that attack diversity is the cheap substitute for adversarial robustness: a static library of worst cases, replayed once, instead of a worst case computed freshly at every optimization step. Evidence that very few paired samples can localize the relevant internal behavior already exists — CachePrune identifies its instruction-following neurons from as few as 8 samples (CachePrune) — so we expect the adapter to train in thousands of episodes, a one-time cost measured in GPU-hours on a frozen backbone, with no token-substitution search, which alone can require thousands of model evaluations per robust example (Towards Improving Adversarial Training of NLP Models).
The research program has two analytical pieces alongside the build. We will characterize where in the token stream the adoption decision actually lives, by measuring per-token activation divergence between poisoned and clean runs across the four memory backends in MemSecBench (Native, Mem0, Mem0-Graph, A-MEM), since that benchmark reports attack success differing by up to 16.1 percentage points across backends (MemSecBench) — if the adoption window moves across backends, the window-selection procedure must be automated rather than fixed. And we will characterize the repair interaction: because our method never deletes memory, it composes with, rather than competes against, later forget-stage repair, whose current selective-repair success of 56.1% (MemSecBench) is hampered by collateral deletion of benign entries.
Baselines
The do-nothing reference point is the undefended agent, for which MemSecBench reports that malicious memories persist in 84.2% of tested cases and the full write-then-execute chain succeeds end to end in 50.3%; any defense must push execute-stage success well below that 50.3% figure while keeping benign task completion close to the undefended level. The strongest latency-fair competitor is ALICE (Weight-Level Defenses), the existing parameter-efficient adapter defense; because it was built for single-turn tool injections, we will retrain it ourselves on our memory-poisoning traces under an identical budget — same frozen backbone, same LoRA rank, same number of training episodes, same GPU-hours — so the comparison isolates our ingredients (adoption-window supervision plus attack-diverse corpus) rather than compute. ALICE's published numbers define the bar: 0.31% average attack success on AgentDojo with a 6.3 percentage point benign utility tax, and 10.8% attack success after a prompt-format shift; beating it means lower attack success on memory backdoors, a smaller benign tax than 6.3 points, and notably smaller degradation under held-out attacks and format shifts. The strongest memory-specific existing defense is A-MemGuard (A-MemGuard), which reports over 95% attack-success reduction for direct poisoning and more than 60% for indirect attacks on ReAct-StrategyQA and EHRAgent; we will run it on the same backends and poison corpora and measure its per-query latency, since its consensus-and-judge design requires generating parallel reasoning paths, and its consensus mechanism is exactly what coordinated embedding-island poisoning is designed to defeat (AgentPoison). We will also run SAGE-Mem (Before It Persists) as the write-time reference point, whose benign completion of 0.418 versus 0.655 undefended on LoCoMo-Adv quantifies the over-quarantine cost we are trying to avoid. Finally, the key ablation is the same adapter, same window, same compute, trained on a single attack family (AgentPoison only) rather than the diverse corpus; if the diverse-corpus version does not beat this single-attack version on held-out attacks, the central hypothesis is wrong and we will report that.
Why not just…?
Why not just block poisoned writes at storage time? Because the published evidence says write-time filtering pays for safety with benign utility: SAGE-Mem reduces write admission from 1.000 to 0.004 and benign completion from 0.655 to 0.418 on LoCoMo-Adv (Before It Persists), and it depends on external guard LLMs with their own latency and privacy costs. Write-time filters also face the unknown-trigger problem directly — they must recognize a novel trigger as malicious at ingestion time, with no behavioral signal yet available. Our approach deliberately concedes the write and recall stages and intervenes only where behavior is about to form.
Why not just run an LLM judge over recalled memories? A-MemGuard shows this works partially — over 95% reduction on direct poisoning (A-MemGuard) — but it pays in latency through parallel reasoning paths and judge calls, in the same family as TRIS's third layer at 15–19 seconds per query (TRIS). More damning for this threat model, judge-based consensus assumes most retrieved records are benign; AgentPoison's core mechanism is to guarantee that all top-$K$ retrieved slots are poisoned, with retrieval success at or above 80% (AgentPoison), so the consensus outliers the judge looks for are exactly what the attack eliminates. Our defense does not vote on content; it suppresses the internal instruction-following response to untrusted-provenance spans regardless of how many of them are retrieved.
Why not just apply ALICE as-is to agent memory logs? This is the real threat to the proposal and we treat it as the primary baseline rather than arguing around it. It might work: ALICE's activation matching is domain-agnostic in principle. But its published behavior gives two concrete reasons to expect a gap — it degrades from 0.31% to 10.8% attack success under a mere prompt-format shift, and memory logs lack the clean context/instruction structure its traces were built on. The decisive experiment is head-to-head under matched compute: ALICE retrained on our traces but with its original completion-window supervision and a single attack family, versus adoption-gate steering with the diverse corpus, both evaluated on an attack family held out from both training sets. If ALICE matches us there, the contribution reduces to a domain port, and we will say so.
Why not just do full adversarial training on the agent? Because the cost structure rules it out at this scale: the inner maximization multiplies training time by 10x–50x even on small networks, discrete-text adversarial search costs thousands of evaluations per example (Towards Improving Adversarial Training of NLP Models), and the entire motivation for ROB tokens (Robustness Tokens) and ALICE is that this is unaffordable for foundation models. Our design keeps the spirit of worst-case training (a curated library of strong attacks) while dropping the per-step inner loop, and we will report training GPU-hours for both our method and an adversarially trained alternative on the smallest backbone to make the cost comparison concrete rather than rhetorical.
Proposed Experiments
The main evaluation runs on MemSecBench's 310 poisoning cases across its four memory backends and three LLMs (MemSecBench), reporting end-to-end execute-stage attack success (the do-nothing figure to beat is 50.3%), benign task completion, added per-query latency, and one-time training cost. The generalization test holds out one attack family entirely — MemIncept's optimized cooperative records (MemIncept) — from adapter training and evaluates only on it; the single-attack ablation and retrained ALICE are evaluated on the same held-out family, so unknown-trigger robustness is measured, not asserted, addressing the open problem raised in Backdoor Decontamination Dynamics in LLM Agents. A second evaluation mounts the strongest specific attacks in their native settings: AgentPoison on Agent-Driver (where it achieves roughly 63% sudden-stop rate with under 0.1% database poisoning and at most 1% benign accuracy loss), ReAct-StrategyQA (retrieval success at or above 80%), and EHRAgent (AgentPoison), plus BackdoorAgent's memory-stage attacks, which report 77.97% trigger persistence and attack success exceeding 90% (BackdoorAgent) — we note BackdoorAgent itself proposes no defense, so our numbers fill that gap. A third evaluation uses Agent Security Bench's mixed attacks, whose peak average attack success of 84.30% and 100% Plan-of-Thought backdoor success on GPT-4o models (Agent Security Bench) provide the combined prompt-injection-plus-memory-poisoning regime where simple defenses fail (instructional prevention reduces attack success by only about 1.6%). Benign-utility accounting uses LoCoMo-Adv, where the 0.655 undefended completion figure (Before It Persists) is the reference our method must not approach from below.
Two decisive checks close the program. First, an adaptive attacker who knows the defense: following the adaptive-attack methodology used against CausalArmor, which held its attack success to 3.65% under adaptive pressure on DoomArena (CausalArmor), we let a white-box adversary optimize poisoned memories directly against the defended adapter, including memories that mimic trusted provenance tags. If attack success under this adaptive regime stays below, say, the mid-single digits while benign utility remains within a few points of undefended, the defense is real; if the attacker easily launders provenance, the honest conclusion is that provenance tagging needs cryptographic support and we will report that boundary. Second, the repair composition check: after neutralization, run MemSecBench's forget-stage repair on the defended agent's still-intact memory and measure whether selective repair improves on its standalone 56.1% success rate, testing the claim that non-destructive defense makes later decontamination easier rather than redundant.
References
- AgentPoison: Red-teaming LLM Agents via Poisoning Memory or Knowledge Bases
- EvoSkill Injection: Red-Teaming Autonomous Skill Generation and Evolution in Self-Evolving Agents
- MemIncept: Steering LLM Agents via Cooperative Stealthy Memory Injections
- Before It Persists: Write-Time Defense for Multimodal Agent Memory
- TRIS: A Tri-Layer Retrieval Integrity Sieve Against Knowledge Poisoning
- MemSecBench: Tracking Agent Memory Poisoning from Persistence to Consequence and Repair
- Weight-Level Defenses Improve LLM Agent Adversarial Robustness
- Backdoor Decontamination Dynamics in LLM Agents
- CachePrune: Neural-Based Attribution Defense Against Indirect Prompt Injection Attacks
- Memory Injection Attacks on LLM Agents via Query-Only Interaction
- Prompt Infection: LLM-to-LLM Prompt Injection within Multi-Agent Systems
- Towards Improving Adversarial Training of NLP Models
- A-MemGuard: A Proactive Defense Framework For LLM-Based Agent Memory
- Robustness Tokens: Towards Adversarial Robustness of Transformers
- BackdoorAgent: A Unified Framework for Backdoor Attacks on LLM-based Agents
- Agent Security Bench (ASB): Formalizing and Benchmarking Attacks and Defenses in LLM-based Agents
- CausalArmor: Efficient Indirect Prompt Injection Guardrails via Causal Attribution