Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

fix(browser): never pass tool-supplied text through a Windows shell (ADR-401)

ruv6adbb393e857
diff --git a/v3/@claude-flow/cli/__tests__/browser-command-resolver.test.ts b/v3/@claude-flow/cli/__tests__/browser-command-resolver.test.ts
new file mode 100644
index 0000000000..79ea67f8c8
--- /dev/null
+++ b/v3/@claude-flow/cli/__tests__/browser-command-resolver.test.ts
@@ -0,0 +1,101 @@
+/** ADR-401: Windows browser launch targets resolve without cmd.exe. */
+import { describe, expect, it } from 'vitest';
+import { resolveAgentBrowserLaunch, resolveNpxLaunch } from '../src/runtime/browser-command.js';
+
+const NODE = 'C:\\Program Files\\nodejs\\node.exe';
+const NPM_BIN = 'C:\\Users\\dev\\AppData\\Roaming\\npm';
+const AB_ROOT = `${NPM_BIN}\\node_modules\\agent-browser`;
+
+/** Fake filesystem + where.exe for a Windows host. */
+function windows(files: Record<string, string | true>, where: Record<string, string[]> = {}) {
+ return {
+ platform: 'win32' as const,
+ nodeExecutable: NODE,
+ fileExists: (p: string) => p in files,
+ readFile: (p: string) => {
+ const v = files[p];
+ if (typeof v !== 'string') throw new Error(`ENOENT ${p}`);
+ return v;
+ },
+ lookup: (_command: string, args: string[]) => {
+ const found = where[args[0]];
+ if (!found) throw new Error('INFO: Could not find files');
+ return found.join('\r\n') + '\r\n';
+ },
+ };
+}
+
+describe('resolveAgentBrowserLaunch', () => {
+ it('spawns the command name directly on POSIX, without a shell', () => {
+ expect(resolveAgentBrowserLaunch({ platform: 'linux' })).toEqual({ command: 'agent-browser', argsPrefix: [] });
+ expect(resolveAgentBrowserLaunch({ platform: 'darwin' })).toEqual({ command: 'agent-browser', argsPrefix: [] });
+ });
+
+ it('prefers a native .exe found on PATH', () => {
+ const exe = 'C:\\tools\\agent-browser.exe';
+ const opts = windows({ [exe]: true }, { 'agent-browser': [`${NPM_BIN}\\agent-browser.cmd`, exe] });
+ expect(resolveAgentBrowserLaunch(opts)).toEqual({ command: exe, argsPrefix: [] });
+ });
+
+ it('maps the npm .cmd shim to node plus the package bin entry', () => {
+ const entry = `${AB_ROOT}\\bin\\agent-browser.js`;
+ const opts = windows(
+ { [`${AB_ROOT}\\package.json`]: JSON.stringify({ bin: { 'agent-browser': 'bin/agent-browser.js' } }), [entry]: true },
+ { 'agent-browser': [`${NPM_BIN}\\agent-browser`, `${NPM_BIN}\\agent-browser.cmd`] },
+ );
+ expect(resolveAgentBrowserLaunch(opts)).toEqual({ command: NODE, argsPrefix: [entry] });
+ });
+
+ it('accepts a string-valued bin field', () => {
+ const entry = `${AB_ROOT}\\cli.js`;
+ const opts = windows(
+ { [`${AB_ROOT}\\package.json`]: JSON.stringify({ bin: 'cli.js' }), [entry]: true },
+ { 'agent-browser': [`${NPM_BIN}\\agent-browser.cmd`] },
+ );
+ expect(resolveAgentBrowserLaunch(opts)?.argsPrefix).toEqual([entry]);
+ });
+
+ it('rejects a bin entry that escapes the package directory', () => {
+ const outside = `${NPM_BIN}\\node_modules\\evil.js`;
+ const opts = windows(
+ { [`${AB_ROOT}\\package.json`]: JSON.stringify({ bin: { 'agent-browser': '..\\evil.js' } }), [outside]: true },
+ { 'agent-browser': [`${NPM_BIN}\\agent-browser.cmd`] },
+ );
+ expect(resolveAgentBrowserLaunch(opts)).toBeNull();
+ });
+
+ it('never returns a batch file, which would imply cmd.exe even with shell:false', () => {
+ const batch = `${AB_ROOT}\\run.cmd`;
+ const opts = windows(
+ { [`${AB_ROOT}\\package.json`]: JSON.stringify({ bin: { 'agent-browser': 'run.cmd' } }), [batch]: true },
+ { 'agent-browser': [`${NPM_BIN}\\agent-browser.cmd`] },
+ );
+ expect(resolveAgentBrowserLaunch(opts)).toBeNull();
+ expect(resolveAgentBrowserLaunch(windows({}, { 'agent-browser': [`${NPM_BIN}\\agent-browser.bat`] }))).toBeNull();
+ });
+
+ it('returns null when nothing resolves', () => {
+ expect(resolveAgentBrowserLaunch(windows({}))).toBeNull();
+ });
+});
+
+describe('resolveNpxLaunch', () => {
+ it('spawns npx directly on POSIX', () => {
+ expect(resolveNpxLaunch({ platform: 'linux' })).toEqual({ command: 'npx', argsPrefix: [] });
+ });
+
+ it("uses node plus the running Node's own npx-cli.js on Windows", () => {
+ const cli = 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npx-cli.js';
+ expect(resolveNpxLaunch(windows({ [cli]: true }))).toEqual({ command: NODE, argsPrefix: [cli] });
+ });
+
+ it('falls back to the npm that where.exe npx points at', () => {
+ const cli = 'D:\\nvm\\v22\\node_modules\\npm\\bin\\npx-cli.js';
+ const opts = windows({ [cli]: true }, { npx: ['D:\\nvm\\v22\\npx.cmd'] });
+ expect(resolveNpxLaunch(opts)).toEqual({ command: NODE, argsPrefix: [cli] });
+ });
+
+ it('returns null rather than reaching for a shell when npx-cli.js is absent', () => {
+ expect(resolveNpxLaunch(windows({}, { npx: ['D:\\nvm\\v22\\npx.cmd'] }))).toBeNull();
+ });
+});
diff --git a/v3/@claude-flow/cli/__tests__/browser-win32-no-shell.test.ts b/v3/@claude-flow/cli/__tests__/browser-win32-no-shell.test.ts
new file mode 100644
index 0000000000..ff6d720d61
--- /dev/null
+++ b/v3/@claude-flow/cli/__tests__/browser-win32-no-shell.test.ts
@@ -0,0 +1,102 @@
+/** ADR-401: tool-supplied browser arguments never reach a shell, on any platform. */
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+
+const execFileSync = vi.hoisted(() => vi.fn());
+const resolveAgentBrowserLaunch = vi.hoisted(() => vi.fn());
+const resolveNpxLaunch = vi.hoisted(() => vi.fn());
+vi.mock('child_process', () => ({ execFileSync }));
+vi.mock('../src/runtime/browser-command.js', () => ({ resolveAgentBrowserLaunch, resolveNpxLaunch }));
+vi.mock('../src/mcp-tools/validate-input.js', () => ({
+ validateIdentifier: () => ({ valid: true }),
+ validateText: () => ({ valid: true }),
+}));
+
+import { execBrowserCommand } from '../src/mcp-tools/browser-tools.js';
+
+// Shell metacharacters for cmd.exe and POSIX shells, plus a multi-line script.
+const HOSTILE = [
+ 'x" & calc.exe & "',
+ '%COMSPEC% /c whoami',
+ 'a ^| b && c',
+ '$(id) `id` ; rm -rf /',
+ 'line1\r\nnet user pwn /add',
+ "');require('child_process').execSync('calc');//",
+];
+
+const realPlatform = Object.getOwnPropertyDescriptor(process, 'platform')!;
+const setPlatform = (value: string) => Object.defineProperty(process, 'platform', { value });
+
+describe('execBrowserCommand never spawns through a shell', () => {
+ beforeEach(() => {
+ execFileSync.mockReset();
+ resolveAgentBrowserLaunch.mockReset();
+ resolveNpxLaunch.mockReset();
+ });
+ afterEach(() => Object.defineProperty(process, 'platform', realPlatform));
+
+ for (const platform of ['win32', 'linux']) {
+ it(`passes hostile values as literal argv with no shell option (${platform}, global path)`, async () => {
+ setPlatform(platform);
+ resolveAgentBrowserLaunch.mockReturnValue({ command: 'node', argsPrefix: ['/pkg/bin/agent-browser.js'] });
+ execFileSync.mockReturnValue('{"success":true}');
+
+ for (const payload of HOSTILE) {
+ await execBrowserCommand(['fill', '#field', payload], 'test-session');
+ const [command, argv, options] = execFileSync.mock.calls.at(-1)!;
+ expect(command).toBe('node');
+ expect(argv).toEqual(['/pkg/bin/agent-browser.js', '--session', 'test-session', '--json', 'fill', '#field', payload]);
+ expect(options.shell).toBeFalsy();
+ }
+ });
+
+ it(`passes hostile values as literal argv with no shell option (${platform}, npx fallback)`, async () => {
+ setPlatform(platform);
+ resolveAgentBrowserLaunch.mockReturnValue(null);
+ resolveNpxLaunch.mockReturnValue({ command: 'node', argsPrefix: ['/npm/bin/npx-cli.js'] });
+ execFileSync.mockReturnValue('{"success":true}');
+
+ for (const payload of HOSTILE) {
+ await execBrowserCommand(['eval', payload], 'test-session');
+ const [command, argv, options] = execFileSync.mock.calls.at(-1)!;
+ expect(command).toBe('node');
+ expect(argv).toEqual(['/npm/bin/npx-cli.js', '--yes', 'agent-browser', '--session', 'test-session', '--json', 'eval', payload]);
+ expect(options.shell).toBeFalsy();
+ }
+ });
+ }
+
+ it('falls back to npx when the resolved global launch reports ENOENT', async () => {
+ setPlatform('win32');
+ resolveAgentBrowserLaunch.mockReturnValue({ command: 'C:\\gone\\agent-browser.exe', argsPrefix: [] });
+ resolveNpxLaunch.mockReturnValue({ command: 'node', argsPrefix: ['/npm/bin/npx-cli.js'] });
+ execFileSync
+ .mockImplementationOnce(() => { throw Object.assign(new Error('gone'), { code: 'ENOENT' }); })
+ .mockReturnValueOnce('{"success":true}');
+
+ const result = await execBrowserCommand(['click', '#go']);
+ expect(result.isError).toBeFalsy();
+ expect(execFileSync).toHaveBeenCalledTimes(2);
+ for (const call of execFileSync.mock.calls) expect(call[2].shell).toBeFalsy();
+ });
+
+ it('fails with the install hint, and spawns nothing, when Windows cannot resolve either launcher', async () => {
+ setPlatform('win32');
+ resolveAgentBrowserLaunch.mockReturnValue(null);
+ resolveNpxLaunch.mockReturnValue(null);
+
+ const result = await execBrowserCommand(['fill', '#f', HOSTILE[0]]);
+ expect(result.isError).toBe(true);
+ expect(JSON.parse(result.content[0].text as string).error).toMatch(/Neither agent-browser nor npx found/);
+ expect(execFileSync).not.toHaveBeenCalled();
+ });
+});
+
+describe('static guard', () => {
+ it('browser-tools.ts sets no shell option on any spawn', async () => {
+ const { readFileSync } = await import('node:fs');
+ const source = readFileSync(new URL('../src/mcp-tools/browser-tools.ts', import.meta.url), 'utf8');
+ // Strip comments so the ADR-401 note can mention the word.
+ const code = source.replace(/\/\*[\s\S]*?\*\//g, '').replace(/\/\/.*$/gm, '');
+ expect(code).not.toMatch(/\bshell\s*:/);
+ });
+});
diff --git a/v3/@claude-flow/cli/src/mcp-tools/browser-tools.ts b/v3/@claude-flow/cli/src/mcp-tools/browser-tools.ts
index 4bd1ffac1b..1589d066d6 100644
--- a/v3/@claude-flow/cli/src/mcp-tools/browser-tools.ts
+++ b/v3/@claude-flow/cli/src/mcp-tools/browser-tools.ts
@@ -8,6 +8,7 @@
import { readFileSync, existsSync } from 'node:fs';
import type { MCPTool, MCPToolResult } from './types.js';
import { validateIdentifier, validateText } from './validate-input.js';
+import { resolveAgentBrowserLaunch, resolveNpxLaunch } from '../runtime/browser-command.js';
// Session registry for multi-session support
const browserSessions = new Map<string, {
@@ -55,33 +56,37 @@ export async function execBrowserCommand(args: string[], session = 'default'): P
const { execFileSync } = await import('child_process');
const fullArgs = ['--session', session, '--json', ...args];
- let result: string;
- try {
- result = execFileSync('agent-browser', fullArgs, {
- encoding: 'utf-8',
- timeout: 30000,
- });
- } catch (error) {
- const err = error as NodeJS.ErrnoException;
- if (err.code === 'ENOENT') {
- try {
- // #2770: On Windows, `npx` ships as `npx.cmd`; execFileSync cannot spawn
- // a .cmd file without going through cmd.exe. Enable shell on win32 so
- // cmd.exe resolves the .cmd extension. POSIX keeps shell:false.
- // NOTE: shell:true joins args by spaces and passes to cmd.exe — the args
- // here are hard-coded flags + a package name, so no injection risk. If
- // user-controlled args are ever added, escape them before spawn.
- result = execFileSync('npx', ['--yes', 'agent-browser', ...fullArgs], {
- encoding: 'utf-8',
- timeout: 60000,
- shell: process.platform === 'win32',
- windowsHide: true,
- });
- } catch (npxError) {
- return browserCommandFailure(npxError, 'Neither agent-browser nor npx found. Install with: npm i -g agent-browser');
- }
- } else {
- return browserCommandFailure(error);
+ // ADR-401: fullArgs carries tool-supplied text (fill values, eval scripts,
+ // selectors), so no spawn here may use a shell. On Windows the npm shims are
+ // resolved to the process behind them instead of enabling `shell: true`,
+ // which would hand that text to cmd.exe. Never add a `shell` option below.
+ const missing = 'Neither agent-browser nor npx found. Install with: npm i -g agent-browser';
+ let result: string | undefined;
+
+ const global = resolveAgentBrowserLaunch();
+ if (global) {
+ try {
+ result = execFileSync(global.command, [...global.argsPrefix, ...fullArgs], {
+ encoding: 'utf-8',
+ timeout: 30000,
+ windowsHide: true,
+ });
+ } catch (error) {
+ if ((error as NodeJS.ErrnoException).code !== 'ENOENT') return browserCommandFailure(error);
+ }
+ }
+
+ if (result === undefined) {
+ const npx = resolveNpxLaunch();
+ if (!npx) return browserCommandFailure(Object.assign(new Error('npx not resolvable'), { code: 'ENOENT' }), missing);
+ try {
+ result = execFileSync(npx.command, [...npx.argsPrefix, '--yes', 'agent-browser', ...fullArgs], {
+ encoding: 'utf-8',
+ timeout: 60000,
+ windowsHide: true,
+ });
+ } catch (npxError) {
+ return browserCommandFailure(npxError, missing);
}
}
diff --git a/v3/@claude-flow/cli/src/runtime/browser-command.ts b/v3/@claude-flow/cli/src/runtime/browser-command.ts
new file mode 100644
index 0000000000..d4be5c6f47
--- /dev/null
+++ b/v3/@claude-flow/cli/src/runtime/browser-command.ts
@@ -0,0 +1,124 @@
+import { execFileSync } from 'node:child_process';
+import { existsSync, readFileSync } from 'node:fs';
+import { posix, win32 } from 'node:path';
+
+/**
+ * A process target Node can spawn with `shell: false`.
+ * The caller appends its own argv after `argsPrefix`.
+ */
+export interface BrowserLaunch {
+ command: string;
+ argsPrefix: string[];
+}
+
+export interface BrowserLaunchOptions {
+ platform?: NodeJS.Platform;
+ nodeExecutable?: string;
+ lookup?: (command: string, args: string[]) => string;
+ fileExists?: (path: string) => boolean;
+ readFile?: (path: string) => string;
+}
+
+/**
+ * Windows npm shims (`agent-browser.cmd`, `npx.cmd`) are batch files. Node
+ * cannot spawn them with `shell: false`, and `shell: true` joins argv with
+ * spaces and hands the result to cmd.exe, so every tool-supplied value (a
+ * `fill` value, an `eval` script, a selector) becomes shell syntax. Resolve
+ * the shim to the JavaScript entry point (or native executable) behind it and
+ * spawn that directly, so argv reaches the process as literal data.
+ *
+ * A target ending in `.cmd` or `.bat` is never returned: spawning one implies
+ * cmd.exe regardless of the `shell` option.
+ */
+const BATCH_TARGET = /\.(cmd|bat)$/i;
+
+function defaults(options: BrowserLaunchOptions) {
+ const platform = options.platform ?? process.platform;
+ return {
+ platform,
+ path: platform === 'win32' ? win32 : posix,
+ nodeExecutable: options.nodeExecutable ?? process.execPath,
+ lookup: options.lookup ?? ((command: string, args: string[]) =>
+ execFileSync(command, args, { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] })),
+ fileExists: options.fileExists ?? existsSync,
+ readFile: options.readFile ?? ((file: string) => readFileSync(file, 'utf8')),
+ };
+}
+
+function whereAll(lookup: (command: string, args: string[]) => string, name: string): string[] {
+ try {
+ return lookup('where.exe', [name])
+ .split(/\r?\n/)
+ .map((line) => line.trim())
+ .filter(Boolean);
+ } catch {
+ return [];
+ }
+}
+
+/** `bin` of a package.json, resolved to a path that stays inside the package. */
+function packageBinEntry(
+ packageRoot: string,
+ binName: string,
+ d: ReturnType<typeof defaults>,
+): string | null {
+ let manifest: { bin?: string | Record<string, string> };
+ try {
+ manifest = JSON.parse(d.readFile(d.path.join(packageRoot, 'package.json')));
+ } catch {
+ return null;
+ }
+ const relative = typeof manifest.bin === 'string' ? manifest.bin : manifest.bin?.[binName];
+ if (typeof relative !== 'string' || !relative) return null;
+
+ const entry = d.path.resolve(packageRoot, relative);
+ const rootWithSep = d.path.resolve(packageRoot) + d.path.sep;
+ if (!entry.startsWith(rootWithSep)) return null;
+ return d.fileExists(entry) ? entry : null;
+}
+
+/**
+ * Locate a globally installed `agent-browser`.
+ * POSIX: the command name itself (spawned without a shell, as before).
+ * Windows: a native `.exe`, or `node <entry.js>` behind the npm shim; null when
+ * neither can be resolved without a shell.
+ */
+export function resolveAgentBrowserLaunch(options: BrowserLaunchOptions = {}): BrowserLaunch | null {
+ const d = defaults(options);
+ if (d.platform !== 'win32') return { command: 'agent-browser', argsPrefix: [] };
+
+ const matches = whereAll(d.lookup, 'agent-browser');
+
+ const executable = matches.find((candidate) =>
+ d.path.extname(candidate).toLowerCase() === '.exe' && d.fileExists(candidate));
+ if (executable) return { command: executable, argsPrefix: [] };
+
+ for (const shim of matches) {
+ const packageRoot = d.path.join(d.path.dirname(shim), 'node_modules', 'agent-browser');
+ const entry = packageBinEntry(packageRoot, 'agent-browser', d);
+ if (!entry || BATCH_TARGET.test(entry)) continue;
+ if (d.path.extname(entry).toLowerCase() === '.exe') return { command: entry, argsPrefix: [] };
+ return { command: d.nodeExecutable, argsPrefix: [entry] };
+ }
+ return null;
+}
+
+/**
+ * Locate `npx` for the `npx --yes agent-browser` fallback.
+ * POSIX: `npx` itself. Windows: `node <npm>/bin/npx-cli.js`, taken from the
+ * running Node's own npm or from the npm that `where.exe npx` points at.
+ */
+export function resolveNpxLaunch(options: BrowserLaunchOptions = {}): BrowserLaunch | null {
+ const d = defaults(options);
+ if (d.platform !== 'win32') return { command: 'npx', argsPrefix: [] };
+
+ const roots = [
+ d.path.dirname(d.nodeExecutable),
+ ...whereAll(d.lookup, 'npx').map((shim) => d.path.dirname(shim)),
+ ];
+ for (const root of roots) {
+ const entry = d.path.join(root, 'node_modules', 'npm', 'bin', 'npx-cli.js');
+ if (d.fileExists(entry)) return { command: d.nodeExecutable, argsPrefix: [entry] };
+ }
+ return null;
+}
diff --git a/v3/docs/adr/ADR-401-browser-mcp-windows-shell-boundary.md b/v3/docs/adr/ADR-401-browser-mcp-windows-shell-boundary.md
new file mode 100644
index 0000000000..8a6611b41e
--- /dev/null
+++ b/v3/docs/adr/ADR-401-browser-mcp-windows-shell-boundary.md
@@ -0,0 +1,63 @@
+# ADR 401: Browser MCP Windows Shell Boundary
+
+Status: Accepted
+
+Date: 2026 09 26
+
+Related: #2770 (the fallback this ADR corrects), ADR 399 (Git execution boundary), ADR 127 (github-safe shell-free execution)
+
+## Context
+
+The browser MCP tools (`browser_open`, `browser_fill`, `browser_type`, `browser_press`, `browser_select`, `browser_eval`, and the others that share `execBrowserCommand`) run the `agent-browser` CLI. When `agent-browser` is not installed globally, `execBrowserCommand` fell back to `npx --yes agent-browser ...`.
+
+On Windows `npx` is `npx.cmd`, a batch file that `execFileSync` cannot spawn without `cmd.exe`. The #2770 fix enabled `shell: process.platform === 'win32'` for that fallback and recorded a safety condition in a comment: the arguments were hard-coded flags plus a package name, and "if user-controlled args are ever added, escape them before spawn."
+
+That condition stopped being true. `execBrowserCommand` now receives tool-supplied values: the `fill` value, the `eval` script, selectors, key names, URLs and paths. Their only validation is `validateText`, which checks type, length and NUL bytes. With `shell: true`, Node joins argv with spaces and passes the string to `cmd.exe`, so `&`, `|`, `^`, `%VAR%` and quotes in any of those values are shell syntax. An MCP caller, including a prompt-injected agent, can run commands as the host user on any Windows host where `agent-browser` is missing.
+
+Scope of the exposure:
+
+- Windows only, and only on the fallback path (global `agent-browser` absent).
+- POSIX was never affected: `shell` is `false` there.
+- Affects every published version that carries the #2770 fallback, including 3.46.0.
+
+The condition was reported through an independent research run against `main` at `88955d9f`. It was verified here by reading the published 3.46.0 artifact: the `shell: process.platform === 'win32'` option and the stale comment are present in `dist/src/mcp-tools/browser-tools.js`.
+
+## Decision
+
+Tool-supplied text never reaches a shell. `execBrowserCommand` no longer sets a `shell` option on any spawn.
+
+Windows launch targets are resolved to the process behind the npm shim, and that process is spawned directly with an argv array:
+
+1. `agent-browser`: `where.exe agent-browser`, then a native `.exe`, or `node <entry>` where `<entry>` is the package's own `bin` file read from `<npm prefix>/node_modules/agent-browser/package.json`.
+2. `npx` fallback: `node <npm>/bin/npx-cli.js --yes agent-browser ...`, using the running Node's own npm, or the npm that `where.exe npx` points at.
+
+This is the resolution `runtime/claude-command.ts` already applies to Claude Code and the hook runner applies to `resolveNpmShim`. It lives in `runtime/browser-command.ts` as two small functions with injectable platform, filesystem and lookup so they are testable on any host.
+
+Guards:
+
+- A resolved target ending in `.cmd` or `.bat` is never returned. Spawning one implies `cmd.exe` even with `shell: false`.
+- A `bin` entry that resolves outside its package directory is rejected.
+- If neither launcher resolves on Windows, the tool fails with the existing install hint. It does not fall back to a shell.
+- POSIX behaviour is unchanged: `agent-browser`, then `npx`, both without a shell.
+
+## Enforcement
+
+- `browser-win32-no-shell.test.ts` drives `execBrowserCommand` with hostile values (`" & calc.exe & "`, `%COMSPEC%`, `^|`, `$(id)`, CRLF injection, a script that calls `child_process`) under a stubbed `win32` and `linux` platform. It asserts that every spawn receives the value as one literal argv element and no truthy `shell`. It fails on the previous implementation.
+- A static test fails if `browser-tools.ts` ever contains a `shell:` option again.
+- `browser-command-resolver.test.ts` covers resolution, `.cmd` and `.bat` refusal, and bin-path traversal.
+
+## Alternatives considered
+
+- **Escape arguments for `cmd.exe`** (`escapeCmdArg`). Rejected. A `shell: true` command line is parsed twice, by `cmd.exe` and then by the target's argv parser, and correct quoting differs between them. The hook runner needed a dedicated two-parser escaper for exactly this. Removing the shell removes the class of bug instead of relying on complete escaping of every future argument.
+- **Tighten `validateText`.** Rejected as the primary control. `fill` and `eval` legitimately carry arbitrary text, including quotes and ampersands, so a denylist would either break the tools or miss a metacharacter.
+- **Require a global `agent-browser` and drop the `npx` fallback.** Viable, but a behaviour change for users who rely on the fallback. Kept as a possible follow-up.
+
+## Consequences
+
+- The Windows fallback keeps working on standard Node installs. On unusual layouts where `npx-cli.js` cannot be located, the tool now reports the install hint instead of running through `cmd.exe`.
+- Users on Windows with a global `agent-browser` now run it without `npx` at all, which is faster than before.
+- Other `shell: process.platform === 'win32'` call sites were audited and are not exposed to tool input: `commands/init.ts` passes hard-coded flags and a pre-validated model name, `commands/eject.ts` takes arguments from the local user's own command line, and `mcp-tools/agentbbs-tools.ts` runs a fixed `--version` against a binary chosen by a trusted environment variable. Their stale "no injection risk" comments should be revisited if any of those arguments ever become tool-supplied.
+
+## Disclosure
+
+The fix and the patched release ship together. The advisory text describes the condition and the affected configuration without an exploit string.