NVIDIA Open Agent Safety Platform 如何防止 MCP 越权调用?2026 OpenShell L7 tools/call 策略与 JSON 审计
「已连上 MCP 服务器」不等于「只能调允许的 tool」。2026 年 NVIDIA Open Agent Safety Platform 在 OpenShell supervisor 的 L7 代理上,对每条出站 tools/call 看 params.name,用 deny_rules 先挡 refund_order 这类写操作,并把决定落成可 Diff 的 JSON 审计。本篇专讲 MCP Security 与越权 tool,不重写 sandbox 生命周期,也不写攻击步骤。
阅读前速览
| 能力 | OpenShell / 平台事实(2026 文档与 PR) | 防越权看什么 |
|---|---|---|
| L7 MCP enforcement | 沙箱出站 body 解析 JSON-RPC;MCP 端点匹配 method 与 tools/call 的 tool 名 | protocol: mcp、deny_rules、tool / params.name |
| 批处理 fail-closed | 一条 tools/call 被拒,整批 JSON-RPC 不转发 | batch_index、整批 deny |
| 参数盲区 | 文档写明:tool arguments 不匹配;允许的工具接受任意 arguments | 越权靠工具名 + 宿主 Schema |
| 平台审计 | Supervisor 在 agent 工作负载外决策;Sentry 可选带外关联(不代替 L7 规则) | outcome、matched_rule、params_redacted |
事实截至 2026-11-10:NVIDIA Open Agent Safety Platform 技术博客、OpenShell Policy Schema(MCP rules)、L7 json-rpc/mcp enforcement PR。订单 A-1042、审计 JSON 为虚构示意。
防 MCP 越权 = L7 按工具名 deny + 批处理 fail-closed + 出站审计 JSON
企业关心的「越权」常指:会话里只批准了查单,沙箱却发出 refund_order;或同一 TCP 连接上,Agent 在 lookup_order 之外再调了未登记 tool。仅 network: full 到 MCP host 时,所有 tools/call 都能过——这是 OpenShell issue #1793 描述的典型缺口。2026 年在 enforcement: enforce 的 MCP 端点上加 L7 规则:显式 allow initialize、tools/list 与只读 tool,把写操作写进 deny_rules。
- 工具名层:supervisor 读离开沙箱的请求体,不靠模型 prose;
refund_order命中 deny 即停。 - 批次层:查单与退款不要同一 batch;一条 deny,整批不转发。
- 参数层:OpenShell 不验
order_id;宿主 Schema 仍是第二道门(见四层安全模型)。
sandbox 怎么建、TOFU binary 见 OpenShell runtime sandbox。Schema + Policy + Sandbox 四层见 四层 JSON 安全模型。MCP 线型见 Coding Agent 如何调用 MCP。会话 allow 不是出站门,见 Coding Agent 的权限模型。
越权常发生在「TCP 已放行,tools/call 未细分」
Harness 里用户点了 Allow lookup_order,只说明这一轮意图被批准。真正发 HTTP 的是沙箱里的 runner。若 network policy 只写 access: full 到 orders.example.com:443,同一连接上的任意 MCP method 都能试——包括未在 UI 里出现过的 tool。L7 MCP Security 把决策下推到每条 JSON-RPC:supervisor 解析 method、对 tools/call 读 params.name(或 tool 字段),再对照 allow / deny 表。解析失败、响应形 frame 或歧义 batch 时 fail-closed,不猜意图。
这不是「在 prompt 里禁止退款」。模型仍可能填 JSON;边界必须在 agent 工作负载外面的 supervisor 上做,与 Open Agent Safety Platform「带外 enforcement」一致。平台里的 Sentry / BlueField 是可选的关联与隔离层,不能替代把 refund_order 写进 deny_rules。
从放行到拦截:四段可 Diff 的 JSON
1. 允许的 tools/call(只读)。 proxy 在转发前匹配 allow 规则:
{
"jsonrpc": "2.0",
"id": "call_lookup_1",
"method": "tools/call",
"params": {
"name": "lookup_order",
"arguments": { "order_id": "A-1042" }
}
}
2. 同一批夹带写操作(整批被拒)。 第二跳 refund_order 触发 deny,batch_index 记入审计:
[
{
"jsonrpc": "2.0",
"id": "batch-1",
"method": "tools/call",
"params": {
"name": "lookup_order",
"arguments": { "order_id": "A-1042" }
}
},
{
"jsonrpc": "2.0",
"id": "batch-2",
"method": "tools/call",
"params": {
"name": "refund_order",
"arguments": { "order_id": "A-1042", "reason": "agent_requested" }
}
}
]
3. 最小权限策略片段(与官方 YAML 同字段)。 deny_rules 写在 rules 之后求值;通配 tool 需 strict_tool_names: true:
{
"version": 1,
"network_policies": {
"orders_readonly": {
"name": "orders_readonly",
"endpoints": [{
"host": "orders.example.com",
"port": 443,
"path": "/mcp",
"protocol": "mcp",
"enforcement": "enforce",
"mcp": {
"strict_tool_names": true,
"allow_all_known_mcp_methods": false,
"versions": ["2025-11-25"]
},
"rules": [
{ "allow": { "method": "initialize" } },
{ "allow": { "method": "notifications/initialized" } },
{ "allow": { "method": "tools/list" } },
{
"allow": {
"method": "tools/call",
"tool": { "any": ["lookup_order", "list_orders"] }
}
}
],
"deny_rules": [
{ "method": "tools/call", "tool": "refund_order" },
{ "method": "tools/call", "tool": "cancel_shipment" }
]
}],
"binaries": [{ "path": "/usr/bin/python3" }]
}
}
}
4. 虚构出站审计事件。 决策日志 redact params,便于合规留存与 JSONPath 抽查(不是 Sentry 未公开 wire 格式):
{
"decision_id": "eg_9c4e02ab",
"timestamp": "2026-11-10T06:44:11Z",
"sandbox_id": "sb_agent_demo_7f3a",
"endpoint": "orders.example.com:443/mcp",
"protocol": "mcp",
"binary": "/usr/bin/python3",
"outcome": "denied",
"matched_rule": "deny_rules.tools/call.refund_order",
"jsonrpc": {
"method": "tools/call",
"tool": "refund_order",
"batch_index": 1,
"params_redacted": true
},
"platform": {
"stack": "nvidia-open-agent-safety-platform",
"component": "openshell-supervisor-network",
"l7_enforcement": "mcp",
"fail_closed": true
}
}
2026 MCP Security 策略能匹配什么、不能匹配什么
写策略前对齐文档边界,避免「以为挡了参数」或「以为拦了服务端响应」:
| 对象 | L7 MCP 策略 | 仍可能发生的越权 |
|---|---|---|
| tools/call 的 tool 名 | allow / deny_rules;支持 tool 与 params.name |
允许的工具内 arguments 任意——需宿主 Schema |
| MCP method | initialize、tools/list 等须显式列出(除非 allow_all_known_mcp_methods) |
忘了 list 握手,连接根本起不来 |
| JSON-RPC batch | 任一元素 deny → 整批 deny | 把读与写拆成两次请求,别用 batch 试探 |
| 服务端响应 / SSE | 当前文档:转发,不做策略解析 | 恶意响应内容要在宿主验 Schema / 业务规则 |
| policy 加载路径 | YAML 与 proto 应对齐;历史 bug 曾在 proto 路径丢 params matcher | 生产只走 proto 时 tool 级 allow 可能变「全放行」——Diff 两路径 |
参数门见 为什么 AI 需要 JSON Schema。OpenShell 与 Sentry 工具名入门见 OpenShell 与 Sentry——本篇往下讲 deny、批处理与审计 JSON。
六步给 MCP Server 做最小权限
用虚构订单 A-1042 在 staging 验收,再放宽 allow 列表:
- endpoint 标
protocol: mcp且enforcement: enforce,与 legacy json-rpc 分 host 或分 path。 - 默认
mcp.allow_all_known_mcp_methods: false,把握手 method 一条条写进 rules。 - 只读 tool 用 allow + 任意 globs;写操作只进
deny_rules,不要「先 allow * 再 deny 一个」。 - 禁止 batch 混读写:lookup 与 refund 分开发;验收整批 deny 行为。
- 宿主 Schema 绑每个 allow 的 tool;OpenShell 不匹配 arguments。
- 策略变更做 JSON Diff + prover;审计流保留
matched_rule与batch_index。
增量 policy update --add-endpoint 尚不接受 mcp——整份 openshell policy set 更利于审阅越权面。
怀疑越权时摊开四份 JSON
对照模型 tool_use、沙箱实际出站 body、生效 policy 与审计事件。
- 出站 body 与 policy 格式化;arguments 用 Schema 校验 验
A-1042。 - 用 JSONPath 提取 抽
$[1].params.name、$.network_policies.*.endpoints[*].deny_rules。 - 放宽前后 policy JSON Diff;先看新增 tool allow,再改 prompt。
openshell logs --tail --source sandbox看matched_rule与 fail-closed。- 审计与消息里的 token 先 脱敏。JSONSort 浏览器本地处理。
四份对齐后,才能分清是 harness 误 Allow、L7 deny、batch 连坐,还是 arguments 没走 Schema。
常见误区
- 以为连上 MCP 就等于最小权限。 没有 L7 tool 规则时,同一 socket 上任意 tools/call 都可能过。
- 用 allow * tools/call 再 deny 一个写 tool。 文档要求不能与 tool 级 allow 混用「匹配全部 tools/call」的规则。
- 把 refund 藏在已 allow 工具的 arguments 里。 L7 不看 arguments;写操作必须 tool 名进 deny。
- 忽略 batch 语义。 查单与退款同一数组,lookup 也会被连坐拒绝——要分开发。
- 只验模型输出,不验沙箱出站 body。 supervisor 看的是进程发出的 JSON-RPC。
- 把本篇当成四层安全栈。 MCP 越权专文;Schema + manifest + sandbox 全栈见 agent-sandbox-schema-tool-policy。
FAQ
和 nvidia-openshell-agent-sandbox-json 有什么区别?
那篇讲 openshell-sandbox、Landlock、TOFU 与 protocol 分轨。本篇专讲 L7 如何按 tools/call 挡越权、批处理与审计 JSON。
deny_rules 和 harness deny 一样吗?
不一样。harness 拦会话工具意图;deny_rules 拦沙箱发往 MCP 端点的具体 tool 名。两份策略都要。
能按 arguments 里的 order_id 做 deny 吗?
当前 OpenShell 文档不支持 params/arguments 匹配。订单号形状用宿主 JSON Schema 验。
MCP Security 会过滤 tools/call 的返回 JSON 吗?
按现行文档,服务端响应与 SSE 上的 MCP 消息转发时不做策略解析。返回体仍要 Schema 与业务校验。
Open Agent Safety Platform 里 Sentry 做什么?
可选带外层:关联策略决策、工具访问与身份,并在越界时硬件侧隔离。它不代替在 policy 里写 deny_rules。
结论
防 MCP 越权不靠提示词,靠 supervisor L7:每条出站 tools/call 对工具名做最小权限,batch fail-closed,决策落成审计 JSON。
把 lookup_order 放在 allow、refund_order 放在 deny_rules、A-1042 放在 Schema——三处对齐,越权面才收得住。
延伸阅读
- OpenShell runtime sandbox openshell-sandbox 与 TOFU 出站
- 四层 JSON 安全模型 Schema + Policy + Sandbox + 审计
- OpenShell 与 Sentry 入门 工具名 allow/deny 与硬件可选层
- Coding Agent 如何调用 MCP tools/call 的 JSON-RPC 形状
- Agent Harness 与 JSON State tool_use 与出站谁执行
- 为什么 AI 需要 JSON Schema arguments 第二道门
- JSONSort 本地工具箱 格式化、校验、Diff、JSONPath
- 全部文章 更多 JSON 与 AI 开发笔记
更新记录: 首次发布