-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
第三方tool未鉴权(插件、MCP等) #8511
Copy link
Copy link
Open
Labels
area:coreThe bug / feature is about astrbot's core, backendThe bug / feature is about astrbot's core, backendarea:webuiThe bug / feature is about webui(dashboard) of astrbot.The bug / feature is about webui(dashboard) of astrbot.enhancementNew feature or requestNew feature or requestfeature:pluginThe bug / feature is about AstrBot plugin system.The bug / feature is about AstrBot plugin system.
Metadata
Metadata
Assignees
Labels
area:coreThe bug / feature is about astrbot's core, backendThe bug / feature is about astrbot's core, backendarea:webuiThe bug / feature is about webui(dashboard) of astrbot.The bug / feature is about webui(dashboard) of astrbot.enhancementNew feature or requestNew feature or requestfeature:pluginThe bug / feature is about AstrBot plugin system.The bug / feature is about AstrBot plugin system.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Description / 描述
目前 AstrBot 中第三方 LLM tools(例如插件 tools、MCP tools,以及类似 Handoff / 外部能力桥接类工具)在进入 LLM tool-calling 流程后,权限控制主要依赖工具或插件开发者自行实现。
也就是说只要用户想就能恶意让ai调用对安全造成影响的问题(例如:本地文件的修改)导致第三方工具是否安全,完全取决于插件作者是否主动实现鉴权。对于文件读写、命令执行、网页控制、定时任务、外部系统操作等高危工具来说,这存在一定安全风险。
当前 LLM tools 的来源比较多,包括但不限于:
这些工具最终都会进入统一的 LLM tool 列表中,由模型在 tool-calling 阶段选择调用。
但目前权限判断并没有形成统一后端机制,而是更多依赖:
event.is_admin();因此会出现一个结构性问题:
1. 后端增加统一权限模型
为 LLM tool 提供统一权限级别,例如:
member:所有用户可用;admin:仅 AstrBot 管理员可用;disabled:完全禁用,不向 LLM 暴露,也不可执行。2. 请求阶段过滤 tool schema
在 LLM 请求发出前,根据当前会话用户权限过滤 tools:
admintools 的 schema;disabledtools 不应对任何用户可见;3. 执行阶段二次兜底校验
即使请求阶段遗漏,或存在历史上下文残留 / 伪造 tool_call,也应在真正执行工具前再次检查权限:
admintool 时返回 permission denied;disabledtool 永远拒绝执行。4. WebUI 提供可编辑权限页面
希望在 WebUI 的工具管理页面中可以看到并修改每个 LLM tool 的权限,例如:
member/admin/disabled。并且这些配置应持久化到配置文件中,重启后仍然生效。
Use Case / 使用场景
在管理员使用tools的时候通过而在普通用户时返回没有这个权限,即无法使用对于tools
Willing to Submit PR? / 是否愿意提交PR?
Code of Conduct