Skip to content

fix(codex): prevent timezone injection from bypassing Windows package activation - #96

Closed
matt1060338871-pixel wants to merge 1 commit into
BigStrongSun:mainfrom
matt1060338871-pixel:fix/windows-codex-package-activation
Closed

matt1060338871-pixel wants to merge 1 commit into
BigStrongSun:mainfrom
matt1060338871-pixel:fix/windows-codex-package-activation

Conversation

@matt1060338871-pixel

@matt1060338871-pixel matt1060338871-pixel commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

问题与已确认原因

CCSM 3.20.2-9 在 Windows 上开启 Codex 出口时区自动模式、且已有有效检测时区时,“刷新 Codex 状态”可能关闭 Codex 后无法重新打开,报 拒绝访问 (os error 5)

触发点是刷新流程的启动目标选择:select_launch_target 为传入进程级 TZ,在时区注入有效且 EXE 存在时优先选择 DesktopExecutable,绕过已经存在的 WindowsAumid 激活入口。关闭时区时则优先使用应用包激活。因此,同为 MSIX、同一 CCSM 版本,不同设置会走不同启动分支。

基线启动目标选择代码

两台机器对比与实际验证

项目 刷新失败机器 刷新正常机器
CCSM 3.20.2-9 3.20.2-9
Codex MSIX 包版本 26.901.6511.0 26.908.4834.0
出口时区模式 auto off
已保存检测时区 America/Los_Angeles America/Los_Angeles
Windows 25H2 / 26200.9168 25H2 / 26200.9445
  • 两台包目录和主 EXE 的安全描述符分别逐字一致:普通用户读取权限不包含执行权限;执行授权包含应用身份条件。没有证据支持“故障机器文件权限异常”。
  • 正常机器的只读 FILE_EXECUTE 权限检查也返回 Win32 错误 5;普通路径与 \\?\ 路径结果相同。此检查不创建进程。
  • 故障机器在正常 Windows 用户账户下冷启动实测:直接创建包内 EXE 进程返回错误 5;相同调试参数通过 IApplicationActivationManager::ActivateApplication 启动成功,CDP /json/version 可用。
  • 随后在故障机器关闭出口时区,用户确认同一刷新操作已恢复正常;读回配置确认 mode=off。无需更换 Codex 安装形式、重装或迁移历史数据。
  • 两台 Codex/Windows 版本不同,但故障机器仅关闭时区即恢复,结合对应分支代码,确认本次刷新故障由时区功能选择直接 EXE 启动触发。没有在正常机器开启时区制造反向故障。

关闭出口时区是本次刷新故障已验证的临时解决办法;不能据此保证所有启动入口恢复,因为模型兼容注入和随 CCSM 启动等入口在基线中仍直接创建 EXE 进程。

修复

已注册 MSIX 包统一使用 IApplicationActivationManager::ActivateApplication,时区设置不再将刷新启动切回直接 EXE。模型兼容注入和随 CCSM 启动的入口也复用包激活,保留请求的 CDP 端口和 origin 参数。

通过当前用户的包注册和 manifest 将选定 EXE 精确映射为 AUMID,兼容 Stable/Preview 共存、非 App Application ID、扩展长度路径和大小写差异。独立安装版继续直接启动;包注册查询错误在刷新关闭进程前返回。

时区行为与限制

应用包激活无法继承 CCSM 设置的子进程 TZ,因此不把进程时区标记为已应用。保留现有 CDP renderer 时区覆盖,并展示“仅支持页面时区同步”;app-server 进程时区不保证覆盖。此状态不会引导用户反复刷新,CCSM 重启后会从运行中的包路径重建状态。

代码验证

  • Windows GNU 隔离测试工程直接包含新增启动模块,并从修改后的源文件提取目标选择、参数和时区状态函数/测试:7 项通过,包含 Windows COM 绑定编译;不是完整 Tauri 构建。
  • CodexEgressTimezoneStatusCard.test.tsx:3 项通过,使用原配置的程序化 Vitest 入口。
  • tsc --noEmitcargo fmt --check、修改的 TS/TSX 文件 Prettier 检查、git diff --check 通过。
  • 已核对 Frontend CI 通过;macOS/Linux 后端在未修改的 proxy/handlers.rs 被基线已有的 clippy::too_many_arguments 阻塞,详见已有 CI 核对评论。完整 CI 状态以 Checks 为准。
  • 上述用户验证针对原安装版的故障、包激活及关闭时区后的恢复;修复版 CCSM 二进制的整条刷新、模型兼容层和历史查询端到端验证仍未完成。

…ation

Resolve the exact registered manifest application for all Desktop launch paths and preserve CDP arguments. Keep standalone launches unchanged and report package lookup failures before closing processes.

Represent MSIX timezone support as renderer-only, including after CCSM restarts, without prompting an ineffective refresh.

Validation: 7 Windows source-harness tests, 3 UI tests, TypeScript, rustfmt, Prettier and diff checks. User cold-start reproduction confirmed direct launch error 5 versus successful package activation and CDP. Full Tauri build remains for CI.

Copy link
Copy Markdown
Contributor Author

CI 核对:本 PR 的 Frontend Checks 已通过。macOS/Linux 后端均在未修改的 src-tauri/src/proxy/handlers.rs:3608,3667 被两处 clippy::too_many_arguments 阻塞,尚未执行后端测试。

已读取并对比基线 ab1b877 的 macOS CI 日志:错误类型和行号完全相同,该文件在本 PR 中无差异。基线证据:https://github.com/BigStrongSun/ccswitchmulti/actions/runs/34746243678/job/103694595762

Windows 后端仍在运行。新增启动模块已在本机 Windows GNU 隔离工程完成编译及相关测试;完整 CI 结果以本 PR Checks 为准。

@matt1060338871-pixel matt1060338871-pixel changed the title fix(codex): use registered MSIX activation for Windows Desktop launches fix(codex): prevent timezone injection from bypassing Windows package activation Sep 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant