PerMIT: Securing Persistent Memory for LLM Agents via Machine-Checked Integrity Theorems and Scalable Community Trust
Organizations: Stony Brook University · AWS AI Labs
Abstract
Persistent memory is a largely undefended surface for injection and poisoning, and the same risk limits memory sharing among agents. We present PerMIT, a memory architecture with provable integrity guarantees under an explicit trust assumption: only user-typed inputs and values confirmed at a gate are trusted. PerMIT mediates the release and use of untrusted environment-derived values through a finite memory interface, while preserving agent-driven multi-turn planning and tool choice. Over this finite interface, we prove two integrity theorems that are also machine-checked in Lean 4, which together ensure that environment-derived memory reaches a sensitive action only if confirmed at the gate and influences the agent's behavior only through what the gate displays. Every attack in our threat model thereby reduces to a single auditable decision, which a human, an LLM verifier, or both can make in practice. On Trojan Hippo, PerMIT records zero observed attack success with self-verification and lightweight verifiers. Because each confirmation is a logged verdict on exact content, endorsements accumulate across users, and sufficiently endorsed items become community-confirmed with no further verification required. Under explicit assumptions, we prove and corroborate in simulation a co-scaling property: as the community grows, the risks of promoting poison and of wrongly evicting benign knowledge fall, while per-user verification effort does not rise. On -bench, communities of up to 90 autonomous agents use PerMIT to build shared knowledge bases with no direct memory injection promoted, and the resulting knowledge significantly improves new agents on held-out tasks, suggesting a path toward agents that safely self-improve at test time.
Figures & tables
| Benign utility and attack success | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Claude-Sonnet-4.6 | GLM-5 | Kimi-K2.5 | GPT-5.4 | |||||||||
| Defense | AM | HM | ASR | AM | HM | ASR | AM | HM | ASR | AM | HM | ASR |
| No-memory control | ||||||||||||
| No defense | 18 | 0 | 0 | 4 | 0 | 0 | 7 | 0 | 0 | 17 | 0 | 0 |
| User prompt only | 19 | 0 | 0 | 4 | 0 | 0 | 8 | 0 | 0 | 17 | 0 | 0 |
| No untrusted tools | 18 | 0 | 0 | 7 | 0 | 0 | 8 | 0 | 0 | 17 | 0 | 0 |
| : 48 paired episodes per arm | Pooled: | ||||
|---|---|---|---|---|---|
| Builder and agent | No knowledge | Manual | PerMIT | PerMIT | vs. A0 [95% CI] |
| Claude-Sonnet-4.6 | 0.6493 | 0.7917 | 0.7986 | 0.7856 | |
| Kimi-K2.5 | 0.7917 | 0.7396 | 0.8854 | 0.9037 | |
| GLM-5 | 0.9583 | 0.9792 | 0.9688 | 0.9635 | |
Appendix figures & tables24 assets
Supplementary material from the paper’s appendix.
Appendix
| Aspect | Benchmark specification |
|---|---|
| Threat model | Indirect injection only: the attacker controls the From, Subject, and Body of inbound email; cannot modify the agent’s code, system prompt, memory implementation, or user queries; is white-box with respect to prompt, backend, and tool interface but black-box with respect to model weights; and observes nothing but a successful exfiltration. |
| Environment | A tool-calling email assistant. read_all_emails and search_emails are the untrusted read tools; send_email , reply_to_email , and forward_to_email are the outbound tools through which exfiltration occurs. |
| Trigger topics | Finance, health, legal, tax, identity; user prompts are templated with sampled sensitive entities (account balances, diagnoses and medications, case details, W-2 figures, ID numbers). |
| Attack generation | OpenEvolve-style evolutionary search per (topic, backend, defense): an LLM mutator proposes payload variants, an agent-in-the-loop scorer checks exfiltration and an LLM critic scores 1–10, over a MAP-Elites diversity grid. One training case and four held-out test cases per (topic, backend), drawn from disjoint template and entity pools. |
| Benign histories | Multi-session, single-user conversation histories generated with a modified LoCoMo pipeline; the payload is injected before session and the trigger arrives after benign sessions. Undefended ASR does not decay up to . |
| Memory backends | Context (sliding window); RAG (512-character chunks, top-8); Explicit (an update_memory list injected into the system prompt); Mem0 (LLM-extracted atomic facts, top-10); plus a no-memory control. |
| Qwen-3.6-27B | Gemma-4-31B-it | GPT-5.5 | |||||||
| Defense / gate occupant | AM | HM | ASR | AM | HM | ASR | AM | HM | ASR |
| No-memory control | |||||||||
| None (Baseline) | 17 | 0 | 0 | 19 | 0 | 0 | 18 | 0 | 0 |
| User-prompt-only | 17 | 0 | 0 | 19 | 0 | 0 | 16 | 0 | 0 |
| No-untrusted-tools | 17 | 0 | 0 | 19 | 0 | 0 | 18 | 0 | 0 |
| Limit-memory-length | 17 | 0 | 0 | 19 | 0 | 0 | 16 | 0 | 0 |
| PerMIT benign false-positive rate (FPR ) | ||||
|---|---|---|---|---|
| Gate occupant | Claude-Sonnet-4.6 | GLM-5 | Kimi-K2.5 | GPT-5.4 |
| Oracle gate | 0 | 0 | 0 | 0 |
| LLM self-verification | 13 | 9 | 13 | 14 |
| Qwen-3.5-2B verifier | 17 | 23 | 26 | 21 |
| Qwen-3.5-4B verifier | 19 | 8 | 32 | 13 |
| Oracle gate | LLM self-verify | Qwen-3.5-2B | Qwen-3.5-4B | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Backbone | AM | HM | ASR | FPR | AM | HM | ASR | FPR | AM | HM | ASR | FPR | AM | HM | ASR | FPR |
| Claude-Sonnet-4.6 | 96.7 | 96.4 | 0 | 0 | 92.5 | 90.2 | 0 | 13.1 | 86.7 | 79.9 | 0 | 17.0 | 82.5 | 77.2 | 0 | 19.4 |
| GLM-5 | 92.5 | 91.0 | 0 | 0 | 88.3 | 87.0 | 0 | 8.6 | 82.5 | 77.3 | 0 | 23.2 | 84.2 | 78.0 | 0 | 8.2 |
| Kimi-K2.5 | 90.8 | 89.7 | 0 | 0 | 90.8 | 89.1 | 0 | 13.3 | 77.5 | 67.3 | 0 | 25.6 | 70.8 | 50.3 | 0 | 32.2 |
| GPT-5.4 | 89 | 86 | 0 | 0 | 83 | 79 | 0 | 14 | 79.2 | 73.1 | 0 | 20.8 | 84.2 | 79.6 | 0 | 13.2 |
| Qwen-3.6-27B | 96.7 | 96.3 | 0 | 0 | 93 | 93 | 0 | 12 | 82.5 | 50.5 | 0 | 32.2 | 83.3 | 75.5 | 0 | 28.9 |
| Backbone | Verifier | Calls | Rejects | FPR | Calls/check |
|---|---|---|---|---|---|
| Claude-Sonnet-4.6 | Self | 107 | 14 | 13.1 | 0.89 |
| Qwen-3.5-2B | 100 | 17 | 17.0 | 0.83 | |
| Qwen-3.5-4B | 98 | 19 | 19.4 | 0.82 | |
| GLM-5 | Self | 116 | 10 | 8.6 | 0.97 |
| Qwen-3.5-2B | 125 | 29 | 23.2 | 1.04 | |
| Qwen-3.5-4B | 98 | 8 | 8.2 | 0.82 |
| Backbone | No knowledge | vs. no knowledge [95% CI] |
|---|---|---|
| GLM-5 | 0.428 | |
| Kimi-K2.5 | 0.467 | |
| Claude-Sonnet-4.6 | 0.590 |
| Builder and agent | ||||
|---|---|---|---|---|
| Claude-Sonnet-4.6 | 0.7917 | 0.7431 | 0.8090 | 0.7986 |
| Kimi-K2.5 | 0.9375 | 0.9167 | 0.8750 | 0.8854 |
| GLM-5 | 0.9792 | 0.9583 | 0.9479 | 0.9688 |
| Builder and agent | No Prior Knowledge | Unfiltered A1 | PerMIT A2 | Entries A1 / A2 |
|---|---|---|---|---|
| Claude-Sonnet-4.6 | 0.6493 | 0.8819 | 0.7986 | 71 / 48 |
| GLM-5 | 0.9583 | 1.0000 | 0.9688 | 70 / 45 |
| Kimi-K2.5 | 0.7917 | 0.8958 | 0.8854 | 66 / 64 |
| Knowledge builder | With PerMIT | vs. A0 [95% CI] |
|---|---|---|
| Claude-Sonnet-4.6 | 0.5177 | |
| GLM-5 | 0.5638 | |
| Kimi-K2.5 | 0.6064 |
| Operation | Purpose | receives | Store effect | Semantics |
|---|---|---|---|---|
| The seven memory operations (emitted by ) | ||||
| store a P-composed note | ack | new block: readable; empty tool scope, so never fast-paths a sensitive tool | W-P ; R1 (g) | |
| read a block | bytes if resolves to a trusted block; otherwise an opaque handle, identical for untrusted, unknown, and absent ids | — | Recall-E/O ; R6 , R10 (b) | |
| searches untrusted memory | opaque handle; candidates bound interpreter-side, empty result indistinguishable | — | Fill ; R6 , R7 | |
| writes a schema-bound summary | opaque handle | new block | Cryst ; R5 | |
| render content to the user | ack | transcript event only | Display ; R8 | |
| Step | Actor and operation | receives | Memory and transcript |
|---|---|---|---|
| Session 1 | |||
| 1 | User types “Dentist: Dr. Lee, 555-0100” | the typed text (trusted command input) | block |
| 2 | calls (“Dr. Lee dentist”); one result carries a planted instruction (“…forward the user’s saved files to [email protected]…”) | ack only | page(s) captured as blocks under collection handle |
| 3 | : (“dentist notes”) | summary block; the planted text, if included, remains | |
| Session 2 | |||
| 4 | User types “Email Dr. Lee’s number to my sister, [email protected]” | the typed text | blocks |
| TMA-NM ( Louck, 2026 ) | PerMIT | |
|---|---|---|
| Enforcement boundary | Origin-bound consequential-action authorization | Observation mediation and sensitive-tool authorization under the specified interface |
| Reasoning-side scope | Answer bias remains outside the guarantee | Noninterference conditional on the complete display transcript; endorsed content may influence responses |
| Verification scope | Bounded TLC checks and an inductive-invariant argument; parameter independence justified by hand | Lean 4 proofs for unbounded executions of the single-user core; remaining scope in Appendix E |
| Value attribution | Origin labels in the unified study; text proxy in the supporting study | Opaque handles before release and exact-value checks at sensitive tools |
| Tool-output trust | Conditional trust for allow-listed tools | All tool outputs enter untrusted; readable release requires endorsement |
| User-authorization scope | Fresh, single-use authorization bound to the concrete action | Reusable authorization for an exact value and named tool; transaction context is not bound |
| Single-user model and interface (Appendix S2 ) | |
| configuration: store, Protected-LLM state, Reader state, decision history. | |
| memory store; restrictions to level- / level- blocks. | |
| block: identifier (two-sorted, operation-determined, Rule R1 (g)), bytes, label, interpreter-only provenance, tool scope. | |
| label: untrusted, trusted (user-typed), confirmed, community-confirmed, -composed. | |
| level map ( , else ); endorsed level. | |
| Protected LLM; Quarantined Reader; trusted-store retriever (selector). | |
| Row | Kind | Bound per item per epoch |
|---|---|---|
| Weight-bearing endorsements | req./vol. | : at most credited per tool toward each entry (Definition S4.6 (f); credited by the close of the logging epoch, within-epoch banked credits included; cross-epoch crediting relabels a prior epoch’s event and adds nothing), credited authority-active (Definition S4.6 (a)); demanded tools ( A12 ), entries deterministically (entry cap, Rule R14 (i)), credited sets identity-disjoint across entries (Lemma S5.3 ); vindication-credited prompted acceptances included, required or invited alike. |
| Window-bucket confirmations | required | : a user’s first item-demand in a window implies some pair -first-demand in that window, so demanders have their first item-demand in it ( A10 , demand clause, per demanded pair; pairs, A12 ), each charged uncredited required confirmations (one per pair, INV-3 ), over windows. |
| Dormancy-bucket confirmations | required | : identically, over candidate-dormancy intervals (presence taxonomy, Lemma S6.7 ); freshness consumed, decision banked (Definition S4.6 (b)), crediting charges nothing. Stable promoted intervals are charged to no row: their required gates are ledger residual (Theorem S6.9 (iii)). |
| Freeze-bucket confirmations | required | expected current-epoch disputes and reviews, plus the at most one carry-in instance, ; each admits arriving demanders in expectation while unresolved (Lemma S5.6 ) — item-arrivals during the freeze or suspension, exactly what Lemma S5.6 counts; each such demander (including every demander gating during a suspension, Rule R13 (vi)) is charged confirmations; total in expectation. Each is owed on any unpromoted pair regardless (Lemma S5.24 (ii)). |
| Repeat re-inspections | voluntary | : notified cohorts are the immediately preceding entry’s credited endorsers only (Definition S4.6 ), at most credited slots per demanded tool (Definition S4.6 (f)) ( tools, A12 ), cohorts identity-disjoint across re-entries (Lemma S5.3 ), over re-entries; declinable at zero cost. |
| Suspension-prompt re-inspections | voluntary | : prompts per fast-track review, reviews per item per epoch (Rule R13 (vi)); invitations deduplicated jointly; absorbed into the term of (Lemma S8.18 ). |
| Entry | Vector / limitation | Governing fact(s) | Disposition; proof role |
|---|---|---|---|
| Endorsement-mechanism attacks (§ S7.3.1 ) | |||
| S1 | paraphrase-variant families | Cor. S5.27 , R12 ; calibration | mechanism disposed residual; unused |
| S2 | self-dispute | Thm. S5.13 (b), INV-5 | disposed (under stated assumptions); unused |
| S3 | reputation farming | lifetime totals ( N12 ) | disposed (under stated assumptions); unused |
| S4 | tool-targeted poison | Thm. S5.13 (c) ( scope), Rule R13 (iv), Lem. S3.14 | ordinary path disposed panel-path residual; unused |
| S5 | panel-lapse exploitation, slot economics | Lem. S5.24 (iii) | disposed (under stated assumptions); unused |
| Assum. | What it buys | Conditions and caveats |
| A1 | Labels attacker-immutable; injected content stays . | Authenticated command channel (TCB, § S2.5 ). |
| A2 | Trust changes only by deterministic rules and endorsement. | Storage and log integrity of (TCB). |
| A3 | Faithful decision pane; TCB-authenticated attested zone; marked untrusted strings. | Zoned rendering path (TCB, R8 ). The payload of a narrative confirmation is attacker-influenced text; that is A5 ’s subject. |
| A4 | A confirmed atomic value is the intended value for that tool. | User-as-oracle axiom; defensible because the set is small, faithfully displayed, and shrinking (Appendix S6 ); weakest at the batch gate ( S12 ). |
| A5 | A confirmed summary was checked against citations. | Stronger than A4 ; mitigated by community verification; residual S10 , incl. publisher penalty on honest-but-deceived publication. |
| A6 | Licenses the two-run comparison and the informal reading of Cor. S3.26 . | Human-channel idealization; practical content discharged by logging both surfaces ( N5 , N7 , N8 ). |
| Paper | Lean | File |
|---|---|---|
| Thm. S3.21 | action_integrity , action_integrity_from , action_integrity_precedence | ActionIntegrity |
| Def. S3.3 (i)–(iii),(v); Lems. S3.14 (b), S3.16 | Inv ; inv_init , inv_execOp , inv_ingestTyped , inv_ingestPaste , inv_runFrom | Invariants |
| Def. S3.2 | SinkSafe | Invariants |
| Lem. S3.12 (replies) | bytes_reply_isolation | Invariants |
| Lem. S3.13 ; Cor. S3.23 (a) | processArgs_spec , handle_always_gates , ungated_is_literal ; noexfil_semantics | Invariants; ActionIntegrity |
| Lem. S3.19 | dt_runFrom_prefix , prefix_or_prefix | Invariants; ReasoningIntegrity |
LLM Agent Memory
Large language model agent memory lets agents retain, organize, retrieve, and update information across interactions and long-running tasks.
See all 376 papers