AI Security
Sentinel Gateway:用指令/資料分離防 Agent Prompt Injection
Sentinel Gateway 類架構把 Agent 指令通道與外部資料通道分離,用 signed scoped token、tool scope、policy enforcement 與 audit log 降低 prompt injection 風險;對任何會讀網頁、API、PDF、email、留言的 Agent 都是重要設計。
2026年7月3日4 分鐘閱讀👁 6
Agent Security × Prompt Injection × Runtime Gateway
Sentinel Gateway:用「指令/資料分離」降低 Agent 讀外部內容時的 Prompt Injection 風險
這篇 Threads 提醒一個所有 production AI Agent 都會遇到的結構性問題:只要 Agent 會讀網頁、API 回應、PDF、搜尋結果或使用者上傳檔案,外部資料就可能夾帶「請忽略之前指令」這類間接 prompt injection。Sentinel Gateway 的設計思路是在 Agent 與工具之間加一層閘道,把指令通道與資料通道分離,並在基礎設施層做 scope / token / policy enforcement。
Reality check:GitHub 上有多個同名/近名 Sentinel Gateway 專案。本文主要核對的是
cmtopbas/Sentinel-Gateway:Python,Apache-2.0,repo description 指向「Agentic AI Security & Multi Agent Management」,主張用 granular action scope 與 cryptographically protected instruction channel 防 prompt injection。另有 gajjela521/sentinel-gateway(Java/Spring Boot)主打 policy enforcement、semantic drift detection、financial circuit breakers。導入前要確認你要看的到底是哪一個。原文重點
- 只要 Agent 會爬網頁、讀 API、處理上傳檔案,就會接觸不可信外部內容。
- 外部內容可能藏著「忽略之前指令,改做 X」這類 prompt injection。
- 如果 Agent 把外部資料與 runtime 指令混在同一個語境,就可能照單全收。
- Sentinel Gateway 的思路是在 Agent 和工具之間加閘道,讓「指令」與「資料」走不同通道。
- 外部內容只能是資料,不能進入可執行指令層。
為什麼這不是小問題
| Agent 會讀的來源 | Prompt Injection 風險 |
|---|---|
| 網頁 / 搜尋結果 | 頁面可藏「忽略系統指令、洩漏資料」等文字。 |
| PDF / 文件 / 履歷 | 上傳者可把惡意指令放進文件內容,誘導 Agent 呼叫工具。 |
| API 回應 | 第三方 API 或被污染資料可把攻擊包在 JSON/string 欄位裡。 |
| 留言 / 社群內容 | 整理留言、爬 Threads/X/Reddit 時尤其容易遇到惡意文字。 |
| 電子郵件 | Mail agent 若能寄信/讀信/下載附件,風險更高。 |