H
Howardism
Plate IIAI Engineering機器翻譯 · machine-translatedENHOWARDISM

Memory and Context Poisoning

PublishedMay 28, 2026FiledConceptDomainAI EngineeringTagsSecurityMemoryRAGThreatsReading4 minSourceAI-synthesised

持久 agent 記憶遭腐敗,在初次注入很久之後仍影響行為;涵蓋 RAG poisoning、shared-context poisoning,以及緩慢的長期記憶漂移;以記憶隔離、完整性驗證與保留政策防禦

Memory and Context Poisoning 的示意圖

資料來源#

摘要#

跨工作階段持久保存脈絡的 agent,其記憶可能被腐敗,使日後推理偏頗、不安全,或積極協助資料外洩。與 Agentic Prompt Injection 等單一工作階段攻擊不同之處在於持久性:植入助理記憶的惡意指令可危及目前與未來所有工作階段——agent 在初次注入很久之後仍持續服務攻擊者目標。Zero Trust for AI Agents 的 Phase 7(「safeguard agent memory」)針對此威脅。

變體#

  • Direct memory poisoning — 攻擊者指令寫入 agent 的長期記憶儲存;影響之後所有推理。
  • RAG poisoning — 透過被毒害的來源、直接上傳或過度信任的管線,將惡意資料引入向量資料庫。agent 在回答查詢時擷取受污染的脈絡,產生錯誤答案或執行針對性 payload。(Agent Supply Chain Risk 在執行期資料上的類比。)
  • Shared context poisoning — 在多租戶環境中,攻擊者透過正常互動注入資料,影響之後的工作階段;新的使用者工作階段會繼承被毒害的脈絡。
  • Long-term memory drift — 最細微的一種:摘要或同儕 agent 回饋逐漸改變儲存知識或目標權重,隨時間產生行為偏差,且因為沒有任何單次變更看起來惡意而難以偵測。這正是行為基線中 drift detection 的動機。

防禦(Phase 7)#

  • Memory isolation — 工作階段與使用者之間嚴格邊界,使某一對話的被毒害脈絡無法影響另一對話。框架指出 Claude Code 預設強制工作階段隔離(每個工作階段全新脈絡;子 agent 在隔離的 context window 中執行)。
  • Context integrity validation — 以密碼學雜湊偵測未授權修改;為每個記憶元素標註來源歸屬。在每次擷取時驗證,而非僅在儲存時;將雜湊存放在與記憶內容分離、防竄改的日誌中;驗證失敗時拒絕並告警。
  • Context retention policies — 以 TTL 自動過期未驗證的記憶;高風險脈絡(外部輸入、未驗證的工具輸出)保留較短。Claude Code 的 cleanupPeriodDays 控制本機 transcript 的持久化。
  • Versioned memory + quarantine — 回滾至已知良好狀態;隔離可疑內容以供刪除前的鑑識分析;預先測試回滾程序;定義全面清除與針對性修復的準則。

與 wiki 記憶概念的關係#

這是 wiki 其他處良性持久記憶設計的對抗面——agent harness 中的 bounded memory 檔案、本 vault 所採用的 compiled knowledge base 模式。任何允許 agent寫入持久記憶的系統都會繼承此威脅面;完整性驗證與來源歸屬,是讓編譯/持久化儲存保持可信的控制手段。

相關連結#

開放問題#

  • Long-term memory drift 被定義為單次變更無法偵測。drift detection 需要基線——但若基線本身也在漂移(Advanced「continuous baseline refinement」),緩慢的 poisoning 攻擊如何與合法的演進區分?
  • 完整性雜湊能偵測修改,卻無法偵測透過合法(被注入)互動寫入的惡意但有效記憶。語意上已毒害、密碼學上仍完整的記憶,由什麼來攔截?

資料來源#

  • Zero Trust for AI Agents — Part II memory/context poisoning 威脅;Part IV Phase 7(isolation、integrity validation、retention)
§ end
About this piece

Articles in this journal are synthesised by AI agents from a curated wiki and are refreshed automatically as new concepts arrive. Topics, framing, and editorial direction are curated by Howardism.

Cited by 8
  • Agent Supply Chain Risk

    Runtime-composed agent ecosystems expand the supply-chain attack surface: model poisoning (250 docs backdoor a 13B mode…

  • Agentic Prompt Injection

    Direct and indirect injection of malicious instructions into an agent; LLMs cannot reliably distinguish information fro…

  • Claude Code

    Anthropic's agentic coding product; created by Boris Cherny late 2024; TypeScript/React; CLI/desktop/web/mobile/IDE sur…

  • LLM-as-Compiler Knowledge Base

    Karpathy's architecture: LLM incrementally compiles raw docs into a persistent interlinked wiki, replacing RAG with a 4…

  • AI Engineering & Agent Tooling

    Map of Content for the ai-engineering domain — 36 concepts. Curated entry point; see Home for all domains.

  • Open Questions Backlog

    _96 pages with open questions, as of 2026-06-14._

  • OWASP

    Open Worldwide Application Security Project; source of the agentic threat taxonomy cited throughout Anthropic's Zero Tr…

  • Zero Trust for AI Agents

    Anthropic's security framework for deploying autonomous agents: trust nothing / verify everything / assume breach, appl…

Related articles
  • Least Agency

    OWASP term extending least privilege to agents: constrain not just what an agent can access but what each tool can do,…

  • MCP and Computer Use

    Anthropic's two complementary connector mechanisms: MCP for structured programmatic access (Salesforce/Drive/Gmail/Slac…

  • Zero Trust for AI Agents

    Anthropic's security framework for deploying autonomous agents: trust nothing / verify everything / assume breach, appl…

  • Claude Code Best Practices

    Anthropic's guide to effective Claude Code usage: context management, verification-driven development, explore→plan→cod…

  • Agent Identity and Authentication

    The foundation control for agentic Zero Trust: cryptographically-rooted per-agent identity (→X.509→hardware attestation…