🔒 全面加固跨世界 GM RPC、用户脚本与 Agent 边界 - #1747
Open
cyfung1031 wants to merge 104 commits into
Open
cyfung1031 wants to merge 104 commits into
cyfung1031 wants to merge 104 commits into
Conversation
cyfung1031
marked this pull request as draft
September 16, 2026 23:03
Bind USER_SCRIPT bootstrap data to the service-worker-issued document token, preserve sender provenance, and enforce per-execution GM capabilities across page RPC and native message paths. Harden captured collection operations and exact-match early startup handling.
3 tasks
说明原生方法捕获、USER_SCRIPT 来源校验、页面 RPC 句柄生命周期、脚本包装完整性和回调收尾约束,降低后续维护时误改安全契约的风险。
Replace replay-cap loops with constant-time full-state invariant checks and enforce a 40-second E2E budget across Playwright configuration, helper waits, and CI. Make retry helpers side-effect bounded and preserve failure logs while closing pages on all paths.
Keep CI and helper timeout behavior outside this PR. Retain the constant-time replay invariant tests while restoring the existing E2E configuration and retry semantics.
cyfung1031
marked this pull request as ready for review
September 19, 2026 06:53
cyfung1031
marked this pull request as draft
September 19, 2026 07:09
Collaborator
Author
|
|
cyfung1031
marked this pull request as ready for review
September 19, 2026 07:20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist / 检查清单
背景
本 PR 系统性加固跨世界 GM API、MAIN world、USER_SCRIPT、Service Worker、Offscreen、Sandbox 与 Agent/CAT API 的边界。原实现中,部分请求依赖页面可观察的 DOM 通道、可变对象或跨上下文全局状态,存在请求伪造与重放、旧文档错配、accessor/proxy 执行、值和附件越权、异步请求悬挂,以及监听器和连接泄漏等风险。
当前 PR 目标分支为
main(live ref249e2fc31896d6a00ce9425e0a31bcccdc475b2e);PR API 的 base OID 与当前 diff merge-base 均为0eeeb5d12a1c87b94aa9b31a94e035422f497ad1,head 为5b07c7e00321e54ae77c2230971e57b230ffe883,涉及 95 个文件。变更总览
__proto__污染、跨脚本附件读取和跨 realm live object 泄露structuredClone,避免创建绑定包装器;减少重复 collection factory、反射和回调扫描;补充安全边界注释并同步架构文档生产代码用法统计
249e2fc31896d6a00ce9425e0a31bcccdc475b2e)5b07c7e00321e54ae77c2230971e57b230ffe883).bind属性引用 / 直接调用.call属性引用 / 直接调用.apply属性引用 / 直接调用new Mapnew Setfor...offor...of.forEach.forEach统计扫描 main 的 654 个和 PR 的 658 个 tracked TypeScript/JavaScript 源文件;排除测试、E2E、fixture/mock、benchmark、生成文件和依赖/构建目录。
.bind、.call、.apply先列属性引用数,再列直接调用数;.apply包含Reflect.apply。Map/Set 相关行按类型识别 Map/ReadonlyMap/MapIterator 与 Set 对应类型。实现考虑
已知限制
passed:-1, failed:-1);该次运行早于最终 guard,当前 head 未重跑。当前 head 的 hosted E2E shards 均通过,这不能替代该本地路径的复测。5b07c7e00321e54ae77c2230971e57b230ffe883的 GitHub Actions run 35427222270 中,Lint、两个测试 shard、聚合测试和四个 E2E shard 均通过;FOSSA License Compliance 尚无结果。建议审查重点
__proto__、不可 clone 值和 live Document 是否不会进入特权服务验证
main249e2fc31896d6a00ce9425e0a31bcccdc475b2e/ merge-base0eeeb5d12a1c87b94aa9b31a94e035422f497ad1→ head5b07c7e00321e54ae77c2230971e57b230ffe883;95 个文件pnpm exec vitest run packages/message --reporter=dot;6 files, 76 tests passedpnpm exec eslint packages/message/window_message.ts packages/message/page_message.ts;passedpnpm exec prettier --check packages/message/window_message.ts packages/message/page_message.ts;passedpnpm exec vitest run packages/message src/app/service/content/utils.test.ts src/app/service/content/page_rpc.test.ts src/pkg/utils/script_compat.test.ts --reporter=dot;9 files, 189 tests passedpnpm exec eslint src/app/service/content/global.ts、pnpm exec prettier --check src/app/service/content/global.ts、pnpm typecheck和pnpm build;passed,build 有 4 个既有 bundle-size/Monaco warningsstructuredClone微基准pnpm exec vitest run src/app/service/agent/service_worker/dom_cdp.test.ts src/app/service/agent/service_worker/dom.test.ts --reporter=dot;42 tests passedpnpm run typecheck;passedpnpm exec eslint src/app/service/agent/service_worker/dom_cdp.ts src/app/service/agent/service_worker/dom_cdp.test.ts;passedpnpm exec prettier --check src/app/service/agent/service_worker/dom_cdp.ts src/app/service/agent/service_worker/dom_cdp.test.ts;passedpnpm build;passed,保留已有 bundle-size/Monaco warningsgit ls-remote与 head SHA5b07c7e00321e54ae77c2230971e57b230ffe883一致