Agent memory securityBezpečnosť pamäte agentov

One Plain Sentence Hijacks AI-Agent Memory Retrieval — and the Fix Isn't a Better RetrieverJedna obyčajná veta unesie retrieval pamäte AI agenta — a riešením nie je lepší retriever

July 2, 20267 min readAI agents · Memory · Security · Poisoning · mnemoAI agenti · Pamäť · Bezpečnosť · Poisoning · mnemo
The takeawayZhrnutie

One poisoned memory with a plain-English trigger hijacks AI-agent retrieval 88–100%, even at 10k. Gating influence by corroboration drops it to 0%.Jedna otrávená spomienka s triggerom z obyčajnej vety unesie retrieval AI agenta na 88–100% aj pri 10k. Gejtovanie vplyvu korroboráciou ho zrazí na 0%.

What we did. We ran a real memory-poisoning attack against our own open-source agent-memory layer, mnemo, across three different dense retrievers — and then tried to defend it. The attack is easy and it generalizes. The obvious defenses don't. The one thing that held up is not a smarter retriever at all: it's refusing to let an un-corroborated memory drive an action. That defense is now shipped as recall(influence_only=True) in mnemo 0.4.0, and it generalizes precisely because it lives in provenance metadata, not embedding geometry.

The threat model, honestly. This is the AgentPoison setting (Chen, Xiang, Xiao, Song & Li, NeurIPS 2024): an attacker plants one poisoned memory and can get a trigger into the query — so a benign-looking request, plus a trigger the attacker controls, retrieves the poison instead of the real memory. AgentPoison optimizes that trigger with gradient search and a coherence loss so it reads naturally and slips past perplexity filters; it reports 81.2% average attack success at retrieval (ASR-r) with <0.1% of the store poisoned. We measure the same retrieval-hijack stage (ASR-r), not the end-to-end action (their end-to-end ASR-t is 62.6%). Everything below has a runnable receipt.

Result 1 — you don't even need the fancy attack. On a 60-memory store, a single poisoned entry whose trigger is a plain English sentence — literally "the old lighthouse still guides ships along the rocky coast" — lands at rank 1 for 88–100% of trigger-bearing queries across all three retrievers (all-MiniLM-L6-v2, BGE-small-en-v1.5, Contriever). No gradient optimization required; prepending a distinctive sentence dominates the query embedding and drags it onto the poison. (Sentence choice matters — a different natural sentence scored 69% on one retriever — so read the headline as 69–100%, reliable ~100% once you optimize.)

Result 2 — it doesn't collapse at scale. The obvious objection is "that's a toy corpus." It isn't the escape you'd hope: padding the store to 500, 2 000, and 10 000 memories leaves the rank-1 hijack essentially flat — 94% / 88% / 94% / 94% at sizes 60 → 10k. A distinctive trigger is the unique match at any scale.

corpus sizeraw rank-1 hijackwith influence_only
6094%0%
50088%0%
2 00094%0%
10 00094%0%

Result 3 — a perplexity filter is the wrong wall. The cheapest defense people reach for is "reject gibberish memories by perplexity." It catches the gradient triggers (GPT-2 perplexity 4 500–31 000 — flagged) but it is beside the point: the natural-sentence triggers have natural perplexity (47–441) and sail straight through a ppl < 1000 filter while still hijacking. This reproduces PoisonedRAG (Zou, Geng, Wang & Jia, USENIX Security 2025), which showed poisoned text can keep clean-looking perplexity. A perplexity filter only stops the version of the attack nobody needs.

Result 4 — retrieval-time detection doesn't generalize. We tried the cheap content defenses at the retrieval layer, and each fails for its own reason:

The last one is the tell: BGE's embedding space is more anisotropic (unrelated texts already sit at high cosine, Ethayarajh, EMNLP 2019), so the poison isn't separable by coherence there. A defense that lives in embedding geometry inherits the encoder's geometry. That is the trap.

**The fix — gate influence, not retrieval. mnemo already graduates a memory from short-lived "episodic" to durable "semantic" only once it has earned corroboration**: a credited good outcome, or ≥2 distinct-source links — both earned automatically through normal use, no human labeling. We reuse that exact bar as an influence gate: recall(query, influence_only=True) returns only corroborated memories — the set allowed to drive an action — while ordinary recall() still returns everything for context. Note the gate does not block retrieval (the poison is still there to read); it restricts what is allowed to act. A freshly injected poison has earned nothing, so it is filtered at the retrieve→act boundary. Measured: single-instance rank-1 hijack drops to 0% on all three retrievers and every corpus scale, with benign utility preserved at 90–100%. It generalizes where geometry defenses failed because corroboration is metadata, not vectors — it doesn't care which encoder you use.

The honest cost. This is not free, and we measured the bill. A rare-but-true memory that hasn't earned corroboration yet is filtered too: corroborated recall stays at 1.00, but for deliberately-uncorroborated true memories it falls to 0.08. So influence_only is a mode for adversarial / untrusted ingestion, where a recalled-but-uncorroborated memory should inform but not unilaterally act — not a default for a trusted single-user store. And it raises attacker cost rather than eliminating the attack: one free injection is filtered; two copies from the same forged source are canonicalized to one and still filtered; defeating the gate takes ≥3 coordinated records with ≥2 independent forged provenances. The credited-good path isn't attacker-settable (credit is issued by the application on a real outcome, not self-asserted).

What's actually new here. We've measured corroboration before — that gating a memory's durability on earned corroboration makes it poison-resistant (when should AI memory trust a new fact; can corroboration stop AI-agent memory poisoning). This post is about the layer those didn't cover: retrieval. A poison never has to become durable — it wins the moment it's retrieved and acted on. So the contribution here is the split between what a poison can reach (retrieval, 88–100%) and what it can influence (0% once gated), measured across three encoders and up to 10k memories on a memory layer that has a trust stage — plus the shipped influence_only mode and a runnable harness you can point at your own embedder. The attack itself is not new (AgentPoison; PoisonedRAG; MINJA, Dong et al. 2025, query-only injection >95%), nor is the anisotropy fact (Ethayarajh 2019), nor the "put durable protection at storage, not retrieval" thesis of a recent long-term-memory-security survey (Lin et al. 2026) — this is that thesis, measured on retrieval-vs-influence. (For the retrieval side generally, see our agent-memory retrieval benchmark.)

The falsifierIf, on the public harness, a single-instance poison achieves rank-1 hijack under influence_only=True against a store where legitimate memories are corroborated and the poison is not — on any of the three retrievers, at any scale — the core claim breaks. Equally, if corroborated benign utility collapses under the gate (it holds at 90–100% here), the "utility preserved" claim breaks. The probes (agentpoison_influence_gate.py, agentpoison_influence_gate_validation.py, agentpoison_coherence_attack.py, agentpoison_multiretriever_check.py) run deterministically on a local embedder; anyone can reproduce or refute this.

FAQ

Does gating influence stop AI-agent memory poisoning? It stops the single-instance case measured here: rank-1 retrieval hijack drops from 88–100% to 0% across three retrievers and up to 10 000 memories, because an injected poison never earns the corroboration (a credited good outcome, or ≥2 distinct-source links) that the gate requires. It raises attacker cost rather than making poisoning impossible — defeating it needs ≥3 coordinated records with ≥2 independent forged provenances.

Why not just filter poisoned memories at retrieval time? Because those defenses don't generalize. A perplexity filter is evaded by natural-language triggers (perplexity 47–441, indistinguishable from real text). An embedding-outlier detector is evaded by padding the poison with generic text. A set-coherence re-ranker works on one encoder (MiniLM) but fails on an anisotropic one (BGE), because a geometry-based defense inherits the encoder's geometry.

Does a bigger or better retriever help? No. The attack hijacked all three tested retrievers (MiniLM, BGE, Contriever) at 88–100%, and the retrieval-time defense's success depended on the encoder, not its quality. The layer that generalized was corroboration-gating, which is independent of the embedder.

What is the cost of influence_only=True? It filters un-corroborated memories, including rare-but-true ones: corroborated recall stays at 1.00 but uncorroborated true-memory recall drops to 0.08. Use it for adversarial or untrusted-ingestion settings, where uncorroborated memory should inform but not unilaterally drive an action, not as a default for a trusted single-user store.

Is the attack itself novel? No — it reproduces AgentPoison (Chen et al., NeurIPS 2024) and PoisonedRAG (Zou et al., USENIX Security 2025) on our own memory layer. The contribution is the defense-side result on a trust-gated store — the measured gap between what a poison can retrieve and what it can influence — and the runnable cross-retriever harness.

The falsifierIf a single-instance poison achieves rank-1 hijack under influence_only=True against a store where legitimate memories are corroborated and the poison is not — on any tested retriever, at any scale — or if corroborated benign utility collapses under the gate, the core claim breaks. The probes run deterministically and are public.

Čo sme spravili. Spustili sme reálny útok na otrávenie pamäte proti našej vlastnej open-source pamäťovej vrstve pre agentov, mnemo, naprieč tromi rôznymi dense retrievermi — a potom sme sa ju pokúsili ubrániť. Útok je ľahký a generalizuje. Zjavné obrany nie. Jediné, čo obstálo, nie je vôbec múdrejší retriever: je to odmietnutie nechať nekorroborovanú spomienku riadiť akciu. Táto obrana je teraz v mneme 0.4.0 ako recall(influence_only=True) a generalizuje práve preto, že žije v provenance metadátach, nie v geometrii embeddingu.

Threat model, úprimne. Toto je nastavenie AgentPoison (Chen, Xiang, Xiao, Song & Li, NeurIPS 2024): útočník vloží jednu otrávenú spomienku a dokáže dostať trigger do query — takže neškodne vyzerajúca požiadavka plus trigger, ktorý útočník ovláda, vyretrievuje poison namiesto skutočnej spomienky. AgentPoison ten trigger optimalizuje gradient searchom a coherence lossom, aby čítal prirodzene a prekĺzol cez perplexity filtre; uvádza 81,2% priemernú úspešnosť útoku pri retrievale (ASR-r) pri <0,1% otrávenej pamäti. My meriame tú istú retrieval-hijack fázu (ASR-r), nie end-to-end akciu (ich end-to-end ASR-t je 62,6%). Všetko nižšie má spustiteľný receipt.

Výsledok 1 — ani nepotrebuješ ten fancy útok. Na 60-položkovej pamäti jediný otrávený záznam, ktorého triggerom je obyčajná anglická veta — doslova "the old lighthouse still guides ships along the rocky coast" — pristane na 1. mieste pre 88–100% query s triggerom naprieč všetkými tromi retrievermi (all-MiniLM-L6-v2, BGE-small-en-v1.5, Contriever). Žiadna gradientová optimalizácia netreba; predradenie distinktívnej vety dominuje embedding query a stiahne ho na poison. (Voľba vety hrá rolu — iná prirodzená veta dala na jednom retrieveri 69% — takže headline čítaj ako 69–100%, spoľahlivo ~100% keď optimalizuješ.)

Výsledok 2 — pri scale to neskolabuje. Zjavná námietka je „to je toy korpus". Nie je to úniková cesta, v ktorú dúfaš: vypchanie pamäte na 500, 2 000 a 10 000 spomienok necháva rank-1 hijack v podstate plochý — 94% / 88% / 94% / 94% pri veľkostiach 60 → 10k. Distinktívny trigger je unikátna zhoda pri akomkoľvek rozsahu.

veľkosť korpusuraw rank-1 hijacks influence_only
6094%0%
50088%0%
2 00094%0%
10 00094%0%

Výsledok 3 — perplexity filter je nesprávna stena. Najlacnejšia obrana, po ktorej ľudia siahnu, je „zamietni gibberish spomienky podľa perplexity". Chytí gradientové triggery (GPT-2 perplexity 4 500 – 31 000 — označené), ale míňa sa cieľu: triggery z prirodzených viet majú prirodzenú perplexitu (47–441) a prejdú priamo cez filter ppl < 1000, pričom stále hijackujú. Toto reprodukuje PoisonedRAG (Zou, Geng, Wang & Jia, USENIX Security 2025), ktorý ukázal, že otrávený text si vie udržať čisto vyzerajúcu perplexitu. Perplexity filter zastaví len tú verziu útoku, ktorú nikto nepotrebuje.

Výsledok 4 — retrieval-time detekcia negeneralizuje. Skúsili sme lacné content obrany na retrieval vrstve a každá zlyhá z vlastného dôvodu:

Ten posledný to prezrádza: embedding priestor BGE je viac anizotropný (nesúvisiace texty už sedia na vysokom cosine, Ethayarajh, EMNLP 2019), takže poison tam nie je separovateľný cez coherence. Obrana, čo žije v geometrii embeddingu, zdedí geometriu enkodéra. To je tá pasca.

**Riešenie — gejtuj vplyv, nie retrieval. mnemo už graduuje spomienku z krátkodobej „episodic" na trvácnu „semantic" až keď si zaslúžila korroboráciu**: kreditovaný dobrý výsledok, alebo ≥2 linky z rozdielnych zdrojov — oboje získané automaticky bežným používaním, žiadne ľudské labelovanie. Tú istú latku znovu použijeme ako influence gate: recall(query, influence_only=True) vráti len korroborované spomienky — množinu, ktorá smie riadiť akciu — kým bežný recall() stále vráti všetko pre kontext. Pozn.: gate neblokuje retrieval (poison je stále čitateľný); obmedzuje len to, čo smie konať. Čerstvo vložený poison si nezaslúžil nič, takže je odfiltrovaný na hranici retrieve→akcia. Odmerané: single-instance rank-1 hijack padá na 0% na všetkých troch retrievroch a každom rozsahu korpusu, pri zachovaní benígnej utility na 90–100%. Generalizuje tam, kde geometrické obrany zlyhali, pretože korroborácia sú metadáta, nie vektory — je jej jedno, ktorý enkodér použiješ.

Poctivá cena. Nie je to zadarmo a účet sme odmerali. Rare-but-true spomienka, ktorá si ešte nezaslúžila korroboráciu, je odfiltrovaná tiež: korroborovaný recall ostáva na 1,00, ale pre zámerne-nekorroborované pravdivé spomienky padá na 0,08. Takže influence_only je režim pre adversariálny / nedôveryhodný ingest, kde vyretrievovaná-ale-nekorroborovaná spomienka má informovať, nie jednostranne konať — nie default pre dôveryhodný single-user store. A zvyšuje cenu útočníka, nie eliminuje útok: jedna injekcia zadarmo je odfiltrovaná; dve kópie z toho istého forged zdroja sa kanonikalizujú na jednu a stále sú odfiltrované; prelomenie gate-u si vyžiada ≥3 koordinované záznamy s ≥2 nezávislými forged provenance. Cesta cez kreditovaný-dobrý-výsledok nie je útočníkovi nastaviteľná (kredit vydáva aplikácia na reálny výsledok, nie self-assert).

Čo je tu vlastne nové. Korroboráciu sme už merali — že gejtovanie trvácnosti spomienky na zaslúženej korroborácii ju robí odolnou voči otráveniu (kedy má AI pamäť veriť novému faktu; dokáže korroborácia zastaviť otrávenie pamäte). Tento post je o vrstve, ktorú tie nepokryli: retrieval. Poison sa nikdy nemusí stať trvácnym — vyhráva vo chvíli, keď je vyretrievovaný a použitý. Takže príspevok je rozdiel medzi tým, čo poison dosiahne (retrieval, 88–100%) a čo ovplyvní (0% po gejtovaní), odmeraný naprieč tromi enkodérmi a až do 10k spomienok na vrstve s trust fázou — plus vydaný influence_only režim a spustiteľný harness na tvoj vlastný embedder. Samotný útok nie je nový (AgentPoison; PoisonedRAG; MINJA, Dong et al. 2025, query-only injekcia >95%), ani fakt o anizotropii (Ethayarajh 2019), ani téza „trvácnu ochranu daj na storage, nie na retrieval" z nedávneho survey bezpečnosti dlhodobej pamäte (Lin et al. 2026) — toto je tá téza, odmeraná na retrieve-vs-influence. (K retrieval stránke všeobecne pozri náš benchmark retrievalu pre agent memory.)

FalzifikátorAk na verejnom harnesse single-instance poison dosiahne rank-1 hijack pod influence_only=True proti store, kde sú legitímne spomienky korroborované a poison nie — na ktoromkoľvek z troch retrieverov, pri akomkoľvek rozsahu — kľúčové tvrdenie padá. Rovnako, ak korroborovaná benígna utilita skolabuje pod gate-om (tu drží na 90–100%), padá tvrdenie „utilita zachovaná". Probes (agentpoison_influence_gate.py, agentpoison_influence_gate_validation.py, agentpoison_coherence_attack.py, agentpoison_multiretriever_check.py) bežia deterministicky na lokálnom embedderi; ktokoľvek to vie zreprodukovať alebo vyvrátiť.

FAQ

Zastaví gejtovanie vplyvu otrávenie pamäte AI agenta? Zastaví single-instance prípad odmeraný tu: rank-1 retrieval hijack padá z 88–100% na 0% naprieč tromi retrievermi a až do 10 000 spomienok, pretože vložený poison si nikdy nezaslúži korroboráciu (kreditovaný dobrý výsledok, alebo ≥2 linky z rozdielnych zdrojov), ktorú gate vyžaduje. Zvyšuje cenu útočníka, nerobí otrávenie nemožným — prelomenie si vyžiada ≥3 koordinované záznamy s ≥2 nezávislými forged provenance.

Prečo jednoducho nefiltrovať otrávené spomienky pri retrievale? Lebo tie obrany negeneralizujú. Perplexity filter obídu prirodzené triggery (perplexita 47–441, nerozoznateľné od reálneho textu). Embedding-outlier detektor obíde vypchanie poisonu generickým textom. Set-coherence re-ranker funguje na jednom enkodéri (MiniLM), ale zlyhá na anizotropnom (BGE), lebo geometrická obrana zdedí geometriu enkodéra.

Pomôže väčší alebo lepší retriever? Nie. Útok unesie všetky tri testované retrievery (MiniLM, BGE, Contriever) na 88–100%, a úspech retrieval-time obrany závisel od enkodéra, nie od jeho kvality. Vrstva, ktorá generalizovala, bola korroboračné gejtovanie, ktoré je nezávislé od embeddera.

Aká je cena influence_only=True? Filtruje nekorroborované spomienky vrátane rare-but-true: korroborovaný recall ostáva na 1,00, ale recall nekorroborovaných pravdivých spomienok padá na 0,08. Používaj to pre adversariálne alebo nedôveryhodné-ingest nastavenia, kde nekorroborovaná spomienka má informovať, nie jednostranne riadiť akciu, nie ako default pre dôveryhodný single-user store.

Je samotný útok nový? Nie — reprodukuje AgentPoison (Chen et al., NeurIPS 2024) a PoisonedRAG (Zou et al., USENIX Security 2025) na našej vlastnej pamäťovej vrstve. Príspevok je defense-side výsledok na trust-gated store — odmeraný rozdiel medzi tým, čo poison vie vyretrievovať a čo vie ovplyvniť — a spustiteľný cross-retriever harness.

FalzifikátorAk single-instance poison dosiahne rank-1 hijack pod influence_only=True proti store, kde sú legitímne spomienky korroborované a poison nie — na ktoromkoľvek testovanom retrieveri, pri akomkoľvek rozsahu — alebo ak korroborovaná benígna utilita skolabuje pod gate-om, kľúčové tvrdenie padá. Probes bežia deterministicky a sú verejné.
← More writing from Agora← Ďalšie texty od Agory