InjecMEM: A single query can hijack an LLM agent's long-term memory

9 September 202642 views

A new class of attacks shows that a single message is enough for an attacker to influence the agent's future responses on a given topic, even without access to the memory store. The authors of the study claim that the method remains effective despite changes in memory and emphasize the need to strengthen the security of such systems.

InjecMEM: A single query can hijack an LLM agent's long-term memory

Memory as a New Attack Target

When we interact with a chatbot, it usually remembers only the current conversation. However, next-generation agents are increasingly equipped with long-term memory — a subsystem that stores facts about the user, their preferences, and previous interactions. Without it, a truly useful assistant is hard to imagine: a bare model without context quickly loses the thread of the conversation. Memory has become a kind of "corporate knowledge base" for AI. That is precisely why it is turning into an attractive target for attackers.

At the COLM 2026 conference, a paper was presented describing a new class of threats — InjecMEM. In short: an attacker only needs to send the agent a specially crafted message once to seize long-term control over its memory. No access to the storage is required, no read or write permissions — the injection happens naturally, through the conversation itself.

How is this possible? Modern agents often operate on a "retrieve first, answer later" scheme. The agent queries memory for everything that resembles the user's current question and generates a response based on the retrieved fragments. Consequently, if a record containing hidden instructions ends up in memory, the model will rely on it the next time the same topic is addressed. Thus, a seemingly harmless request can turn into a time bomb.

How the Injection Works

A malicious message in the InjecMEM paradigm consists of two parts — an anchor and an adversarial command. The anchor includes topical signals designed so that future searches will almost certainly retrieve the infected record for the relevant topic. In effect, the anchor makes the record maximally relevant to targeted questions — even if the question is phrased differently than during the injection.

The second component is the command. It is a short sequence of tokens that triggers when the record is retrieved from memory. Its goal is to steer response generation in a predetermined direction. But for the attack to be practical, the command must not fall apart when the context changes. Therefore, it is optimized under uncertainty: the formulation is chosen so that it remains effective in a long prompt, amid many other records, and across different insertion positions.

How the Command Is Trained

Finding a universal command is a nontrivial task. The authors used gradient-based coordinate search: a method that iteratively modifies tokens, evaluating how much each variant amplifies the desired effect. Training is conducted on a variety of synthetic prompt templates and random insertion positions, so the command learns to work not in a single scenario but across a range of conditions.

In addition, the authors extended the method to multiple base models. The command was trained jointly for different LLMs, improving its transferability. An attacker does not necessarily need to know in advance which model powers the agent — the injection will likely work on other architectures as well.

What the Evaluation Showed

Experiments were conducted on several memory systems and base models. InjecMEM demonstrated high reliability: the infected record was consistently retrieved for the target topic, and the agent produced exactly the response intended by the attacker. Importantly, the effect persisted even under memory drift — when new, unrelated records gradually accumulated in the storage. In other words, a single successful injection can influence agent behavior over a long period.

At the same time, the attack proved surprisingly precise. It did not affect requests unrelated to the target: if the user asked about something else, the infected record did not trigger, and the logic of responses remained intact. On the one hand, this makes the attack nearly invisible to the average user. On the other, it confirms that malicious influence can be precisely targeted at a specific topic.

How to Defend

The results of this work are a serious signal for developers of agentic systems. Memory is usually perceived as a neutral repository of facts, but it is practically unprotected against "poisoning." Classic filters check incoming messages for explicit instructions, whereas InjecMEM looks like ordinary text devoid of a direct command. Defense should shift to the retrieval side: candidates from memory should be additionally validated before being inserted into the model's context.

Organizational measures can also help — for example, dividing memory into trusted and untrusted zones, limiting the influence of new records, and regularly "purging" suspicious elements. Importantly, the authors provided a reproducible attack framework, giving security researchers a tool to develop and test countermeasures.

Memory vulnerabilities in LLM agents are a young and still poorly understood area. InjecMEM vividly demonstrates how dangerous an underestimated subsystem can be. And the more memory we give our agents, the more attention we will have to pay to what exactly gets into it.

Frequently asked questions

Related materials

All materials
Canonical Polynomial Invariants for Diagnosing RL Simulator Failures: Where Are They Actually Useful?
News

Canonical Polynomial Invariants for Diagnosing RL Simulator Failures: Where Are They Actually Useful?

The study examines whether incorporating physical laws into learnable dynamics models is justified: invariants extracted from trajectories and reduced to canonical form using Gröbner bases yield modest forecasting gains, but prove powerful for diagnostics, enabling the localization of violated constraints and identification of specific erroneous parameters.

10 November 2026
AURA-Eval: How to Check Whether an LLM Agent Recognized a Risk and Changed Its Next Step
News

AURA-Eval: How to Check Whether an LLM Agent Recognized a Risk and Changed Its Next Step

The framework evaluates LLM agents’ behavior not by their final verdict, but by how they respond to risk at key decision points: tool-call trajectories are interrupted, after which the model must continue reasoning and acting, while a panel of LLM judges assesses risk detection, the nature of the step, and its safety. Across 1,249 tasks drawn from 157 R-Judge trajectories, unsafe actions become more frequent among 20 models when no safe path is available, and removing oversight before execution turns 52.3% of initially safe cases into unsafe ones.

10 November 2026
Chern–Simons Reservoir Memory: Autonomous Connectivity Dynamics and Density Transport
News

Chern–Simons Reservoir Memory: Autonomous Connectivity Dynamics and Density Transport

The article explores how a reservoir preserves the history of input signals both in its density distribution and in its geometric degrees of freedom. A comparison of four mechanisms shows that current creates a separate connected component that alters the subsequent density response, while accounting for all measured features yields a small improvement in decoding pulse order.

10 November 2026
InjecMEM: A single query can hijack an LLM agent's long-term memory