Skip to content

[P0] 为 AI 写操作增加服务端审批与审计 #8

Description

@mahoshojoHCG

背景

系统提示词虽然要求模型在破坏性操作前确认,但服务端会直接执行模型发起的工具调用。manage_downloads 可以取消并删除文件,manage_feeds 可以删除订阅,manage_tasks 可以触发后台任务。仅依赖提示词不能防止误调用或提示注入。

相关代码:

  • Plugins/SecondDimensionWatcherReDive.Chat/ChatSystemPrompt.cs
  • Plugins/SecondDimensionWatcherReDive.Chat/ChatController.cs
  • Plugins/SecondDimensionWatcherReDive.Chat/Tools/ManageDownloadsTool.cs
  • Plugins/SecondDimensionWatcherReDive.Chat/Tools/ManageFeedsTool.cs
  • SecondDimensionWatcherReDive.Client/src/components/chat/ToolCallDisplay.tsx

目标

让所有 AI 变更操作经过服务端强制的“计划—批准—执行”流程。

建议范围

  • 为工具/action 标注 ReadOnly、Mutating、Destructive 风险级别。
  • 变更调用先创建 PendingAction,保存规范化参数、影响对象、风险、可逆性、用户/会话绑定和过期时间。
  • SSE 返回 approval_required,前端展示批准/拒绝卡片。
  • 批准后使用一次性幂等令牌执行。
  • 保存申请、批准、参数摘要、结果和错误审计记录。
  • 删除文件等高风险操作显示影响范围并要求二次确认。

验收标准

  • ReadOnly 工具可直接执行,Mutating/Destructive 工具不能绕过审批。
  • 待批准操作绑定当前用户、会话及精确参数,并会过期。
  • 重复提交批准令牌不会重复产生副作用。
  • 拒绝、过期、参数篡改和会话失效均不会执行工具。
  • 审计记录可查询且不保存敏感值。
  • 覆盖提示注入、并发批准、断线重连和重放攻击测试。

预估工作量:中高

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions