Skip to content

[REQ-096] HTML 产物在零桥接隔离宿主中静态预览 #208

Description

@jinjunnn

简明目的

HTML 文件可以看,但只能当作不可信静态内容:不能联网、不能调用 Alpha、不能留下可复用的浏览器状态。

Outcome(专业定义)

不可信 HTML artifact 经有界 worker sanitization 后,在 main-owned、短生命周期、独立 partition 的静态 preview host 中显示;宿主具备零 preload bridge、零 Node/Electron capability、零网络出口和完整导航/权限拒绝策略。核心隔离已存在,剩余工作是消除 main 同步读取、保证异常清理,并用恶意 packaged matrix 证明零出口/零桥接。

Complexity

L — 直接处理主动内容与 Electron 进程隔离,属于高风险安全 surface。

Context

#188 已交付核心 host;当前仍可能在 main 同步读取大内容、清理 storage 失败被吞掉,且缺少完整 malicious/packaged 证据。#299/#300 只覆盖 worker bound 和阻断提示,不能单独证明完整隔离。

Scope

  • 在有界 worker 中解析/sanitize HTML,提供 timeout、取消和 crash recovery。
  • 为每次预览创建 main-owned 静态 host/partition,并在关闭、崩溃、切换时可靠销毁。
  • 强制无 preload、nodeIntegration=false、context isolation/sandbox 与零 Electron bridge。
  • 拒绝网络、导航、redirect、popup、外部协议、permission、download/upload 与持久化 storage。
  • 以异步、有界 descriptor stream 读取内容,不阻塞 Electron main。
  • 明确显示被阻断资源和“复制链接到系统浏览器”等用户动作。

Non-goals

  • 不实现交互式浏览器、登录、表单自动化、持久 profile 或 CDP;见 [REQ-106] 用户可安全接管隔离的交互式浏览器会话 #213。
  • 不复用旧 preview URL、partition、savedPath、file URL 或主窗口 9222。
  • 不执行 artifact JavaScript、宏、service worker 或 extension bridge。
  • 不兼容旧 HTML host/storage;当前没有既有用户。

Acceptance criteria

AC1. HTML 只在独立沙箱预览进程内解析,应用界面进程不接触 HTML 内容;根文档有大小上限,超限拒绝并说明。 (2026-09-17 按 owner 裁决改写,原文见编辑历史)
AC2. 每次预览使用隔离、短生命周期的 main-owned host;关闭、切换或 crash 后 partition/storage/cache 不可恢复。
AC3. host 无 preload、Node/Electron API 或 Alpha IPC bridge,页面无法枚举/控制主窗口或其它 preview。
AC4. 所有网络、redirect、popup、外部协议、权限、download/upload、service worker 与持久 storage 默认拒绝。
AC5. main 通过异步有界 descriptor stream 读取;大 HTML、慢盘和取消不会阻塞应用事件循环。 —— 2026-09-17 删除(owner 裁决):读前已校验大小、单文件有上限,上限内的一次同步读取不产生用户可观察的卡顿;大小上限已并入 AC1。
AC6. 被删除/阻断资源、sanitize 结果与失败原因诚实显示,系统浏览器动作需要显式用户操作。
AC7. 每次预览使用独一份、不可复用的存储分区;关闭时清理,残留在下次启动时清除。 (2026-09-17 按 owner 裁决改写,原文见编辑历史)
AC8. 恶意 HTML 夹具下,预览保持零网络出口、零应用桥接、零跨预览存储(由隔离宿主行为测试判定;打包态冒烟随每个 Release Candidate 的清单执行)。 (2026-09-17 按 owner 裁决改写,原文见编辑历史)

Evidence map

AC Evidence surface
AC1 #299(机制被取代)ArtifactHtmlPreview.tsx:3-4 + html-preview-host.ts:68/:319
AC2 html-preview-host.ts:15 + rail-preview-host.ts:127-150
AC3 html-preview-host.test.ts(精确 24 条,scripts/gate-files.tsv:253)
AC4 html-preview-host.test.ts(同上)
AC5 已删除(见 AC5)
AC6 #300、#907 artifact-html-preview.test.ts(gate-files.tsv:254)
AC7 html-preview-host.ts:15/:324 + rail-preview-host.ts:127-150
AC8 html-preview-host.test.ts 24 条 + 每个 RC 的 packaged checklist

Acceptance owner

@jinjunnn — 按 AC 逐条验收并手工关闭;PR 不得关闭父需求。

设计要点

  • sanitize 不是唯一边界;即使 sanitizer 漏洞存在,宿主仍须零网络、零 bridge。
  • partition 标识不可从 artifact 输入派生或跨预览复用。
  • main 线程不做同步大文件读取/解析。
  • cleanup 失败需要 quarantine/新 partition,而不是 best-effort 吞错。

潜在问题与风险

过时性与兼容性结论

需求有效且核心隔离已部分实现。旧 preview URL/partition/storage、savedPath 和主窗口调试端口复用均直接删除。保留异常清理、取消、崩溃恢复与未来不认识内容 fail-closed。

关联与职责边界

Delivery plan / 建议子票

Dependencies

Activity

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

Metadata

Metadata

Assignees

Labels

area:productUser-facing product behaviorarea:runtimeServices, jobs, infrastructure, or operationsarea:securitySecurity or access controltype:requirementA product or cross-repository outcome

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions