fix(powershell-format): refuse computed -FilePath on Invoke-Command and Start-Job - #2466
Conversation
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
Claude finished @kyle-sexton's task in 2m 30s —— View job Security Review
This PR extends the PSScriptAnalyzer IMPORTANT — New loaders can be bypassed via their built-in aliases, reopening the exact hole this PR closesConfidence: High hooks/powershell-format.sh#L368-L370 The
icm -FilePath $computedPathparses to a Suggested fix: add No other security issues found in this diff. The |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 06121018a9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
88b0024 to
0d667f2
Compare
|
Claude finished @kyle-sexton's task in 1m 37s —— View job Security Review
This PR extends the PSSA trust gate's IMPORTANT —
|
…nd Start-Job Enumerates the two remaining named loaders whose -FilePath argument can execute an unpinned repository file. Fixes #1490 Co-authored-by: Kyle Sexton <kyle-sexton@users.noreply.github.com>
Co-authored-by: Kyle Sexton <kyle-sexton@users.noreply.github.com>
0d667f2 to
cf37cc7
Compare
|
Claude finished @kyle-sexton's task in 48s —— View job Security Review
This PR extends the PSScriptAnalyzer IMPORTANT —
|
|
Claude finished @kyle-sexton's task in 2m 42s —— View job Code Review
Per this repo's REVIEW.md, this lane owns correctness/design/tests and leaves security findings to the dedicated One correctness finding posted inline on
|
| $loaders = @("Import-Module", "ipmo", "Add-Type", "New-Module", | ||
| "Invoke-Expression", "iex", "Import-PowerShellDataFile") | ||
| "Invoke-Expression", "iex", "Import-PowerShellDataFile", | ||
| "Invoke-Command", "Start-Job") |
There was a problem hiding this comment.
Correctness: adding Invoke-Command/Start-Job to $loaders will false-positive on ordinary remoting calls that load no file
The loop that consumes $loaders (L398-415) doesn't check which parameter a value belongs to — it skips only the CommandParameterAst tokens themselves (-ComputerName, -ArgumentList, -ScriptBlock, ...) and then treats every remaining non-constant command element as a load target requiring pinning, else it refuses with PSSA_TRUST UNPINNABLE (exit 6) at L415.
For the loaders added before this PR (Import-Module, Add-Type, New-Module, Invoke-Expression, Import-PowerShellDataFile), that's mostly harmless because those cmdlets effectively take one meaningful path/name argument. Invoke-Command and Start-Job break that assumption — they commonly take several variable arguments that have nothing to do with loading a file, e.g.:
Invoke-Command -ComputerName $server -ScriptBlock { ... } -ArgumentList $value
Start-Job -ScriptBlock { ... } -ArgumentList $valueHere $server/$value are VariableExpressionAst nodes, not StringConstantExpressionAst/ExpandableStringExpressionAst with fully-expandable content, so they fall through to the final else at L415 and the scan exits UNPINNABLE — permanently blocking the trust approval for a rule module that never loads a file this way, with "no approval route" (as Codex's review on this same line noted).
Since this hook's opt-in trust gate exists specifically so legitimate CustomRulePath modules can be approved (see README's Trust model section), a rule module using either cmdlet for ordinary remoting/job control — not file loading — would be unable to ever pass the gate. Given Invoke-Command/Start-Job are far more likely to appear in non-loading remoting/job-control usage than the previous loaders, suggest scoping the pinning check to the value bound to -FilePath specifically (as Codex suggested), rather than every non-parameter element, for these two entries.
|
Claude has reviewed this PR 1 time. The lane skips further automatic reviews after 5; deleting this comment resets the count. |
Closes #1490
Related
N/A