Skip to content

ASI06:記憶與上下文污染

Memory & Context Poisoning

說明

Agentic 系統仰賴可儲存與可擷取的資訊,這些資訊可能是 conversation history 的 snapshot、memory tool 或擴充 context,用來支援跨任務與 reasoning cycle 的連續性。Context 包含 Agent 保留、擷取或重複使用的任何資訊,例如 summary、embedding 與 RAG store,但不包含 LLM01:2025 Prompt Injection 所涵蓋的一次性輸入 prompt。

在 Memory and Context Poisoning 中,攻擊者會破壞或植入惡意、誤導性的 context,使未來的 reasoning、planning 或 tool use 產生偏差、不安全行為,或協助資料外洩。Upload、API feed、user input 或 peer-agent exchange 等 ingestion source 可能是不受信任或僅經部分驗證的來源。

此風險不同於 ASI01(Agent Goal Hijack),後者涵蓋直接的目標操弄;也不同於 ASI08(Cascading Failures),後者描述 poisoning 發生後的劣化與傳播。然而,memory poisoning 經常會進一步造成 goal hijacking(ASI01),因為被污染的 context 或 long-term memory 可能改變 Agent 對目標的解讀、reasoning path 或 tool-selection logic。

本項建立在 LLM01:2025 Prompt Injection、LLM04:2025 Data and Model PoisoningLLM08:2025 Vector and Embedding Weaknesses 之上,但聚焦於 Agent memory 與可擷取 context 的持久性破壞;這些污染會跨 session 傳播並改變 autonomous reasoning。

Agentic Threats and Mitigations 中,本項對應 T1 Memory Poisoning,並與 T4 Memory Overload、T6 Broken GoalsT12 Shared Memory Poisoning 的影響相關。在 AIVSS 中,AARS 欄位 Memory UseContextual Awareness 會提高 Agentic vulnerability score。

常見漏洞範例

  1. RAG and embeddings poisoning — 惡意或遭操弄的資料透過 poisoned source、直接 upload 或過度信任的 pipeline 進入 vector DB,造成被納入後續考量的錯誤答案與具針對性的 payload。
  2. Shared user context poisoning — 重複使用或共享的 context 讓攻擊者可以透過一般 chat 注入資料,進而影響後續 session。其效果包括 misinformation、不安全的程式碼執行,或錯誤的工具操作。
  3. Context-window manipulation — 攻擊者把特製內容注入持續進行中的 conversation 或 task,使其之後被 summary 或保存進 memory;即使原始 session 已結束,未來 reasoning 或 decision 仍會受到污染。
  4. Long-term memory drift — 持續接觸少量遭污染的資料、summary 或 peer-agent feedback,會逐步改變已儲存的 knowledge 或 goal weighting,使 behavior 或 policy 隨時間產生偏移。
  5. Systemic misalignment and backdoors — Poisoned memory 改變 model persona,並植入以 trigger 啟動的 backdoor,執行隱藏指令,例如 destructive code 或 data leak。
  6. Cross-agent propagation — 被污染的 context 或 shared memory 在合作的 Agent 之間傳播,進一步放大 corruption,並造成長期資料外洩或 coordinated drift。

攻擊情境範例

  1. Travel Booking Memory Poisoning — 攻擊者持續強化一個假的機票價格;assistant 把它儲存為事實,之後依此價格核准訂票並繞過 payment check。
  2. Context Window Exploitation — 攻擊者把嘗試分散到多個 session,讓先前的拒絕逐漸離開 context;AI 最終授予逐步提高的權限,直到 admin access。
  3. Memory Poisoning for System — 攻擊者重新訓練 security AI 的 memory,使其把惡意活動標示為正常,讓攻擊在未被偵測的情況下通過。
  4. Shared Memory Poisoning — 攻擊者把假的 refund policy 寫入 shared memory;其他 Agent 重複使用該資訊,導致錯誤決策、損失與爭議。
  5. Cross-tenant vector bleed — 攻擊者植入近似重複的內容,利用寬鬆的 namespace filter,使高 cosine similarity 的另一個 tenant 敏感 chunk 被擷取出來。
  6. Assistant Memory Poisoning — 攻擊者透過 Indirect Prompt Injection 植入使用者 assistant 的 memory,破壞該使用者目前與未來的 session。

預防與緩解指南

  1. Baseline data protection — 傳輸中與靜態資料都加密,並搭配 least-privilege access。
  2. Content validation — 在寫入 memory 前,以規則與 AI 掃描所有新的 memory write 與 model output,偵測惡意或敏感內容。
  3. Memory segmentation — 隔離 user session 與 domain context,避免 knowledge 與 sensitive data leakage。
  4. Access and retention — 只允許 authenticated、curated source;依 task 強制 context-aware access;並依資料敏感度降低 retention。
  5. Provenance and anomalies — 要求 source attribution,並偵測可疑的 update 或更新頻率。
  6. 避免將 Agent 自己產生的 output 自動重新 ingest 回 trusted memory,以免形成 self-reinforcing contamination 或「bootstrap poisoning」。
  7. Resilience and verification — 執行 adversarial test,使用 snapshot/rollback 與 version control,並要求 high-risk action 經 human review。若使用 shared vector 或 memory store,採用 per-tenant namespace 與 entry trust score,讓未驗證 memory 隨時間衰減或過期,並支援對疑似 poisoning 內容進行 rollback/quarantine。
  8. 讓未驗證的 memory 過期,以限制 poisoning 的持續時間。
  9. 依 trust 與 tenancy 加權 retrieval — 高影響 memory 必須具備兩個因素才能被取用,例如 provenance score 加上 human-verified tag,並讓低信任 entry 隨時間衰減。

參考資料

  1. New hack uses prompt injection to corrupt Gemini’s long-term memoryhttps://arstechnica.com/security/2025/02/new-hack-uses-prompt-injection-to-corrupt-geminis-long-term-memory/
  2. Attackers Can Manipulate AI Memory to Spread Lieshttps://www.bankinfosecurity.com/attackers-manipulate-ai-memory-to-spread-lies-a-27699
  3. Poisoned RAGhttps://arxiv.org/pdf/2402.07867
  4. AgentPoison: Red-teaming LLM Agents via Poisoning Memory or Knowledge Baseshttps://arxiv.org/abs/2407.12784
  5. Securing Agentic AI: A Comprehensive Threat Model and Mitigation Framework for Generative AI Agentshttps://arxiv.org/pdf/2504.19956
  6. Dynamic Cheatsheet: Test-Time Learning with Adaptive Memoryhttps://arxiv.org/abs/2504.07952v1
  7. Memento: Fine-tuning LLM Agents without Fine-tuning LLMshttps://arxiv.org/abs/2508.16153
  8. AgentFlayer: persistent 0click exploit on ChatGPT.
  9. Hacker plants false memories in ChatGPT to steal user data in perpetuity
  10. The Trifecta: How Three New Gemini Vulnerabilities in Cloud Assist, Search Model, and Browsing Allowed Private Data Exfiltration

原作:OWASP Top 10 For Agentic Applications 2026
專案:OWASP Gen AI Security Project - Agentic Security Initiative
授權:CC BY-SA 4.0
本翻譯為非官方繁體中文版本,並依 CC BY-SA 4.0 授權釋出。