Skip to content

fix(command-injection): read the script after pwsh -File as a file name (#218) - #229

Merged
SizzleUnrlsd merged 1 commit into
mainfrom
fix/powershell-file-operand
Oct 7, 2026
Merged

SizzleUnrlsd merged 1 commit into
mainfrom
fix/powershell-file-operand

Conversation

@SizzleUnrlsd

Copy link
Copy Markdown
Contributor

Summary

After -File, PowerShell takes the next element as the script, whatever it is spelled like. after_code scanned the code option's value too, so a script named -c, -e, -ec or -Command was read as a rest option and the elements after it as the command (false positive, high). The scan now stops before the value. A rest option always takes a value (every element after it is its value); CommandOption now enforces this, so the position excluded is never a rest option itself.

Verification

New tests in tests/test_powershell_file_operand.py (red before the fix); a -Command before -File still takes the rest. Full suite green apart from the local test_packaging environment issue; ruff, mypy clean; regression snapshots and the mitmproxy scan (75 findings) unchanged.

Closes #218

@SizzleUnrlsd SizzleUnrlsd added the bug Something isn't working label Oct 7, 2026
@SizzleUnrlsd SizzleUnrlsd self-assigned this Oct 7, 2026
@SizzleUnrlsd
SizzleUnrlsd merged commit ff31f66 into main Oct 7, 2026
10 checks passed
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.

command-injection: a PowerShell script named like -Command after -File is read as the option

1 participant