claude-code - 💡(How to fix) Fix PowerShell(*) wildcard has silent carve-out for subexpressions -- bypasses allowlist, prompts anyway -- v2.1.119 [3 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#52926Fetched 2026-04-25 06:17:02
View on GitHub
Comments
3
Participants
2
Timeline
6
Reactions
0
Timeline (top)
commented ×3labeled ×3

The PowerShell(*) wildcard in settings.local.json does NOT actually cover all PowerShell commands as advertised. Any PowerShell command containing subexpressions ($(...)), script blocks ({}), or variable interpolation triggers a silent override labeled "Command contains subexpressions $()" or "Command contains script block that may execute arbitrary code" -- firing a permission prompt despite the explicit wildcard allow.

Root Cause

The PowerShell(*) wildcard in settings.local.json does NOT actually cover all PowerShell commands as advertised. Any PowerShell command containing subexpressions ($(...)), script blocks ({}), or variable interpolation triggers a silent override labeled "Command contains subexpressions $()" or "Command contains script block that may execute arbitrary code" -- firing a permission prompt despite the explicit wildcard allow.

Code Example

$procs = Get-Process python -ErrorAction SilentlyContinue
foreach ($p in $procs) {
    try { $cmd = (Get-CimInstance Win32_Process -Filter "ProcessId=$($p.Id)").CommandLine } catch { $cmd='?' }
    "PID $($p.Id): [$([int]($p.WorkingSet/1MB))MB]"
}
RAW_BUFFERClick to expand / collapse

Summary

The PowerShell(*) wildcard in settings.local.json does NOT actually cover all PowerShell commands as advertised. Any PowerShell command containing subexpressions ($(...)), script blocks ({}), or variable interpolation triggers a silent override labeled "Command contains subexpressions $()" or "Command contains script block that may execute arbitrary code" -- firing a permission prompt despite the explicit wildcard allow.

Environment

  • OS: Windows
  • Claude Code: v2.1.119
  • settings.local.json contains: "PowerShell(*)" in the allow array
  • Both desktop CLI and Remote Control exhibit the behavior

Expected behavior

PowerShell(*) in the allow array should cover ALL PowerShell commands, matching the advertised behavior and matching how Bash(*) works.

Actual behavior

PowerShell commands using common syntax patterns trigger a permission prompt regardless of the wildcard:

  • $() subexpressions -- extremely common in PowerShell (string interpolation, property access, arithmetic)
  • ${} variable expansion
  • {...} script blocks (foreach bodies, try/catch, ForEach-Object, Where-Object)
  • Any command with a newline/multi-line structure

Real example that prompted today despite PowerShell(*) being allowed:

$procs = Get-Process python -ErrorAction SilentlyContinue
foreach ($p in $procs) {
    try { $cmd = (Get-CimInstance Win32_Process -Filter "ProcessId=$($p.Id)").CommandLine } catch { $cmd='?' }
    "PID $($p.Id): [$([int]($p.WorkingSet/1MB))MB]"
}

The warning shown is "Command contains subexpressions $()" with options "Yes / No" (no "Allow always" option), even though PowerShell(*) is already in the allow list.

Impact

This is the dominant failure mode for PowerShell permission gating in practice. Virtually every non-trivial PowerShell command uses subexpressions or script blocks -- they are not exotic patterns, they are the language's primary syntax. So PowerShell(*) as a wildcard is effectively useless except for the simplest one-liner cases like Get-Process.

For users on Windows who rely on PowerShell for monitoring, process management, and file operations, this means autonomous overnight operation is repeatedly interrupted for commands that SHOULD be covered by the explicit wildcard allow.

Reproduction

  1. Add "PowerShell(*)" to settings.local.json allow array
  2. Trigger any PowerShell tool call that uses $() or {} syntax
  3. Observe permission prompt still fires with "Command contains subexpressions" warning

Request

Either:

  • PowerShell(*) should genuinely cover all PowerShell commands including subexpressions (match Bash(*) behavior)
  • OR document that PowerShell(*) has carve-outs for subexpressions and provide a different syntax (e.g., PowerShell(*, allow_subexpressions) or PowerShell.Unrestricted(*)) to genuinely allow everything
  • OR add "Allow always" option to the subexpression prompt so users can explicitly override the carve-out

Related: #37442 (permission inheritance), #52898 (Remote Control ignores wildcards).

extent analysis

TL;DR

The PowerShell(*) wildcard in settings.local.json does not cover PowerShell commands with subexpressions or script blocks, triggering a permission prompt despite the explicit allow.

Guidance

  • Verify that the issue is not specific to the version of Claude Code (v2.1.119) and check if newer versions have addressed this behavior.
  • Test using a different syntax, such as PowerShell(*) with additional parameters or options, to see if it makes a difference in the permission prompt.
  • Consider using a more permissive allow rule, such as PowerShell.Unrestricted(*), if available, to cover all PowerShell commands.
  • Document the current behavior and limitations of PowerShell(*) to set user expectations and provide workarounds.

Example

No code snippet is provided as the issue is more related to configuration and expected behavior.

Notes

The issue seems to be a limitation of the current implementation of PowerShell(*) and may require changes to the allow syntax or the addition of new options to cover all PowerShell commands.

Recommendation

Apply a workaround, such as using a more permissive allow rule or documenting the current behavior, as the issue is not fully addressed by the current PowerShell(*) syntax.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

PowerShell(*) in the allow array should cover ALL PowerShell commands, matching the advertised behavior and matching how Bash(*) works.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix PowerShell(*) wildcard has silent carve-out for subexpressions -- bypasses allowlist, prompts anyway -- v2.1.119 [3 comments, 2 participants]