Skip to content

fix(windows): avoid unspawnable Deep Scan launchers - #367

Open
kmbroai wants to merge 1 commit into
mainfrom
dev/kyleb/windows-deep-scan-launcher
Open

fix(windows): avoid unspawnable Deep Scan launchers#367
kmbroai wants to merge 1 commit into
mainfrom
dev/kyleb/windows-deep-scan-launcher

Conversation

@kmbroai

@kmbroai kmbroai commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Normalize CODEX_CLI_PATH at the nested Deep Scan MCP environment boundary.
  • On Windows, preserve explicit direct executables while rejecting extensionless npm shims, .cmd shims that require a shell, and protected WindowsApps binaries.
  • Fall back to the existing resolveCodexCommand() platform-binary resolver instead of adding another launcher resolver.

Root cause

Deep Scan workers inherit CODEX_CLI_PATH through the plugin MCP environment. Before this change, any non-empty value bypassed the canonical npm platform-binary resolver. On Windows that value can be the extensionless npm shim or a protected MSIX WindowsApps executable; CodexExec passes it directly to child_process.spawn without a shell, which can fail with spawn EPERM even when the installed @openai/codex platform package contains a valid executable.

This keeps case-insensitive Windows environment propagation intact, preserves explicit spawnable .exe / .com launchers, and uses the existing bundled platform executable when the inherited value cannot be launched.

Related: CLI-18410, codex#35872.

Validation

  • bun test tests-ts/runtime.test.ts --test-name-pattern 'bundled Codex through|explicit Codex executable override|spawnable Windows' — 3 passed
  • pnpm run types
  • pnpm run build
  • pnpm run format
  • pnpm pack --pack-destination ../../dist
  • pnpm run test:package — validated the installed package and a nested worker without global codex
  • Native prepublish review gate: 3 independent passes plus verifier; 0 findings

The full runtime.test.ts module was also attempted, but this host reports / and /home as UID 65534, so 24 unrelated trusted-owner tests fail closed. The launcher-focused tests and package smoke pass without weakening those checks.

@kmbroai kmbroai changed the title [codex-security] Avoid unspawnable Windows Deep Scan launchers fix(windows): avoid unspawnable Deep Scan launchers Aug 12, 2026
@github-actions github-actions Bot added the bug Something isn't working label Aug 12, 2026

@ting-hong-shieh ting-hong-shieh left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I validated exact head 8eb9493d and a conflict-resolved replay of its single commit onto current main at 216212b7.

The exact head passes the three focused launcher tests (11 assertions), generated-model check, TypeScript check, build, Prettier, and whitespace check. The replay passes the four focused launcher tests inherited from the PR and current main (15 assertions), generated-model check, TypeScript check, build, Prettier, and whitespace check.

The replay also exposes one relative-path regression that the existing tests do not cover. The inline note includes the reproduction and a tested fix direction. These were local unit and static checks on macOS; I did not run a native Windows process or use credentials or an external API.

): string {
const configured = environmentValue(environment, "CODEX_CLI_PATH");
if (configured !== undefined && isSpawnableCodexPath(configured, platform)) {
return configured;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please preserve current main's absolute-path normalization when resolving this conflict. pluginExecutionEnvironment() now delegates to resolveCodexCommand(environment), which turns a relative CODEX_CLI_PATH into an absolute path before passing it to a nested worker. This helper instead returns the trimmed relative value unchanged on non-Windows platforms, and does the same for a relative .exe or .com path on Windows. The worker can then resolve that value from a different working directory and fail to launch Codex.

On the conflict-resolved replay at 216212b7, resolveNestedCodexPath({ CODEX_CLI_PATH: "./bin/codex" }, "linux") returned "./bin/codex" instead of resolve("./bin/codex"). Normalizing an accepted override with the platform-specific path resolver made this reproduction and all four focused launcher tests pass. Please retain that normalization and add relative-path coverage for accepted non-Windows and Windows executables.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants