Skip to content

加固 Browser/Chrome/Computer Use 内置插件保护 / Harden bundled Browser, Chrome and Computer Use protection#1537

Open
Yuimi-chaya wants to merge 3 commits into
BigPizzaV3:mainfrom
Yuimi-chaya:codex/bundled-plugin-guard-v3
Open

加固 Browser/Chrome/Computer Use 内置插件保护 / Harden bundled Browser, Chrome and Computer Use protection#1537
Yuimi-chaya wants to merge 3 commits into
BigPizzaV3:mainfrom
Yuimi-chaya:codex/bundled-plugin-guard-v3

Conversation

@Yuimi-chaya

Copy link
Copy Markdown
Contributor

中文

为什么需要这个改动

Codex++ 目前已经有插件市场解锁和 Computer Use Guard,能够准备部分本地配置、缓存与运行环境。但这些保护主要针对既有的初始化路径和 Computer Use。随着 Codex App 持续更新并整合进 ChatGPT Desktop,openai-bundled 市场、插件可用状态和浏览器能力会在启动及供应商切换期间被异步刷新,已经完成的本地修复可能再次被后到的官方状态覆盖。

这不是重复实现原有保护,而是补上它面对新版异步刷新时缺少的持续一致性。对以 API Key 和第三方 URL 使用 Codex App 的用户而言,如果 Browser、Chrome 或 Computer Use 在切换供应商后重新变成不可用,就会再次依赖联网、VPN 或手动刷新来恢复,与 Codex++ 降低接入成本的目标相冲突。

真实遇到的竞态

真人测试中曾观察到:从 Codex++ 启动后立即打开“设置 -> 浏览器”,页面会先显示“内置浏览器使用”;下一瞬间又变为“应用内浏览器不可用”。继续等待时,它还可能自行恢复,几秒后又再次消失。

这说明问题并非简单的“插件没有安装”,而是 Codex 原生异步初始化、openai-bundled 市场响应与 Codex++ 本地保护之间存在时序竞争。只在启动时修一次配置,无法保证稍后的官方刷新不会把状态覆盖回去。

本 PR 做了什么

  • 将 Browser、Chrome、Computer Use 纳入统一的 bundled plugin guard,并在完整增强模式的插件市场解锁场景中自动启用保护。
  • 保留“Codex 增强 -> 界面与启动 -> 强制启用 Windows Computer Use Guard”开关,供其他运行模式显式触发同一套保护。
  • 在启动、供应商切换和配置写入后的相关流程中重新检查并修复 bundled marketplace、插件启用状态、Computer Use 配置及必要的本地状态。
  • 从本地 bundled marketplace 缓存构造稳定快照,并在 renderer 收到暂时缺项的官方响应时,只补回缺失的 Browser、Chrome、Computer Use。
  • openai-bundled 快照再次执行三项白名单过滤,避免过期缓存恢复 Latex、Visualize 或未来出现的无关官方插件。
  • 保留官方响应中已经存在的插件和字段,不重复插入,不把本地快照当作完整官方市场替代品。
  • 避免无实际操作时周期性写入 plugin_auto_expand_finished 诊断,减少启动保护过程中的无效日志写盘。

兼容边界

本 PR 不修改 Codex App 的 MSIX/ASAR,也不修改用户安装的插件包。它增强的是 Codex++ 启动、供应商切换、缓存恢复和 renderer 合并路径。

如果未来 Codex App 在 ASAR 内新增更强的组织、地区或账号门控,本地状态保护仍不保证能够 100% 绕过;届时需要针对新的原生门控单独评估。本 PR 也不会恢复白名单之外的所有历史 bundled 插件。

验证

  • 已在真实 Windows Codex App 环境中进行启动和供应商切换测试,观察到 Browser、Chrome、Computer Use 状态能够恢复,Browser 设置页不再持续停留在竞态产生的不可用状态。
  • npm run check
  • bundled marketplace focused tests: 2/2
  • plugin/CDP tests: 15/15
  • launcher tests: 71/71
  • relay config tests: 101/101
  • relay switch tests: 5/5
  • node --check assets/inject/renderer-inject.js
  • cargo fmt --all -- --check
  • git diff --check

English

Why this change is needed

Codex++ already provides plugin marketplace unlocking and a Computer Use Guard that prepares part of the local configuration, cache, and runtime environment. Those protections, however, were designed around earlier initialization paths and were primarily focused on Computer Use. As Codex App continues to change and becomes integrated into ChatGPT Desktop, the openai-bundled marketplace, plugin availability, and browser capability are refreshed asynchronously during startup and provider switching. A local repair that has already succeeded can therefore be overwritten by a later native refresh.

This PR does not duplicate the existing guard. It extends that guard so bundled tool state remains coherent across newer asynchronous refresh paths. This matters especially to API-key and custom-URL users: if Browser, Chrome, or Computer Use becomes unavailable again after a provider switch, users may once more need external connectivity, a VPN, or manual refreshes to recover it.

Observed Browser race

During real-user testing, opening Settings -> Browser immediately after launching through Codex++ could first show the in-app Browser control, then switch to “in-app browser unavailable” a moment later. It could recover by itself after waiting, only to disappear again several seconds later.

This behavior indicates a timing race between native Codex initialization, asynchronous openai-bundled responses, and the Codex++ local guard. A one-time configuration repair at startup is not sufficient when a later native refresh can replace the repaired state.

What this PR changes

  • Protects Browser, Chrome, and Computer Use through one bundled-plugin guard, automatically enabled by plugin marketplace unlock in full enhancement mode.
  • Keeps the explicit Codex Enhancements -> Interface & Startup -> Force-enable Windows Computer Use Guard option for other modes.
  • Rechecks and repairs the bundled marketplace, enabled plugin state, Computer Use configuration, and required local state across startup, provider switching, and related configuration writes.
  • Builds a stable snapshot from the local bundled marketplace cache and restores only missing Browser, Chrome, and Computer Use entries when a native response is temporarily incomplete.
  • Applies the same three-plugin allowlist again in the renderer so stale caches cannot restore unrelated bundled plugins such as Latex or Visualize.
  • Preserves official entries and fields that are already present, avoids duplicates, and does not treat the local snapshot as a full replacement for the official marketplace.
  • Stops periodic no-op plugin_auto_expand_finished diagnostics, reducing unnecessary log writes during plugin protection cycles.

Compatibility boundary

This PR does not modify the Codex App MSIX/ASAR or any installed plugin package. It strengthens the Codex++ startup, provider-switch, cache-recovery, and renderer-merge paths.

If a future Codex App release introduces stronger organization, region, or account gates inside its ASAR, local state recovery still cannot guarantee a complete bypass. Such native gates require separate investigation. This PR also intentionally does not preserve every historical bundled plugin outside the three-item allowlist.

Validation

  • Human-tested on a real Windows Codex App installation across startup and provider switching. Browser, Chrome, and Computer Use recovered, and the Browser settings page no longer remained stuck in the unavailable state produced by the observed race.
  • npm run check
  • bundled marketplace focused tests: 2/2
  • plugin/CDP tests: 15/15
  • launcher tests: 71/71
  • relay config tests: 101/101
  • relay switch tests: 5/5
  • node --check assets/inject/renderer-inject.js
  • cargo fmt --all -- --check
  • git diff --check

@Yuimi-chaya
Yuimi-chaya marked this pull request as ready for review July 16, 2026 13:21
@Yuimi-chaya
Yuimi-chaya marked this pull request as draft July 16, 2026 13:39
@Yuimi-chaya
Yuimi-chaya marked this pull request as ready for review July 16, 2026 14:25
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.

1 participant