Skip to content

Windows: don't start a .cmd when cmd.exe would act on its arguments (1.2.2) - #186

Merged
paureis merged 4 commits into
mainfrom
fix/cmd-spawn-quote
Nov 5, 2026
Merged

paureis merged 4 commits into
mainfrom
fix/cmd-spawn-quote

Conversation

@paureis

@paureis paureis commented Nov 5, 2026

Copy link
Copy Markdown
Owner

The fix from 1.2.2 (released 2026-11-05, tag v1.2.2 on release/1.2.2), brought to main, with 1.2.2's docs.

On Windows, a value in a command could start another command through cmd.exe while cloudpin checked or ran that command, when the CLI is a .cmd or .bat file. cross-spawn escapes arguments for cmd.exe, but a batch file reads them a second time. src/exec.ts now refuses to start such a file when cmd.exe would act on its arguments: the check stops the command as "can't tell", and cloudpin exec exits non-zero. The message names the kind of character, never a value. JMESPath with double quotes keeps working. .exe CLIs, Linux and macOS are unaffected.

src/exec.ts's comment and THREAT_MODEL.md's line said values could never be re-read by cmd.exe; both now say what's true.

Evidence

  • npm run typecheck exit 0; npx vitest run passes on main, and 2304 passed on v1.2.1 plus the fix.
  • test/exec-cmd-quote.test.ts failed first (157 failing before the code existed). The real Linux and macOS spawn test is skipped on Windows; this PR's Linux job runs it.
  • 64 of 64 mutations killed.
  • 996 cases through realExec and the inherit path, with printers shaped like az.cmd, npm's shim and a .bat: 716 intact, 280 refused with nothing run, none still different.
  • A direct reproduction: realExec("az", [..., 'a"&kubectl']) ran a fake kubectl before the fix and doesn't after. Nightly was green on the release branch.
  • npm's cloudpin@1.2.2 integrity equals the release tarball (1.2.1's differs); its attestation verifies, and a wrong-repo control fails.

Not tested

No real CLI. gcloud, wrangler and supabase aren't installed here as .cmd, so their batch files are unread.

🤖 Generated with Claude Code

paureis and others added 4 commits November 4, 2026 23:53
cross-spawn escapes for one reading by cmd.exe, but a .cmd or .bat reads its
arguments again, and what arrives can differ from what cloudpin passed.
src/exec.ts now refuses those calls on Windows: realExec returns a failure,
so the check fails closed, and runInherited exits 127 with a message that
names the kind of character and never the value. A plain double quote still
passes when it leaves nothing outside the quotes, so JMESPath keeps working.
.com and .exe, Linux and macOS are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The comment said a value could never be interpreted by cmd.exe.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… form

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@paureis
paureis merged commit cc827ef into main Nov 5, 2026
4 checks passed
@paureis
paureis deleted the fix/cmd-spawn-quote branch November 5, 2026 05:46
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