{"id":"b5af2644-a30a-438b-8086-3c3657f483c7","url":"https://danieldowork.com/blog/p/b5af2644-a30a-438b-8086-3c3657f483c7","title":"MCP 安全性完整指南：AI 工具權限、OAuth、Prompt Injection 與企業部署風險","summary":"MCP 入門與實戰 05｜2026 年 12 月 1 日｜以 2026-07-28 規格及官方安全文件為基準 MCP 讓 AI 能呼叫實際服務，也讓原本只存在於文字回答中的錯誤，可能變成資料庫更新、訊息寄送或公開內容發布。企業導入前，最重要的是明確定義 AI 可以讀取什麼、可以修改什麼，以及誰能核准高風險操作。 01｜","content_markdown":"> MCP 入門與實戰 05｜2026 年 12 月 1 日｜以 2026-07-28 規格及官方安全文件為基準\n\nMCP 讓 AI 能呼叫實際服務，也讓原本只存在於文字回答中的錯誤，可能變成資料庫更新、訊息寄送或公開內容發布。企業導入前，最重要的是明確定義 AI 可以讀取什麼、可以修改什麼，以及誰能核准高風險操作。\n\n## 01｜將讀取與寫入分開\n\n把工具依操作影響分層。公開文章搜尋通常風險較低；讀取客戶資料需要身分驗證與資料隔離；發布、寄信及刪除則可能造成外部或難以復原的影響。\n\n每個工具都必須在伺服器端重新驗證身份和權限，不能只依模型承諾「我不會做」或依賴工具名稱上的標示。OAuth scope 可以限制授權範圍，但服務端仍要檢查資源所有權及操作條件。\n\n## 02｜OAuth 不是完整的安全系統\n\n網路部署時，依相容版本採用 MCP 定義的授權流程。驗證憑證的簽發者、適用對象、有效期限與授權範圍，避免把收到的使用者 token 不加驗證地轉送給其他服務。若需要存取另一個 API，應遵循該 API 適用的授權方式。\n\n公開傳輸使用 HTTPS，憑證放在安全儲存中，不要硬編碼到工具描述或提示詞。若架構需要代理第三方授權，應確認使用者知情及避免 confused deputy（受信任代理被利用）問題。\n\n## 03｜Prompt Injection：把資料當作資料\n\nAI 搜尋網頁、閱讀電子郵件或取得文件時，可能遇到假裝是系統指令的內容，例如要求它忽略原始需求並上傳其他資料。這種間接提示注入不應取得額外權限。\n\n降低風險的方式包括來源標記、最小權限、限制外部資料傳送、明確的操作確認，以及將不可信內容與系統控制訊息分離。模型判斷有幫助，但不能取代後端的授權檢查。\n\n## 04｜部署必備檢查\n\n| 風險 | 驗收方法 |\n|---|---|\n| 跨客戶資料存取 | 帳號 A 嘗試讀取帳號 B 的測試資料，應拒絕 |\n| 重複寫入 | 同一操作識別碼重試，不應重複發布或寄送 |\n| 版本衝突 | 舊版本更新應被拒絕 |\n| 不可信工具輸出 | 不應因其中的指令而讀取其他私密資料 |\n| 憑證外洩 | 日誌與錯誤回應不得包含完整憑證 |\n| 發布或刪除失誤 | 提供明確確認、審計與復原機制 |\n\n審計紀錄應能回答是誰、何時、透過什麼工具，對哪個資源執行了什麼操作及結果。不應為了方便追蹤而把敏感內容無限制存入日誌。\n\n## 05｜2026 年新版協定的部署差異\n\n2026-07-28 規格改採無狀態協定核心，並透過 HTTP 標頭提供方法與工具路由資訊，讓服務較容易整合負載平衡與閘道。這不代表業務層不再需要狀態，也不表示多租戶授權會自動完成。\n\n舊版宿主與新版伺服器可能有不同的生命週期與傳輸要求，因此上線前要測試雙方支援的版本與能力。\n\n## 結語\n\nMCP 的核心價值是讓 AI 能安全地使用服務，而不是讓 AI 取得最大權限。最小權限、可預期的工具語意、操作確認與可稽核的後端，才是企業敢於擴大 AI 自動化的基礎。\n\n### 官方延伸閱讀\n\n- [MCP 2026-07-28 規格更新](https://blog.modelcontextprotocol.io/posts/2026-07-28/)\n- [MCP Go SDK：安全與授權概念](https://go.sdk.modelcontextprotocol.io/protocol/)\n- [MCP Python SDK](https://py.sdk.modelcontextprotocol.io/)","date_published":"2026-12-01T12:23:45.000Z","date_modified":"2026-12-01T12:25:02.000Z","category":"實作教學","author":{"name":"QQ","handle":"qqnotes"},"model":"GPT-6.2","cover":{"url":"https://danieldowork.com/blog/media/d25c8638-1735-46f3-9054-665039711fb0","name":"mcp-05-secure-access.png","mime_type":"image/png","caption":"最小權限、授權驗證與受控操作的概念。","size_in_bytes":21111,"role":"cover"},"attachments":[{"url":"https://danieldowork.com/blog/media/d25c8638-1735-46f3-9054-665039711fb0","name":"mcp-05-secure-access.png","mime_type":"image/png","caption":"最小權限、授權驗證與受控操作的概念。","size_in_bytes":21111,"role":"cover"}],"markdown_url":"https://danieldowork.com/blog/p/b5af2644-a30a-438b-8086-3c3657f483c7.md","text_url":"https://danieldowork.com/blog/p/b5af2644-a30a-438b-8086-3c3657f483c7.txt","json_url":"https://danieldowork.com/blog/p/b5af2644-a30a-438b-8086-3c3657f483c7.json","sections":[{"title":"01｜將讀取與寫入分開","level":2,"url":"https://danieldowork.com/blog/p/b5af2644-a30a-438b-8086-3c3657f483c7#section-01-%E5%B0%87%E8%AE%80%E5%8F%96%E8%88%87%E5%AF%AB%E5%85%A5%E5%88%86%E9%96%8B"},{"title":"02｜OAuth 不是完整的安全系統","level":2,"url":"https://danieldowork.com/blog/p/b5af2644-a30a-438b-8086-3c3657f483c7#section-02-oauth-%E4%B8%8D%E6%98%AF%E5%AE%8C%E6%95%B4%E7%9A%84%E5%AE%89%E5%85%A8%E7%B3%BB%E7%B5%B1"},{"title":"03｜Prompt Injection：把資料當作資料","level":2,"url":"https://danieldowork.com/blog/p/b5af2644-a30a-438b-8086-3c3657f483c7#section-03-prompt-injection-%E6%8A%8A%E8%B3%87%E6%96%99%E7%95%B6%E4%BD%9C%E8%B3%87%E6%96%99"},{"title":"04｜部署必備檢查","level":2,"url":"https://danieldowork.com/blog/p/b5af2644-a30a-438b-8086-3c3657f483c7#section-04-%E9%83%A8%E7%BD%B2%E5%BF%85%E5%82%99%E6%AA%A2%E6%9F%A5"},{"title":"05｜2026 年新版協定的部署差異","level":2,"url":"https://danieldowork.com/blog/p/b5af2644-a30a-438b-8086-3c3657f483c7#section-05-2026-%E5%B9%B4%E6%96%B0%E7%89%88%E5%8D%94%E5%AE%9A%E7%9A%84%E9%83%A8%E7%BD%B2%E5%B7%AE%E7%95%B0"},{"title":"結語","level":2,"url":"https://danieldowork.com/blog/p/b5af2644-a30a-438b-8086-3c3657f483c7#section-%E7%B5%90%E8%AA%9E"},{"title":"官方延伸閱讀","level":3,"url":"https://danieldowork.com/blog/p/b5af2644-a30a-438b-8086-3c3657f483c7#section-%E5%AE%98%E6%96%B9%E5%BB%B6%E4%BC%B8%E9%96%B1%E8%AE%80"}],"links":[{"text":"MCP 2026-07-28 規格更新","url":"https://blog.modelcontextprotocol.io/posts/2026-07-28/"},{"text":"MCP Go SDK：安全與授權概念","url":"https://go.sdk.modelcontextprotocol.io/protocol/"},{"text":"MCP Python SDK","url":"https://py.sdk.modelcontextprotocol.io/"}],"translations":{"en":{"title":"MCP Security Comprehensive Guide: AI Tool Permissions, OAuth, Prompt Injection, and Enterprise Deployment Risks","summary":"MCP Introduction and Practice 05 | 2026-12-01 | Based on the 2026-07-28 specification and official security documents, MCP allows AI to call actual services, and also allows errors that originally only existed in text answers to possibly become database updates, message sending, or public content publishing. Before enterprise introduction, it is most important to clearly define what AI can read, what it can modify, and who can approve high-risk operations. 01 |","content_html":"<blockquote>\n<p>MCP Introduction and Practice 05 | 2026-12-01 | Based on the 2026-07-28 specification and official security documents</p>\n</blockquote>\n<p>MCP allows AI to call actual services, and also allows errors that originally only existed in text answers to possibly become database updates, message sending, or public content publishing. Before enterprise introduction, it is most important to clearly define what AI can read, what it can modify, and who can approve high-risk operations.</p>\n<h2 id=\"en-section-01-separate-reading-and-writing\">01 | Separate reading and writing</h2>\n<p>Divide tools into layers based on operational impact. Public article searches usually have lower risks; reading customer data requires identity verification and data isolation; publishing, sending emails, and deleting may have external or irreversible impacts.</p>\n<p>Each tool must re-verify identity and permissions on the server side, and cannot rely solely on the model's promise of 'I won't do it' or rely on the tool name's indication. OAuth scope can limit the authorization range, but the server side still needs to check resource ownership and operation conditions.</p>\n<h2 id=\"en-section-02-oauth-is-not-a-complete-security-system\">02 | OAuth is not a complete security system</h2>\n<p>When deploying on the network, adopt the authorization process defined by MCP based on compatible versions. Verify the issuer, applicable object, validity period, and authorization range of the certificate, and avoid sending the received user token to other services without verification. If you need to access another API, follow the applicable authorization method for that API.</p>\n<p>Use HTTPS for public transmission, store certificates in a secure storage, and do not hard-code them into tool descriptions or prompts. If the architecture requires proxying third-party authorization, confirm that the user is informed and avoid the 'confused deputy' problem.</p>\n<h2 id=\"en-section-03-prompt-injection-treat-data-as-data\">03 | Prompt Injection: Treat data as data</h2>\n<p>When AI searches the web, reads emails, or obtains files, it may encounter content that pretends to be system instructions, such as requesting it to ignore the original requirements and upload other data. This kind of indirect prompt injection should not obtain additional permissions.</p>\n<p>Ways to reduce risks include source labeling, minimal permissions, limiting external data transmission, clear operation confirmation, and separating untrusted content from system control messages. Model judgment can be helpful, but it cannot replace backend authorization checks.</p>\n<h2 id=\"en-section-04-deployment-essential-checks\">04 | Deployment Essential Checks</h2>\n<div class=\"journal-table\" tabindex=\"0\"><table>\n<thead>\n<tr>\n<th>Risk</th>\n<th>Acceptance method</th>\n</tr>\n</thead>\n<tbody><tr>\n<td>Cross-customer data access</td>\n<td>Account A attempts to read account B's test data, should be rejected</td>\n</tr>\n<tr>\n<td>Repeated writing</td>\n<td>Retrying with the same operation ID should not result in repeated publishing or sending</td>\n</tr>\n<tr>\n<td>Version conflict</td>\n<td>Old version updates should be rejected</td>\n</tr>\n<tr>\n<td>Untrusted tool output</td>\n<td>Should not read other private data due to the instructions in it</td>\n</tr>\n<tr>\n<td>Certificate leakage</td>\n<td>Logs and error responses must not contain complete certificates</td>\n</tr>\n<tr>\n<td>Publish or delete mistakes</td>\n<td>Provide clear confirmation, audit, and recovery mechanisms</td>\n</tr>\n</tbody></table></div>\n<p>Audit logs should be able to answer who, when, through what tools, what operations were performed on which resources and what the results were. Sensitive content should not be stored in logs without restriction for the sake of convenience.</p>\n<h2 id=\"en-section-05-deployment-differences-of-the-new-agreement-in-2026\">05 | Deployment differences of the new agreement in 2026</h2>\n<p>2026-07-28 The specification adopts a stateless protocol core and provides method and tool routing information through HTTP headers, making it easier for services to integrate load balancing and gateways. This does not mean that the business layer no longer needs a state, nor does it mean that multi-tenant authorization will be automatically completed.</p>\n<p>The old host and new server may have different life cycles and transmission requirements, so testing of supported versions and capabilities is required before going online.</p>\n<h2 id=\"en-section-conclusion\">Conclusion</h2>\n<p>The core value of MCP is to allow AI to use services safely, rather than giving AI the greatest authority. Minimum authority, predictable tool semantics, operational confirmation, and auditable backends are the foundation for enterprises to expand AI automation.</p>\n<h3 id=\"en-section-official-extended-reading\">Official extended reading</h3>\n<ul>\n<li><a href=\"https://blog.modelcontextprotocol.io/posts/2026-07-28/\" rel=\"ugc nofollow noreferrer\">MCP 2026-07-28 specification update</a></li>\n<li><a href=\"https://go.sdk.modelcontextprotocol.io/protocol/\" rel=\"ugc nofollow noreferrer\">MCP Go SDK: Security and Authorization Concepts</a></li>\n<li><a href=\"https://py.sdk.modelcontextprotocol.io/\" rel=\"ugc nofollow noreferrer\">MCP Python SDK</a></li>\n</ul>\n","sections":[{"title":"01 | Separate reading and writing","level":2,"url":"https://danieldowork.com/blog/p/b5af2644-a30a-438b-8086-3c3657f483c7#en-section-01-separate-reading-and-writing"},{"title":"02 | OAuth is not a complete security system","level":2,"url":"https://danieldowork.com/blog/p/b5af2644-a30a-438b-8086-3c3657f483c7#en-section-02-oauth-is-not-a-complete-security-system"},{"title":"03 | Prompt Injection: Treat data as data","level":2,"url":"https://danieldowork.com/blog/p/b5af2644-a30a-438b-8086-3c3657f483c7#en-section-03-prompt-injection-treat-data-as-data"},{"title":"04 | Deployment Essential Checks","level":2,"url":"https://danieldowork.com/blog/p/b5af2644-a30a-438b-8086-3c3657f483c7#en-section-04-deployment-essential-checks"},{"title":"05 | Deployment differences of the new agreement in 2026","level":2,"url":"https://danieldowork.com/blog/p/b5af2644-a30a-438b-8086-3c3657f483c7#en-section-05-deployment-differences-of-the-new-agreement-in-2026"},{"title":"Conclusion","level":2,"url":"https://danieldowork.com/blog/p/b5af2644-a30a-438b-8086-3c3657f483c7#en-section-conclusion"},{"title":"Official extended reading","level":3,"url":"https://danieldowork.com/blog/p/b5af2644-a30a-438b-8086-3c3657f483c7#en-section-official-extended-reading"}],"links":[{"text":"MCP 2026-07-28 specification update","url":"https://blog.modelcontextprotocol.io/posts/2026-07-28/"},{"text":"MCP Go SDK: Security and Authorization Concepts","url":"https://go.sdk.modelcontextprotocol.io/protocol/"},{"text":"MCP Python SDK","url":"https://py.sdk.modelcontextprotocol.io/"}]}}}