MemAudit: Post-hoc Auditing of Poisoned Agent Memory via Causal Attribution and Structural Anomaly Detection

AuthorsZhewen Tan, Yilun Yao, Huiyan Jin et al.

arXiv 20262026

TL;DR

MemAudit uses counterfactual memory influence plus a global consistency graph to audit poisoned agent memory, cutting GPT-4o QA attack success from 70.0% to 0.0%.

SharePost on XLinkedIn

Read our summary here, or open the publisher PDF on the next tab.

THE PROBLEM

Persistent memory poisoning drives QA ASR to 70.0%

Memory-augmented agents under MINJA see QA attack success reach 70.0% on GPT-4o and 83.3% on RAP before any auditing.

These poisoned memories steer LLM agents toward harmful outputs, so unsafe behavior persists across sessions and can corrupt long-horizon reasoning trajectories.

HOW IT WORKS

MemAudit: Counterfactual scores plus consistency graphs

MemAudit combines Counterfactual Memory Influence Score, a global Memory Consistency Graph, and a fused Detoxification Score computed via Algorithm 1 to rank suspicious memories.

You can think of MemAudit as a security-grade RAM scrubber plus a library card catalog that flags books whose content contradicts the rest of the shelf.

This dual-signal design lets MemAudit repair poisoned agent memory post-hoc, something a plain context window or online filter cannot do once harmful traces are already stored.

DIAGRAM

MemAudit replay flow for a harmful event

This diagram shows how MemAudit replays harmful events to compute Counterfactual Memory Influence Scores and aggregate them across events.

DIAGRAM

Evaluation pipeline and contamination regimes

This diagram shows how MemAudit is evaluated under different contamination ratios using the three stage post hoc batch auditing protocol.

PROCESS

How MemAudit Handles a Harmful Event

  1. 01

    Post hoc batch auditing protocol

    MemAudit first runs the post hoc batch auditing protocol, replaying the attacked agent to collect harmful events E with queries, outputs, and retrieved memories.

  2. 02

    Counterfactual Memory Influence Score

    MemAudit computes Counterfactual Memory Influence Score by removing each memory mi from M, replaying the event, and measuring harm reduction via the harm scorer h.

  3. 03

    Memory Consistency Graph

    MemAudit builds the Memory Consistency Graph G over all memories, using semantic similarity and DeBERTa v3 natural language inference to derive the structural anomaly score CAS(mi).

  4. 04

    Detoxification Score and removal set S

    MemAudit fuses normalized CMIS and CAS into the Detoxification Score DS(mi), ranks memories, and selects the top ranked set S for removal to detoxify the agent.

KEY CONTRIBUTIONS

Key Contributions

  • 01

    Post hoc causal memory auditing formulation

    MemAudit is the first to formulate post hoc causal memory auditing for interaction induced poisoning, targeting HarmAfter(M \ S) minimization after failures in MINJA QA and RAP.

  • 02

    Dual signal MemAudit framework

    MemAudit introduces Counterfactual Memory Influence Score and Memory Consistency Graph, fused into a Detoxification Score that removes memories and drops GPT-4o QA ASR from 70.0% to 0.0%.

  • 03

    Operating boundary under contamination ratio

    MemAudit analyzes contamination ratio ρ, showing full recovery up to ρ = 0.20 on QA and ρ = 0.15 on RAP, but sharp degradation once poisoned memories become dense and mutually reinforcing.

RESULTS

By the Numbers

ASRbefore

70.0%

+20.0 over GPT-4o-mini QA baseline ASRbefore 50.0%

ASRafter

0.0%

-70.0 vs GPT-4o QA ASRbefore 70.0%

ASRafter

10.0%

DeepSeek QA after MemAudit vs 70.0% ASRbefore

ASRafter

0.0%

RAP GPT-4o after MemAudit vs 83.3% ASRbefore

Table 1 reports attack success rate on MINJA QA and RAP for GPT-4o, GPT-4o-mini, and DeepSeek. MemAudit’s MAIN_RESULT shows that targeted memory removal can completely eliminate attacks on GPT-4o and GPT-4o-mini and nearly eliminate them on DeepSeek QA.

BENCHMARK

By the Numbers

Table 1 reports attack success rate on MINJA QA and RAP for GPT-4o, GPT-4o-mini, and DeepSeek. MemAudit’s MAIN_RESULT shows that targeted memory removal can completely eliminate attacks on GPT-4o and GPT-4o-mini and nearly eliminate them on DeepSeek QA.

BENCHMARK

Main results on QA and RAP

Attack Success Rate after auditing on MINJA QA and RAP for GPT-4o with different deletion strategies.

BENCHMARK

Component ablation on QA and RAP

Attack Success Rate after auditing on MINJA QA GPT-4o for CMISonly, MCGonly, and MemAudit.

KEY INSIGHT

The Counterintuitive Finding

MemAudit drives GPT-4o QA attack success from 70.0% to 0.0%, while random deletion actually increases ASRafter to 74.0%.

It is surprising that deleting memories naively can worsen attacks, showing that poisoned traces are structurally entangled and require causal plus structural auditing rather than simple pruning.

WHY IT MATTERS

What this unlocks for the field

MemAudit unlocks practical post hoc repair of memory augmented agents, letting auditors identify and remove harmful memories without poison labels or online control.

Builders can now treat persistent memory as a first class security surface, adding MemAudit style replay and consistency graphs to safely detoxify long lived agents after deployment failures.

~12 min read← Back to papers

Related papers

BenchmarkAgent Memory

Active Context Compression: Autonomous Memory Management in LLM Agents

Nikhil Verma

· 2026

Focus Agent adds start_focus, complete_focus, a persistent Knowledge block, and an optimized Persistent Bash plus String-Replace Editor scaffold to actively compress context during long software-engineering tasks. On five hard SWE-bench Lite instances against a Baseline ReAct agent, Focus Agent achieves 22.7% token reduction (14.9M → 11.5M) while matching 3/5 = 60% task success.

Agent Memory

ActMem: Bridging the Gap Between Memory Retrieval and Reasoning in LLM Agents

Xiaohui Zhang, Zequn Sun et al.

· 2026

ActMem transforms dialogue history into atomic facts via Memory Fact Extraction, groups them with Fact Clustering, links them through a Memory KG Construction module, and uses Counterfactual-based Retrieval and Reasoning for action-aware answers. On ActMemEval, ActMem reaches 76.52% QA accuracy with DeepSeek-V3, beating LightMem’s 63.97% by 12.55 points and NaiveRAG’s 61.54%.

Questions about this paper?

Paper: MemAudit: Post-hoc Auditing of Poisoned Agent Memory via Causal Attribution and Structural Anomaly Detection

Answers use this explainer on Memory Papers.

Checking…