fix(desktop): allow localhost browser previews - #2445
Conversation
Signed-off-by: yuaiccc <yuaiccc@aliyun.com>
|
| Filename | Overview |
|---|---|
| apps/desktop/src/main/mcp-integrations/browser-managed-config.ts | 为受管浏览器新增 localhost 主机名例外;已有线程指出的无限制本地服务访问仍未解决。 |
| apps/desktop/src/main/mcp-integrations/tests/browserManagedConfig.test.ts | 更新配置生成测试,断言 localhost 与 fake-IP 例外同时存在。 |
| packages/browser-control-runtime/src/tests/runtime-config-application.test.ts | 更新 vendored 配置解析测试,确认新增 SSRF 字段不会在解析过程中丢失。 |
Reviews (2): Last reviewed commit: "chore: complete PR description per forma..." | Re-trigger Greptile
| ssrfPolicy: { | ||
| allowRfc2544BenchmarkRange: true, | ||
| allowIpv6UniqueLocalRange: true, | ||
| allowedHostnames: ['localhost'], |
There was a problem hiding this comment.
Unrestricted localhost service access
When an agent navigates to http://localhost:<arbitrary-port>/, this hostname-wide exemption skips the normal loopback rejection, causing every HTTP service bound to localhost—not only the intended preview server—to become reachable. How this was verified: The browser navigation path applies allowedHostnames, which bypasses loopback rejection, and the checked guards contain no port or service restriction.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop/src/main/mcp-integrations/browser-managed-config.ts
Line: 80
Comment:
**Unrestricted localhost service access**
When an agent navigates to `http://localhost:<arbitrary-port>/`, this hostname-wide exemption skips the normal loopback rejection, causing every HTTP service bound to localhost—not only the intended preview server—to become reachable. **How this was verified:** The browser navigation path applies `allowedHostnames`, which bypasses loopback rejection, and the checked guards contain no port or service restriction.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
MagicLizi
left a comment
There was a problem hiding this comment.
格式检查未通过
请补充 PR Description 的必要段落:
- 这次改了什么:说明允许 localhost browser previews 的具体改动和范围
- 怎么验证的:说明测试覆盖和验证方式
- 风险:评估放宽 localhost 访问的安全影响
另外 CI 当前失败(Windows unit tests / client-ci / Greptile Review),请一并修复。
修完描述和 CI 后 push 即可触发重新审查。
|
@yuaiccc 👋 这个 PR 还有 1 条 review conversation 没 resolve(apps/desktop/src/main/mcp-integrations/browser-managed-config.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。 如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。 |
…t flake Signed-off-by: yuaiccc <yuaiccc@aliyun.com>
这次改了什么
摘要
在 browser managed config 的 SSRF policy 中新增
allowedHostnames: ['localhost'],使受管浏览器预览能打开开发者的本地 web 应用。这是 hostname 级例外(非原始 loopback IP、非 RFC1918/LAN),沿用既有 SSRF guard;fake-IP 代理范围、metadata、link-local 等仍被拦截。同步更新 managed config 与 vendored config 解析的相关测试。变更类型
feat新功能fix缺陷修复refactor/perf重构或性能优化docs/test/chore文档、测试或工程维护范围
buildManagedConfig()的ssrfPolicy增加allowedHostnames: ['localhost'];更新 SSRF 策略注释说明;browserManagedConfig.test.ts与runtime-config-application.test.ts断言 localhost 例外与既有 fake-IP 例外并存。127.0.0.1/::1原始 IP、RFC1918/LAN、metadata、link-local;不改变 page-contextevaluate的既有残余风险边界。http://localhost:*的本地预览。UI 变化
不涉及:仅改主进程 SSRF 策略配置,无 renderer / 视觉 / 交互 / 文案变化。
怎么验证的
自动验证
手工验证
不涉及:策略由单测覆盖,无 UI 手工路径。
未执行的验证
本次未本地复跑单测,依赖 CI 重跑确认。CI 此前在 Windows unit tests 上失败,需以重跑结果为准。
风险
风险分类
影响与回滚
localhost,不放行127.0.0.1/::1原始 IP 或 RFC1918/LAN,故不会让 agent 经由浏览器触达内网。page-contextevaluate的残余风险(Chromium 网络栈不经 Node SSRF guard)为既有约束,已在注释中说明,本 PR 不改变该边界。allowedHostnames: ['localhost']即恢复完全拦截 localhost。提交前检查