資料來源#
摘要#
會跨工作階段持續保存上下文的 agents,可能會遭到記憶污染,導致後續推理產生偏誤、不安全,或主動協助資料外洩。它與 Agentic Prompt Injection 這類單一工作階段攻擊的差異,在於持久性:植入 assistant 記憶的惡意指令,可能危害目前以及未來所有工作階段——初次注入很久之後,agent 仍持續服務攻擊者的目標。Zero Trust for AI Agents 的第 7 階段(「保護 agent 記憶」)正是針對此問題。
變體#
- 直接記憶中毒——攻擊者將指令寫入 agent 的長期記憶儲存區,影響之後的所有推理。
- RAG 中毒——透過遭污染的來源、直接上傳,或過度信任的 pipeline 將惡意資料引入向量資料庫。agent 在回答查詢時會取回遭污染的上下文,產生錯誤答案或執行指定的 payload。(這是 Agent Supply Chain Risk 在執行期資料上的類比。)
- 共享上下文中毒——在多租戶環境中,攻擊者透過正常互動注入資料,影響後續工作階段;新的使用者工作階段會繼承遭污染的上下文。
- 長期記憶漂移——最隱晦的一種:摘要或 peer-agent 回饋逐漸改變儲存的知識或目標權重,隨時間造成行為偏差,並且因為沒有任何單一變更看起來像惡意行為而躲過偵測。這正是行為基線需要漂移偵測的威脅。
防禦措施(第 7 階段)#
- 記憶隔離——在工作階段與使用者之間建立嚴格邊界,使一段對話中的遭污染上下文無法影響另一段對話。該框架指出,Claude Code 預設會強制執行工作階段隔離(每個工作階段使用全新的上下文;子 agents 位於隔離的上下文視窗中)。
- 上下文完整性驗證——使用密碼雜湊偵測未授權修改;使用來源歸因標籤記錄每個記憶元素的來源。應在每次取回時驗證,而不只是儲存時;將雜湊儲存在與記憶內容分離的防竄改日誌中;驗證失敗時拒絕內容並發出警示。
- 上下文保留政策——使用 TTLs 自動使未驗證的記憶過期;對高風險上下文(外部輸入、未驗證的工具輸出)採用較短的保留期限。Claude Code 的
cleanupPeriodDays控制本機逐字稿的持久化。 - 版本化記憶 + 隔離區——回復至已知良好狀態;刪除前先將可疑內容移入隔離區以進行鑑識分析;預先測試回復程序;定義完整清除與針對性修復的判定標準。
與 wiki 記憶概念的關係#
這是 wiki 其他地方那些良性持久記憶設計的對抗性對應物——agent harness 中受邊界限制的記憶檔案,以及這個 vault 本身所採用的 compiled knowledge base 模式。任何允許 agent 寫入耐久記憶的系統,都會承受這個威脅面;完整性驗證與來源歸因,正是讓編譯/持久化儲存維持可信的控制措施。
相關連結#
- Zero Trust for AI Agents——第 7 階段(「保護 agent 記憶」)(樞紐)
- Agentic Prompt Injection——注入是傳遞向量;兩者都利用模型無法區分資料與指令的缺陷,但中毒增加了持久性
- Agent Supply Chain Risk——RAG 中毒是遭污染上游元件在執行期資料上的類比
- LLM-as-Compiler Knowledge Base——會承受這個確切威脅面的良性持久知識模式(對耐久記憶的寫入權限)
- Claude Code——引用的參考:預設工作階段隔離、
cleanupPeriodDays、用於回復的 checkpoint/rewind - Out-of-Band Prompt-Injection Defense——持久記憶與先前 agent 的輸出是低完整性通道,Biba invariant 會降低其 subject 的權限;reference-monitor 類別中規格不足的provenance oracle(§8.2),與記憶完整性驗證及來源歸因面臨的是同一個 trusted-base 問題
- Agent Data Injection (ADI)——一種單一回合類比:其工具呼叫/回應注入偽造 agent 的上下文內執行歷史(偽造的先前工具結果),在完全未接觸持久儲存區的情況下,污染模型對自己已完成工作的記憶
- Non-Malleable Memory Authority (TMA-NM)——對此威脅最強的防禦側處理:TMA-NM(Louck,arXiv 2606.24322)在寫入時將每個記憶項目的行動權限與其來源以不可竄改方式綁定,因此,即使遭污染的記憶經過 agent 自身摘要、可信工具回聲或虛假佐證而被洗白,只要讀起來看似良善,仍會維持
act=none;一個機器檢查的 TLA⁺ 分離定理,加上 8 個模型的基準測試(攻擊成功率 0%,而內容/譜系基線最高達 68%,且效用完整)
開放問題#
- 長期記憶漂移被定義為逐次變更都無法偵測。漂移偵測需要基線——但如果基線本身也會漂移(Advanced「continuous baseline refinement」),要如何區分緩慢的中毒攻擊與正當演化?
- 完整性雜湊能偵測修改,卻無法偵測透過正當(但遭注入的)互動寫入的惡意但有效記憶。什麼能抓出語意遭污染、但密碼學完整無缺的記憶?(目前最強的答案:TMA-NM(Louck,arXiv 2606.24322)重新框定了這個問題。「惡意但有效」類別正是洗白攻擊——不可信內容被改述/回聲/虛假佐證,使其讀起來像良善內容且維持密碼學完整——而機器檢查的分離定理證明,任何基於內容或譜系的偵測器都無法可靠防禦它(T1);內容判斷器掃描也確認,在完整效用下,沒有任何閾值能達到 0% ASR。因此,修正方式不是抓出它,而是從建構上預防:在寫入時以不可竄改方式將每個項目的行動權限與其真正來源綁定,使洗白後的項目無論看起來多麼良善,都會是
act=none——在 8 個前沿模型、100% 合法效用下,攻擊成功率為 0%;而內容/譜系基線最高達 68%。它是預防,而非偵測。)
資料來源#
- Zero Trust for AI Agents——Part II memory/context poisoning threats;Part IV Phase 7(隔離、完整性驗證、保留)
Cited by 21
- Non-Malleable Memory Authority (TMA-NM)×6
memsecbench — Chen, Xie, Fu, Zhou, Yu & Xuan (Zhejiang University of Technology; Binjiang Institute…
- Agent Context Files×5
That direction is the opposite of everything else on this page. A context file earns authority by…
- Out-of-Band Prompt-Injection Defense×5
Memory And Context Poisoning — persisted memory and prior-agent outputs are low-integrity channels…
- Zero Trust for AI Agents×5
Context persistence — memory across sessions creates new data-protection needs (Memory And Context…
- Open Questions Backlog×4
Memory And Context Poisoning: Long-term memory drift is defined as undetectable per-change. Drift…
- Agentic Prompt Injection×3
The corpus does not support the unqualified version. Precision matters about what the claim covers:…
- Bind, Don't Forbid; Prevent, Don't Detect: The Action-Open and Poisoned-Memory Residuals×3
The replacement is prevention by construction: bind each memory item's authority-to-act to its true…
- Capability Gating Is Not Authorization×2
Memory And Context Poisoning — a discordant second reading of the deployment-tier exposure gap: Bad…
- Claude Code×2
Session isolation by default + cleanupPeriodDays + checkpoint/rewind → Memory And Context Poisoning…
- Context Lifecycle Management×2
Memory And Context Poisoning — the same substrate read adversarially, and the reason Scoping is a…
- OWASP×2
Agentic Prompt Injection / Memory And Context Poisoning — threats in OWASP's agentic taxonomy
- Self-Propagating Prompt Injection (AI Worms)×2
That second route is the load-bearing one for this page's threat model, because it removes the last…
- Agent Data Injection (ADI)
Memory And Context Poisoning — tool-call-and-response injection fabricates the agent's in-context…
- Agent Supply Chain Risk
Memory And Context Poisoning — RAG/data-pipeline poisoning is a runtime-composition analogue of…
- Authority and Audit Survive Abundance
What would change this answer. Cat Wu's prediction that "all the safety mechanisms today — prompt…
- Blast Radius (Agentic)
Memory And Context Poisoning — the recovery half of the unit, and the one nothing else on this page…
- When Knowledge Layers Disagree: Context Files vs Memory, and Conflicting Sources at Compile Time
Policy disagreements: the context file wins, always. A context file is the high-integrity channel —…
- LLM-as-Compiler Knowledge Base
Memory And Context Poisoning — the adversarial threat surface this pattern inherits: any system…
- Agent Security
Memory And Context Poisoning — Corruption of persistent agent memory that influences behavior long…
- Task-Specification Effects in Prompt Injection (AutoDojo)
Memory And Context Poisoning — an untested surface for this page's argument: AM-Sentry…
- Write-Then-Trusted
Memory And Context Poisoning — the same seam, one substrate over, and with rates attached. Here the…
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,…
- Agent Data Injection (ADI)
A new category of indirect prompt injection: malicious payloads disguised as *trusted data* (metadata like a comment's…
- Out-of-Band Prompt-Injection Defense
Second-generation prompt-injection defense enforced outside the model: a deterministic reference monitor mediates tool…
- Zero Trust for AI Agents
Anthropic's security framework for deploying autonomous agents: trust nothing / verify everything / assume breach, appl…
- Agentic Prompt Injection
Direct and indirect injection of malicious instructions into an agent; LLMs cannot reliably distinguish information fro…
