Repository navigation
Windows: cmd.exe re-reading a .cmd CLI's arguments is can't tell (#168) - #185
Merged
Merged
Conversation
On Windows, read as PowerShell (or with a .cmd or .bat name typed), when the CLI resolves to such a file: rebuild the command line as the shell does, scan it with cmd.exe's quote toggle, and an unquoted & | < > ^ ), a newline or %NAME% is "can't tell", naming the class and no value. A guarded CLI the words name stops too, as cmd.exe may run it. gh.exe and other .exe CLIs are untouched, a .ps1 beside the .cmd never reaches cmd.exe, and Linux and macOS are untouched. The line is scanned first, so most calls never look at PATH, and nothing is spawned for it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tests for what the first commit already does: a URL with & after a variable, a word bash splits, and --% text that stays with its own statement. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CHANGELOG under Security, ROADMAP's line says done, AGENTS has the new file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A mutation that left out the \" survived, and rightly: cmd.exe toggles on the quote whatever is before it, and an empty word holds nothing it acts on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #168 (PR 4 of the fail-closed design,
docs/superpowers/specs/2026-11-04-fail-closed-design.md).The bug. On Windows,
azand npm-installed CLIs are.cmdfiles, and cmd.exe re-reads their arguments. In PowerShell,az group list --query 'x&kubectl'also runskubectl, and--subs^cription otherreaches the CLI as--subscription other. cloudpin saw oneazcall with one value.A correction to the issue:
'x&kubectl get pods'has spaces, so PowerShell 5.1 quotes it andkubectldoesn't run. The real forms are'x&kubectl','a b"&kubectl get pods&"c'and--%.The fix: "can't tell", not a split (owner decision). Only on Windows, read as PowerShell or with a typed
.cmd/.bat, when the CLI resolves to a.cmdor.bat: rebuild the command line as PowerShell 5.1 does, and scan it with cmd.exe's quote toggle. An unquoted&,|,<,>,^or), a newline or carriage return anywhere, or%NAME%anywhere stops. The message names the character class, never a value.gh.exeisn't a.cmd, sogh --jqfilters are unaffected. That test is what keeps this cheap: without it, 452 real lines would stop..ps1beside the.cmdkeeps the rule silent, because PowerShell 5.1 runs the.ps1, or refuses it by policy, and never reaches cmd.exe. npm writes both, so this covers npm installs..cmd.Evidence
npm run typecheckexit 0;npx vitest run: 4493 passed, 19 skipped. 153 new tests, seen failing first.az.cmdand npm'svercel.cmdplus a compiledgh.exe: main allowed all 37, so the check can fail, and the branch matches what each printer really got.Not tested
pwsh(not installed; 7.3+ comes fromabout_Preference_Variables, and its quote rule and.ps1precedence are unmeasured). No real CLI.Left open
An unguarded
.cmdisn't read. A value only known at run time could hold&(--query $env:Q) and passes unless it's a target flag.🤖 Generated with Claude Code