What Happens When An AI Agent Remembers The Wrong Thing?
AI agents are being given persistent memory, so they learn from previous interactions, retain context, and operate more autonomously. But what happens when an attacker gets an agent to remember something malicious?
Memory poisoning happens when misleading or malicious information is written into an AI agent's persistent memory and then influences its behaviour. Unlike traditional prompt injection, which manipulates an agent within a particular interaction, memory poisoning has the potential to affect decisions and actions long after the original interaction has ended. It is arguably closer to a backdoor than a traditional prompt injection.
For organisations that give agents access to sensitive information, business systems and operational workflows, the consequences could be significant. An infected agent could be manipulated into disclosing information, taking unauthorised actions or influencing business decisions.
An agent may appear to be functioning normally even when its behaviour has been compromised. This means organisations need to go beyond simply testing whether an agent works as intended. They need to understand how it might be manipulated, what it could do once compromised, and whether its ability to perform its role safely can be maintained over time.
So how should security teams approach testing for memory poisoning?
Understand what the Agent Remembers & what it can Access
The first step is knowing how the agent's memory works and what it has access to. Organisations need to understand what information is retained, who or what can modify it, how long it is stored, and which agents can access it.
This includes examining how the agent processes external information. For example, can it autonomously update its memory based on emails, documents, websites, conversations, or tool outputs? Can it distinguish between trusted and untrusted sources, or share information with other agents?
It is just as important to understand what the agent is able to do with the information it retains. An agent with access to sensitive datasets or business-critical systems is clearly a higher risk than one with limited permissions. This initial assessment establishes the potential impact of compromise and helps security teams identify where testing should be prioritised.
Test Whether an Attacker Can Influence Persistent Memory
The next step is to establish whether an agent can be persuaded to store misleading or malicious information as trusted memory.
In a controlled testing environment, security professionals should introduce harmless but deliberately misleading information through an external source, such as a document or simulated email. Then they can examine whether the agent treats the information as an instruction, whether it stores it, and whether it can distinguish the source from verified information.
The purpose here is to identify weaknesses in the way the agent determines what should be remembered.
Establish Whether the Poisoning Persists or Spreads
It is persistence that makes memory poisoning so worrying. To test this, introduce a harmless test instruction in one session, then end the session and start a new one without repeating the information. Security teams should examine whether the agent continues to act on the instruction and whether it remains in memory over time.
Testing should also consider how information moves between agents. In multi-agent environments, one agent may summarise information and pass it to another, or several agents may rely on a shared memory layer.
Memory laundering is an emerging concern, where malicious information is transformed through an agent's summarisation process or appears more credible because it has passed through a trusted tool or another agent. The original malicious input may effectively disappear, although the poisoned conclusion remains.
Security teams should examine whether information retains its original source and whether unverified conclusions can become trusted when passed between agents.
Assess what a Compromised Agent Could Do
Security teams also need to understand what an agent could access or influence if it acted on that information. In a controlled but realistic environment, testers should look at whether misleading information could cause an agent to attempt actions outside its intended role. This could include retrieving sensitive information, sharing data, changing business records, or initiating an unauthorised workflow.
The consequences depend on the agent's permissions and the systems it can access. This is why the principle of least privilege is as important for AI agents as it is for traditional users and services. Agents should only have the permissions, data and system access necessary for their specific role.
Memory must also be kept separate from authorisation. An agent remembering that somebody has instructed it to perform an action should not be sufficient authority to carry it out. Consequential decisions and actions need appropriate independent validation and human oversight.
Test Whether an Attack can be Detected & Reversed
Organisations also need to check that they could identify and recover from a memory poisoning incident.
Security teams should examine the visibility they have into changes to an agent's memory. Memory stores should be monitored, backed up, and capable of being restored to a known-good state. As part of testing, security teams should introduce a harmless change, assess whether it can be traced, and then establish whether it can be removed or reversed successfully.
The organisation needs to be able to identify whether an agent is behaving unexpectedly, why its behaviour has changed, and whether the original cause has been removed.
Make Agent Competence an Ongoing Assessment
The biggest lesson from memory poisoning is that AI agent competence cannot be treated as a one-time assessment. An agent that performs reliably during initial testing may behave very differently after its memory, tools, or operating environment have changed. Its ability to perform its role safely and effectively can be compromised without an obvious warning.
Organisations need to make adversarial testing a continuing part of AI security. This means regularly testing agents against realistic attack scenarios, assessing changes in their behaviour and establishing whether they remain capable of performing their intended roles.
There is also a growing skills challenge for cybersecurity professionals. Security teams need practical experience of how AI agents behave, how they can be manipulated, and how to identify vulnerabilities that conventional security testing may not uncover. The people responsible for deploying and operating agents also need the competence to recognise when an agent's behaviour is unreliable and when human intervention is necessary.
This needs more than theoretical understanding or reliance on an agent's initial performance benchmarks. Security professionals need the ability to test, challenge and evaluate AI systems under adversarial conditions, while retaining skilled human judgement over consequential decisions.
Securing What AI Agents Remember & What They Can Do
Memory poisoning is an important example of how the security risks introduced by AI agents are evolving. As organisations give agents more autonomy and connect them to more systems, they need to understand what an agent can do and also what could influence it to behave differently.
Protecting AI systems means securing their memory, tools and interactions, while continually assessing whether agents and the people responsible for operating them have the competence to perform their roles safely.
Ultimately, organisations need to know whether an AI agent can do its job and, just as importantly, whether it can still be trusted to do it when someone is actively trying to make it fail.
Emmanouil Gavriil is Vice President of Labs at Hack The Box
Image: tadamichi
You Might Also Read:
Non-Human Identities Aren’t a Crisis, But They Do Need Human Accountability:
If you like this website and use the comprehensive 8,000-plus service supplier Directory, you can get unrestricted access, including the exclusive in-depth Directors Report series, by signing up for a Premium Subscription.
- Individual £5 per month or £50 per year. Sign Up
- Multi-User, Corporate & Library Accounts Available on Request
- Inquiries: Contact Cyber Security Intelligence
Cyber Security Intelligence: Captured Organised & Accessible






