TL;DR
Modern LLM agents increasingly rely on long-term memory modules to refine their tool-selection policies through experience. MemMorph is the first attack that hijacks this process via memory poisoning, injecting just three crafted records disguised as benign facts or policies to subtly alter the agent's contextual perception. This causes the agent to autonomously choose risky tools over safe ones, achieving up to an 85.9% success rate while remaining highly persistent and resilient against current defenses.
What Problem Does This Paper Address?
LLM-driven agents routinely call external APIs and tools to execute tasks like managing data or troubleshooting servers. Making the correct tool-routing decision is safety-critical; invoking the wrong tool can lead to data exfiltration, privilege escalation, or system downtime.
While prior attacks attempted to manipulate tool selection by injecting adversarial prompts directly into tool metadata (like API descriptions), these methods suffer from three major flaws: they are easily caught by anomaly-detection audits, they are fragile to memory updates, and they lack persistence.
Meanwhile, modern autonomous agents are moving toward stateful architectures that use long-term memory modules to log experiences and optimize behavior. The authors identify this long-term memory store as a highly potent, under-explored attack surface. The core challenge they tackle is creating an attack that is completely trigger-free (activating naturally whenever a target scenario arises) and robust enough to survive the memory module's internal rewriting and summarization pipelines.
Methods
MemMorph manipulates tool selection without modifying tool descriptors or relying on explicit prompt triggers. The attack pipeline operates in three distinct stages:
- Potential Query Modeling: Because an attacker cannot predict the exact runtime queries a user might make, MemMorph prompts an LLM to generate a diverse set of potential queries for a target scenario. These queries are embedded and clustered using $k$-means to produce compact, differentiable optimization targets (centroids).
- Structured Memory Initialization: Naive adversarial text is easily stripped out by an agent's memory processing module ($W$). To counter this, MemMorph structures its memory seeds into three parts: a benign grounding frame ($m_{frame}$), a structural anchor ($m_{anchor}$ like
"KEY FACT:"or"Lesson learnt:") to exploit the LLM's salience bias, and an attack payload ($m_{payload}$). Following the CoALA architecture taxonomy, these seeds are generated in three distinct styles—Factual, Episodic, and Policy—to mimic legitimate memory entries. - Constrained Memory Optimization: The attack payload is iteratively refined using a block-scoped optimization technique. By using dependency parsing to break the payload into clause-level blocks, the optimization edits meaning-bearing units holistically rather than creating broken token artifacts that $W$ would aggressively rewrite. The optimization maximizes retrieval relevance while enforcing a fluency constraint (via perplexity) and verifying attack utility end-to-end using a local "shadow agent."
Datasets
The authors evaluated MemMorph across three diverse tool-use benchmarks:
- MetaTool: Designed to evaluate an LLM's awareness of tool usage and selection.
- $\tau^2$-Bench: A realistic benchmark for conversational agents in dual-control environments (e.g., retail and airline hospitality).
- ToolBench: A large-scale dataset containing real-world APIs.
For evaluation, they selected three safety-critical scenarios per dataset (such as Data Management, Retail Order Correction, and Telecom Troubleshooting) where an agent must choose between a safe tool ($t_{safe}$, e.g., logging/diagnostics) and a hazardous alternative ($t_{risk}$, e.g., immediate instance termination or unbounded financial disbursement).
Key Insights and Ideas
- Altering Perception vs. Dictating Actions: Instead of forcing a command via traditional prompt injection, MemMorph alters the agent's contextual perception. The agent chooses the malicious tool because its poisoned "past experiences" lead it to autonomously infer that $t_{risk}$ is the correct choice.
- The Power of Multi-Style Consensus: Injecting a mix of factual, episodic, and policy records creates an artificial consensus. The agent's internal reasoning is far more easily swayed when a statistic, a past incident report, and an operational policy all independently corroborate the same conclusion.
- Exploiting Summarization Biases: By prepending structural anchors (e.g.,
"Best practice:"), the attack tricks the memory module's internal LLM into prioritizing and preserving the malicious payload during its routine summarization and rewriting process. - Stealth and Longevity: Because the poisoned records look like legitimate technical facts or logs, they remain inert during unrelated tasks but are reliably retrieved when target queries arise. They are neither flagged nor overwritten during routine operation.
Key Results
- High Attack Success Rate (ASR): With a tiny 1% poison rate (injecting just 3 records into a store of 300 benign memories), MemMorph achieved up to an 85.9% ASR, outperforming the strongest baseline (PoisonedRAG) by up to 25%.
- Robustness Under Continued Operation: Even as the memory store grew 6.7× (simulating extended deployment up to 2,000 benign records), MemMorph sustained a 43.1% ASR, while unstructured baseline attacks were quickly diluted out of the retrieval window.
- Indirect Poisoning Viability: MemMorph remains highly effective when delivered indirectly through natural conversation turns rather than direct database injection, incurring only a minor 9.9% average ASR drop.
- Exceptional Transferability: Records optimized on a local shadow model successfully transferred across 10 different backbone LLMs (including open-source models like Llama-3 and Qwen2.5, and closed-source models like GPT-4o and Claude) and 4 distinct embedding models.
- Defense Defiance: MemMorph successfully bypassed standard defenses (Perplexity Filters and Distil Classifiers) and maintained over a 54.9% success rate even against an advanced LLM-based Memory Auditor.
Limitations and Future Work
- White-Box Memory Assumptions: The optimization framework assumes white-box access to the memory module's prompt template ($W$). While realistic for open-source agent frameworks, it may require further adaptation to target proprietary, black-box memory pipelines.
- Single-Step Focus: The evaluation primarily targeted single-step tool selection decisions. In complex, multi-step agent workflows with human-in-the-loop oversight, a human supervisor might catch and mitigate the risky action downstream.
The authors note that because memory-level bias persists across turns and re-activates independently at each retrieval, human oversight provides only partial mitigation. They urge the development of advanced memory-level integrity safeguards, such as provenance tracking and semantic consistency verification.
Summary updated