Repository navigation
[bugfix] desktop: grant the renderer permissions the shell controls use - #458
Zhangbo-cn wants to merge 3 commits into
Conversation
wangtiance
left a comment
There was a problem hiding this comment.
已审阅 7c9f562 的权限处理、origin 校验、测试及冒烟检查变更。四项权限都经同一 allow list 与 ownedURL 校验,空值和非法 URL 会被拒绝;没有发现这些变更把权限直接开放给外部 origin 的问题。当前 head 的 14 项 GitHub 检查均成功。本轮为静态审阅,未在本机运行 Electron 或安装包。
有两点建议在合并前补齐:
- 明确记录 clipboard-read 的实际授权范围。它用于修复无用户激活的 writeText,但授权名称也涉及剪贴板读取;当前测试只证明写入成功,没有界定同 origin 下 readText 的行为。建议在真实 Electron 中增加 readText 探针,并在安全说明里准确记录读取是否也被允许,避免把策略描述成只有写入能力。
- GitHub 当前报告本分支存在合并冲突。同步 main 后应重跑新提交的检查,保留两种用户激活方式的剪贴板断言,并补 macOS/Windows 安装包结果及全屏进入/退出验证。现有 Windows 4/5 冒烟通过和独立权限探针不能替代同步后的跨平台安装包验收。
结论:修复路径有针对性,但当前证据还不足以作完整安装包验收或合并批准。
## summary - Replace the deny-all renderer permission handler with an explicit allow list limited to `opendirector://app`: the two clipboard names `navigator.clipboard.writeText` can request and the two fullscreen names `requestFullscreen` uses. - Grant by activation path, not by intent: a scripted write asks for `clipboard-read`, while the same write from a click asks for `clipboard-sanitized-write`, so a single name passes a scripted check and still leaves every copy button failing with `NotAllowedError`. - Scope grants by `details.requestingUrl` and the check handler's origin, and treat an empty or opaque origin as a denial instead of letting `new URL` throw. - Cover the shell policy in the installed smoke run: write from the renderer with and without user activation, then compare the system clipboard from the main process, polling because the renderer promise settles before the system clipboard holds the value. ## validation - Measured on Windows with Electron 45.3.3 against the real `opendirector://app` origin: the deny-all handler rejected the write with `NotAllowedError: Write permission denied.`; the allow list accepted both activation paths and the system clipboard held the written text. - `apps/desktop` `node --test tests/*.test.mjs`: 11 passed, 1 skipped (the packaged smoke needs a packaged runtime). - `node --check apps/desktop/scripts/smoke-window.mjs`. - `npm test`: 952 passed. `npm run check:i18n`: 0 problems. Refs: ThinkFlowLab#397
## summary - The installed run failed with only "did not reach the system clipboard", which does not distinguish a denied write from a read that arrived before Windows handed the clipboard over. - Poll the read instead of taking one sample, and include the observed value in the failure, so the next packaged failure names the cause. ## verification - Packaged Windows build (win-unpacked, Electron 45.3.3): the scripted and the click-activated write both reach the system clipboard before the smoke moves on. The run then stops at the trace-window step, which reproduces with the previous deny-all handler as well and is unrelated to renderer permissions.
…ks for Chromium reports a scripted clipboard write as `clipboard-read`, which is the same permission that opens `navigator.clipboard.readText`. Granting it kept the scripted smoke write green and handed the page the ability to read the system clipboard, a capability the shared UI never uses. Grant `clipboard-sanitized-write` only, the name a click-activated copy asks for, and assert the rest of the policy where it runs: a write without user activation and a `readText` are refused with NotAllowedError, a click-activated copy reaches the system clipboard and gives the previous text back, and a fullscreen request settles, enters and exits rather than staying pending. Measured in Electron 45.3.3 on Windows with a deny-all handler, this policy and a grant-all handler: deny-all rejects the click write and leaves `requestFullscreen` pending, which are the two reported failures; grant-all lets the page read back the text a scripted write stored; this policy refuses both scripted calls and keeps the click path working.
7c9f562 to
f7dcd6e
Compare
|
谢谢审阅,两点都取了。已 rebase 到当前 main( 1. 同意这条是问题:Chromium 把「无用户激活的 writeText」报成
第三行就是「授权名称必须按能力而不是按调用看」的证据:全放开时,页面能读回脚本写入留下的文本。记录到的权限流是 安全说明已按实测改写: 2. 冒烟断言与全屏验证。 「保留两种用户激活方式的剪贴板断言」保留了,但对两条的期望值不同:点击激活的写入断言成功并核对系统剪贴板,无激活写入断言 新增 仍然缺的证据,先说清楚:
结论我同意你的判断:这是修对了方向、但安装包级证据还不足的程度。合并前还差发布流水线那两次运行的结果。 |
wangtiance
left a comment
There was a problem hiding this comment.
已复核 f7dcd6e 中对上轮意见的调整。clipboard-read 已从 allow list 移除,点击触发的 clipboard-sanitized-write 保留;新增断言分别检查无激活写入被拒且剪贴板不变、readText 被拒、点击写入成功,以及全屏进入和退出。这个方向解决了上轮提出的读取能力扩大问题;“保留两种激活断言”不要求两种都成功,现在按产品实际需求分别断言允许和拒绝是合适的。
作者提供的三种策略对照探针把开发版 Electron 的结果和安装包证据分开,更新后的说明也不再用 TypeScript 检查替代 .mjs 覆盖。当前 f7dcd6e 的 14 项 GitHub 检查均已成功。
本轮没有在复核的权限模块和新增断言中发现新的阻塞缺陷。安装包层面的 macOS 与 Windows 剪贴板、全屏验证仍以 PR 中列出的待办为准:旧提交的 4/5 冒烟结果不计作本提交验收,源码 CI 全绿也不替代发布作业结果。本轮只做远程静态复核,未运行本地 Electron,未批准或执行合并。
|
@wangtiance — I checked your latest review against the head, and I can close one of the two open items with a real measurement on Windows, plus one small nit. 1. The earlier "merge conflict" note no longer applies. 2.
Recorded permission stream for those calls, every Boundary, stated plainly: this is an Electron probe on the branch's policy module, not a packaged 3. One nit worth taking before merge. In Electron 45 the main-process I am not asking to merge. As far as I can see the remaining gate is the packaged Windows + macOS run, and the code itself needs only the |
Summary
opendirector://app:clipboard-sanitized-write,fullscreen,automatic-fullscreen. Every other renderer permission stays denied.clipboard-sanitized-writeis the name a click-activatednavigator.clipboard.writeTextrequests. The read/write clipboard name (clipboard-read) stays denied because it also opensnavigator.clipboard.readText, and every copy in the shared UI starts from a click: measured below, granting it lets the page read back the text a scripted write stored.fullscreenorautomatic-fullscreenleavesrequestFullscreen's promise unsettled, so the media player's fullscreen button does nothing and no.catchruns.details.requestingUrland by the check handler's origin. An origin outsideopendirector://app, including an empty or unparsable one, is a denial rather than a thrownTypeError.readTextmust be refused withNotAllowedErrorwithout touching the clipboard, and a fullscreen request must settle, enter and exit.Linked issue
Labels
type:bug,area:desktopTest plan
apps/desktop→node --test tests/*.test.mjs: 11 pass, 1 skipped (the skip needs the packaged runtime). The policy test pins the granted names, the denied clipboard read, and the origins that must stay denied, includingopendirector://appwithout a path as the check handler serializes it.node scripts/check-i18n.mjs: 3341 keys, 0 problems.check-browser-manifest.mjs: 92 entries OK.check-browser-locale.mjs: 86 pages, 0 problems.opendirector://app/origin, the probe imports this branch'spermissions.mjs, and the handler wiring matchesmain.mjs. The same build was measured under three policies, one process each:readTextrequestFullscreenNotAllowedErrorNotAllowedErrorNotAllowedError(the reported bug)fullscreenElementnone (the reported bug)NotAllowedError, clipboard unchangedNotAllowedErrorprobe-clickedprobe-scriptedprobe-scriptedclipboard-read(scripted write),clipboard-read(readText),clipboard-sanitized-write(click write),automatic-fullscreen(check),fullscreen(request); every requesting URL wasopendirector://app/.npm run prepare:runtime+npm run pack, thennode scripts/smoke.mjs ...\win-unpacked\OpenDirector.exe. 4 of 5 runs passed with the previous allow list, including both clipboard assertions. The failures were later steps —Project search shortcutin one run, the trace-window step in another — and reproduced with the deny-all handler as well, so they are not permission failures.Evidence that it works
Boundaries this change does not cross.
.mjsis outside the TypeScript check, so a cleantsc --noEmitsays nothing aboutpermissions.mjs,main.mjsor the smoke script, and this PR does not claim it as coverage. The permission names and the activation split come from Chromium's permission code, which is shared by platform, but the system clipboard and window server of macOS and of the installed Windows build are unmeasured here; the new clipboard and fullscreen assertions are first exercised in the release jobs. The fullscreen sequence has run in the Windows probe above, not yet inside a packaged smoke run.Provider verification
Bilingual UI