From 1eace14c57a0e7aa3ea55fda2d57faa2da1208d9 Mon Sep 17 00:00:00 2001 From: BingZ Date: Sun, 12 Jul 2026 12:21:18 +0800 Subject: [PATCH] fix(preflight): reject Windows paths from WSL agent lookup (#7994) * fix(preflight): reject Windows paths from WSL lookup WSL agent discovery previously treated path.win32 absolute results as valid guest paths, so a Windows absolute path like C:\spoof could be counted as a found agent. Only POSIX absolute paths are valid inside WSL. * docs(preflight): explain WSL path boundary * docs(preflight): correct WSL path rejection rationale Co-authored-by: Orca --------- Co-authored-by: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Co-authored-by: Orca --- src/main/ipc/preflight-wsl-agent-detection.test.ts | 4 ++-- src/main/ipc/preflight-wsl-agent-detection.ts | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/ipc/preflight-wsl-agent-detection.test.ts b/src/main/ipc/preflight-wsl-agent-detection.test.ts index a1f9d7cfda5..1853540d8db 100644 --- a/src/main/ipc/preflight-wsl-agent-detection.test.ts +++ b/src/main/ipc/preflight-wsl-agent-detection.test.ts @@ -78,11 +78,11 @@ describe('detectWslCommandsOnPath', () => { it('ignores commands whose resolved path is not absolute', async () => { execFileAsyncMock.mockResolvedValue({ - stdout: '__ORCA_AGENT_PATH__claude\tclaude\n', + stdout: '__ORCA_AGENT_PATH__claude\tclaude\n' + '__ORCA_AGENT_PATH__codex\tC:\\spoof\n', stderr: '' }) - const found = await detectWslCommandsOnPath({ distro: 'Ubuntu' }, ['claude']) + const found = await detectWslCommandsOnPath({ distro: 'Ubuntu' }, ['claude', 'codex']) expect(found).toEqual(new Set()) }) diff --git a/src/main/ipc/preflight-wsl-agent-detection.ts b/src/main/ipc/preflight-wsl-agent-detection.ts index be1f216ed9c..b5eff064325 100644 --- a/src/main/ipc/preflight-wsl-agent-detection.ts +++ b/src/main/ipc/preflight-wsl-agent-detection.ts @@ -114,7 +114,9 @@ function parseWslDetectedCommands(stdout: string): Set { } const command = payload.slice(0, separatorIndex) const resolvedPath = payload.slice(separatorIndex + 1) - if (path.posix.isAbsolute(resolvedPath) || path.win32.isAbsolute(resolvedPath)) { + // Why: a real guest executable always resolves to a POSIX-absolute path, so + // a Windows-style C:\ path here is spoofed/non-guest output, not an install. + if (path.posix.isAbsolute(resolvedPath)) { found.add(command) } }