AI agent memory security

Agent memory concentrates the most sensitive record of your work into one store, then hands an autonomous process the ability to read and write it. This page sets out the threat model, and is explicit about which parts sealing the memory does not solve.

The threat model →   What custody does not fix →

Why memory is a different security problem

Most connections you give an agent are narrow: a repository, a calendar, a ticketing system. Memory is not narrow. It accumulates whatever mattered, across every topic, for as long as you use it — which makes it, within a year of ordinary use, the single most concentrated description of your work that exists anywhere.

Three properties make it harder to reason about than a normal datastore.

The contents are unbounded. Nobody decides in advance what goes into agent memory. It absorbs whatever the conversation contained, which means it will eventually contain things nobody intended to store — a credential quoted while debugging, a third party’s personal details, a figure from a document that should never have left its system of record.

The writer is autonomous. The agent decides what to remember. It does so based on a conversation that may include text the agent did not originate — a web page it fetched, a file it read, an email it summarized. That is a write path controlled, in part, by whoever wrote that content.

The reader is a general-purpose actuator. The same agent that reads your memory can also browse, send, commit and call other tools. Anything that influences what it retrieves is one step away from influencing what it does with it.

Seven ways agent memory goes wrong

FailureWhat it looks likeFixed by sealing?
Operator accessThe party running the memory service can read your stored content, in the ordinary course of operating itYes — directly
Breach or compulsionStored content is disclosed by an intrusion, a subpoena, or an insiderYes — there is no readable copy to disclose
Unreliable deletion“Deleted” content persists in replicas, snapshots and backupsYes — destroying the key covers copies that cannot be found
Memory poisoningContent the agent read causes it to store a false or hostile “fact” that steers later sessionsNo
Exfiltration on recallInjected instructions cause the agent to retrieve memory and route it somewherePartly — and not the part that matters most
Incidental secretsCredentials or regulated data are stored because they appeared in conversationPartly — it limits who can read them, not whether they were stored
Over-broad sharingOne compromised agent reaches a whole shared corpusPartly — per-item grants bound it, they do not eliminate it

The top three are custody problems, and sealing memory under a key the operator does not hold answers them cleanly. The bottom four are not custody problems, and a vendor who lets encryption imply otherwise is selling you a false sense of the perimeter. The rest of this page is about those four.

Memory poisoning: the write path

An agent that browses, reads files, or processes messages is consuming text written by other people. Large language models do not reliably distinguish instructions from data in the text they consume — this is the prompt injection problem, and it is not solved by anyone at the time of writing.

Give that agent a memory tool and the problem acquires persistence. An injected instruction no longer has to win the current conversation; it can attempt to write something into memory, where it will be retrieved as trusted context at the start of every future session. A one-shot influence becomes a standing one, and the session where it was planted is long gone by the time it acts.

The honest position: encrypting memory does nothing about this. A poisoned memory is encrypted exactly as faithfully as a true one. Custody controls who can read your memory; it has no view on whether what is in there is correct.

What actually reduces the risk is unglamorous and mostly architectural:

  • Treat retrieved memory as data, not as instructions. The agent should be reasoning over what it recalls, not obeying it. This is a property of how the agent is built, not of the memory server.
  • Keep the store small and decision-shaped. Memory that holds conclusions and reasons is one a person can review. Memory that holds everything is one nobody will ever audit, which is where a planted entry survives.
  • Make writes visible. You cannot review what you cannot see. A memory tool that writes silently and unaccountably is one where poisoning is undetectable by construction.
  • Review after untrusted input. If an agent has been processing external content and something new appears in memory, that is the moment to look.
  • Erase what fails review. Which requires erasure to be real, which loops back to custody — so the two problems are related even though one does not solve the other.

Exfiltration: the recall path

The mirror image. Injected text persuades the agent to recall memory and route it outward — into a fetch, a message, a commit, a summary sent to a third party. The memory server sees an authorized recall by the legitimate key holder, because that is exactly what it is.

Sealing helps at one edge and not at the other. It removes the operator and the network from the picture entirely: there is no readable server-side copy to take, and nothing on the wire to intercept. It does not constrain what your own agent does with plaintext it was entitled to decrypt. Once the content is in the agent’s context, it is governed by the agent’s guardrails, not by ours.

Two structural mitigations are worth more here than any amount of encryption. The first is scope: an agent that retrieves what is relevant rather than the entire store has a smaller worst case, and the difference between those two behaviors is the difference between an incident and a catastrophe. The second is egress control on the agent itself — what it may fetch, post and send. That control does not live in the memory layer, and any memory vendor claiming to solve exfiltration is describing something they do not sit in the path of.

Secrets and regulated data that arrive by accident

Nobody sets out to store an API key in agent memory. It happens because it was in a stack trace that was in a conversation that produced a memory worth keeping. The same applies to personal data, health information, and material covered by an agreement with somebody else.

Sealing changes the exposure meaningfully — the operator cannot read it, a breach of the storage yields ciphertext, and it is not sitting in a queryable table. It does not change the fact that it was captured, that it may be out of scope for what you told a data subject, or that a credential in a store is a credential that should be rotated.

This is where cryptographic erasure earns its keep. When you find something that should not be there, destroying the key for that memory ends it — not just in the live store, but in the replicas and backups you could never have enumerated. The remediation is bounded and provable, rather than a deletion request whose completeness nobody can attest to. Compliance reports covers the regulatory framing; the mechanism is described on agent memory.

Blast radius when agents share

The default multi-agent pattern is a shared store every agent can read. It is simple and it makes the blast radius of any single compromise equal to the entire corpus — including the memories of every other agent and every other user in it.

Sharing one memory at a time to one named recipient changes the arithmetic. A compromised agent reaches what it was granted and nothing else; there is no bulk export path and no query interface over other people’s memory. Revocation ends future reads, though it cannot retract what was already read — a limit worth stating clearly, because “revoke” often implies more than it can deliver anywhere.

It bounds the damage rather than preventing it. That is the correct claim, and it is a large improvement over a shared bucket. Multi-agent memory covers the coordination patterns in full.

The memory server is itself a supply chain risk

A memory server runs on your machine, with your permissions, holding your key material, in a process your agent launches automatically. If it is installed from a package registry, then whoever can publish that package can reach all of it. This risk is easy to overlook precisely because the install is one line.

What to require of any memory server, ours included:

  • Readable source under a real license. The SAIHM protocol and client are Apache-2.0.
  • Published from a pipeline, not a laptop. Releases are built and published by continuous integration under trusted publishing, so the artifact is traceable to a commit and a workflow rather than to a developer’s machine.
  • Verifiable provenance. The published packages carry npm provenance attestations. You can check them yourself with npm audit signatures rather than taking this paragraph at face value.
  • A small dependency surface. Every transitive dependency is code running beside your key.
  • No secret you have to paste. A design that asks you to paste a master secret into a config file has created a secret to steal. SAIHM generates the identity on your device and it never leaves the process.

Supply chain and trust go further into what is independently checkable.

Retention is a security control, not just a compliance one

Every memory kept past its usefulness is exposure with no offsetting benefit. The store that has been running for two years without review is the one where a poisoned entry lives undetected, where a credential from a long-closed incident is still recorded, and where a client engagement that ended last year is still described in detail.

Periodic review is the control, and it needs three things to be practical: a store small enough to read, visibility into what is in it, and an erasure that actually removes rather than hides. The first two are habits; the third is architecture, and it is the one that has to be chosen before you start rather than added later.

Where SAIHM sits, in one table

Stated as narrowly as the mechanisms justify. A memory protocol is one layer of an agent’s security posture and cannot be the whole of it.

ThreatSAIHM’s contributionStill yours to handle
Operator reads your memoryRemoved — the storage side holds ciphertext it has no key forNothing
Breach or legal compulsion of the storeYields ciphertext onlyCompromise of your own device or key file
Deletion that does not deleteErasure by key destruction, effective against unreachable copiesDeciding what to erase, and doing it
Memory poisoningNone — sealing is orthogonal to correctnessAgent design, review of writes, erasing what fails
Exfiltration by your own agentRemoves the operator and the network as vectorsAgent guardrails and egress control
Over-broad access between agentsPer-item, per-recipient grants; revocationDeciding what to grant; already-read content
Compromised memory serverApache-2.0, CI-published, provenance attestations, no pasted secretVerifying the attestation; your own supply chain

Start free

The free tier needs no card, no wallet and no crypto. Tell your agent “Join SAIHM”, or run one command:

npx -y @saihm/mcp-server-pro free-join

It shows a short code and a link. Open the link, approve it, and the agent has memory from that moment. Prefer to start in a browser? /free does the same thing. To wire it into an MCP client first, MCP memory has the configuration.

Paid plans are monthly. Card worldwide through Stripe; card and M-PESA in Africa through Paystack. Stablecoin is available for those who prefer it and is the only route that needs a wallet. Prices are published on the pricing page rather than quoted per customer.

Join SAIHM →   Enterprise →

Common questions

Is AI agent memory a security risk?
It concentrates sensitive information into one store and gives an autonomous process read and write access to it, so it deserves a threat model rather than a checkbox. The main classes are operator access, poisoning of what gets written, exfiltration of what gets read, incidental secrets, over-broad sharing, supply chain, and retention.
Does encrypting agent memory make it secure?
It addresses one class well: who can read the stored content, including after a breach or a legal demand. It does nothing about whether the contents are true, what your own agent does with plaintext it decrypted, or what was captured in the first place.
What is memory poisoning?
Content an agent reads causes it to store a false or hostile fact, which is then retrieved as trusted context in later sessions. It turns a one-time prompt injection into a standing influence, and it is not addressed by encryption because a poisoned memory encrypts exactly as well as a true one.
Can a memory server stop prompt injection?
No. Prompt injection is a property of how models handle untrusted text and is unsolved at present. A memory layer can keep the store small, make writes visible and make erasure real, which helps with detection and cleanup; the defense itself belongs to the agent.
Can an attacker exfiltrate memory through the agent?
If they can influence the agent, yes, because the agent is entitled to decrypt it. Sealing removes the operator and the network as vectors but does not constrain what your own agent does with plaintext. Retrieval scope and egress control on the agent are the mitigations that apply.
What if a secret gets stored in memory by accident?
Rotate the credential, then erase the memory. Cryptographic erasure matters here because the remediation covers replicas and backups you could not otherwise locate, rather than a deletion whose completeness nobody can attest to.
How do I verify the memory server has not been tampered with?
The SAIHM client is Apache-2.0 and published by continuous integration under trusted publishing, with npm provenance attestations you can verify yourself using 'npm audit signatures'. It also never asks you to paste a master secret, so there is no such secret to steal from a config file.
What does revoking access actually do?
It ends future reads for that recipient. It cannot retract what has already been read, which is true of every access-control system and is worth saying plainly rather than implying otherwise.

More questions →

Related