08 防禦:從機率性到確定性

索引:README|原理 01-principles

0. 總原則

  • 假設模型一定會被注入(assume breach),設計目標是「被注入時最壞能發生什麼」。
  • 防禦分兩類:機率性(降低機率:classifier、prompt 技巧、alignment)與確定性(限制可能性:權限、隔離、資訊流)。只有後者能寫進 threat model 當保證。
  • 檢查口訣:Lethal trifecta 砍一腳/Rule of Two(Meta)。

1. 分層防禦(由外到內,越外層越確定)

層做法性質代表
L1 隔離container → gVisor → microVM;檔案系統唯讀/範圍限縮確定性gVisor、Firecracker、NVIDIA OpenShell、Claude Code sandboxing
L2 網路 egressdefault-deny;domain allowlist 含 DNS;禁 markdown 圖片自動載入確定性OpenAI DNS 事件教訓(07-open-vs-closed)
L3 身分與權限per-task、短效、最小 scope token;不給 agent ambient credential;service account ≠ 使用者權限確定性MCP Authorization、MCP Security Best Practices
L4 Tool policygateway 層 allowlist、參數驗證、讀寫分離、高風險動作 HITL確定性Progent(2504.11703)
L5 資訊流控制控制流/資料流分離;taint label;不可信資料不能決定動作確定性(設計內)CaMeL(2503.18813)、Fides(2505.23643)、Design Patterns(2506.08837)
L6 供應鏈MCP server pin 版本 + hash、tool 描述變更告警(防 rug pull)、內部 registry確定性+流程06-incidents postmark 事件
L7 偵測prompt-injection classifier、output filter機率性Prompt-Guard、NeMo Guardrails、PurpleLlama
L8 模型層instruction hierarchy、StruQ/SecAlign、spotlighting機率性2404.13208、2402.06363、2410.05451、2403.14720
L9 監控與應變完整 audit log(tool call + 輸入來源)、異常自動 kill、事後可重建確定性(若自動)OpenAI:告警 15 分但 2.5 小時才停

2. Guardrails / classifier 的極限

  • Adaptive attack 下各類 IPI 防禦被繞過(2503.00061、2510.09023)。
  • EchoLeak 即繞過了 Microsoft 的 XPIA classifier(NVD);Auto Mode classifier 被 module shadowing 繞過。
  • Classifier 的正確定位:偵測與告警(提高攻擊成本、產生 telemetry),不是邊界。好比篩檢:sensitivity 永遠 <100%,不能取代手術室的無菌區規範。

3. 紅隊與評測工具

  • garak(LLM 弱點掃描)、PyRIT(Microsoft 紅隊框架)、promptfoo(CI 中的 red team)。
  • Benchmark:AgentDojo(2406.13352)、InjecAgent(2403.02691)、AgentHarm(2410.09024)。注意:benchmark ASR ≠ adaptive 安全性。

4. Computer use 的定位

Computer use 讓 agent 透過 GUI 操作,攻擊面 = 螢幕上任何可見文字,且權限 = 登入者整個 session(ambient authority 最大化)。ZombAIs、Comet、Antigravity 都屬此類。對醫院:能用結構化 API/MCP tool 解決的,就不要用 computer use;若必須用,跑在拋棄式 VM、無院內憑證、egress 白名單。