Skip to content

docs(plugins): align plugin security doc with egress and grant code - #2025

Merged
vastsa merged 2 commits into
vastsa:mainfrom
zszz3:docs/plugin-security-audit
Oct 31, 2026
Merged

vastsa merged 2 commits into
vastsa:mainfrom
zszz3:docs/plugin-security-audit

Conversation

@zszz3

@zszz3 zszz3 commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Related to #2000

P1 第 4 项:04-plugin-security.md 的 sandbox / partition / egress 部分对照实现。只改文档,中英文成对。

检查的文档

  • docs/spec/07-plugins/04-plugin-security.md(重点 §3、§8.0、§8.1、§11)
  • docs/zh-CN/spec/07-plugins/04-plugin-security.md

对照的代码

已核对一致

  • 面板与视图均为 contextIsolation: true、nodeIntegration: false、sandbox: true(panel、view);面板 setWindowOpenHandler → deny。
  • 插件主进程为每插件一个 utilityProcess,环境变量来自 minimalChildEnv,与 §11 第 7 条一致;§11 “Not enforced yet” 中关于 Node 内置模块可达的说明与 plugin-host-process.mjs 一致。
  • net.anyHost 下云元数据主机仍被拒绝(net-policy.ts#L25-L27);MCP 最多 5 跳;websocket 4 个 / 1 MiB。

发现与修改

# 文档原文 代码实际 修改
1 §8.0 面板 session “refuses every device permission” 持有 ui.microphone 时放行纯音频 media 请求(plugin-panel-host.ts#L140-L153) 写明这一例外并指向 §8.2
2 §8.0 未说明 partition 形态 每插件一个持久化分区 persist:pi-plugin-<id>,面板窗口与停靠视图共用,都调用 applyPluginEgressPolicy;file:/data:/blob:/devtools:/chrome-extension:/主题资源 scheme 直接放行(L70-L77) 补充说明
3 §8.0 “a bare * is refused at install” 拒绝发生在 parseNetDomains(经 validateManifest),即 pi-plugin check 与宿主 加载时;host-core PluginManifest 不读取 net,市场安装后在 loadFromPath 才失败 按实际描述
4 §11 “Declared manifest permissions are auto-granted at load time, subject to the user unchecking them at install” 安装审核没有逐项开关;授权缺少任何声明权限时安装器报 PLUGIN_PERMISSION_DENIED: missing grant for …;无记录授权时 加载取声明集合 改为“整体授予”并写明行为
5 §11 “net.websocket is implemented … (§8.1)” websocket 在 §8.0,§8.1 是 MCP 改为 §8.0
6 zh §8.0 pi.net.fetch 仍写“Electron 主进程不提供任何替代的 fetch 服务” 英文版已更新为共享逐跳循环 + redirect: "error" / "manual" 模式 zh 按英文同步

发现但未在本 PR 处理

  • zh 文末 “Fetch redirect policy” 一节仍是英文,属于 P0 翻译问题。

验证

  • git diff --check 通过
  • 未改标题;新加的 §8.0、§8.2 引用与 zh 03-plugin-api#网 锚点均指向现有章节
  • 分支基于 upstream/main c85251b

The security spec said a bare "*" in net.domains is refused at install
and that users can uncheck declared permissions at install. Neither
holds: the host-core installer does not read net.domains, so the
refusal happens in validateManifest at check and load time, and the
installer refuses any grant that omits a declared permission. The
panel-session bullet also missed the ui.microphone exception and the
per-plugin persisted partition shared by panels and views, and the
zh-CN fetch bullet still described a pre-redirect-mode design.

Correct those statements in both the English and zh-CN documents.

Related to vastsa#2000

@vastsa vastsa left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已独立对照 applyPluginEgressPolicy、pluginSessionPartition、PluginViewHost、parseNetDomains / validateManifest、Rust PluginManifest / installer 和 loadFromPath。麦克风例外、共享持久分区、本地 scheme 放行、裸通配符的校验时机、整体授权及 websocket 引用均符合当前实现,中文 fetch 重定向说明与英文一致,未发现阻塞问题。

最新 main:f0cdf590bb7918d0611e28372196bbb0a6d04888;已验证的 GitHub 合并候选:19231fb5459b41c44bf64f2b80bb17f4f8e689e7。diff --check、base ancestry、86 组中英配对、599 个文档页面、agent-policy sync、VitePress 生产构建及 GitHub Docs checks / Head contains latest base 全部通过。仅文档改动,应用 E2E 不适用。

@vastsa
vastsa merged commit bdc7472 into vastsa:main Oct 31, 2026
2 checks passed
@Tioit-Wang

Copy link
Copy Markdown
Collaborator

Merged. Thanks!

Auditing egress, partition, and sandbox claims against the actual isolation code is the part of #2000 that is easiest to get wrong, and the paired English/Chinese edits kept the gap from widening. This also complemented #2005, which filled the missing Chinese sections in the same file — the two did not collide.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants