Skip to content

Commit c5d6e83

Browse files
committed
fix: restrict startup unblock to PowerShell script files
Narrow the Mark-of-the-Web removal to .ps1/.psm1/.psd1: those are the only files the mark actually blocks (dot-sourcing), while other file types (json/xaml/reg/assets) are read through APIs that ignore the mark -- so their zone information is kept intact, and any future non-script payloads keep SmartScreen coverage. Addresses the CodeRabbit least-privilege note.
1 parent 9200024 commit c5d6e83

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

Win11Debloat.ps1

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,15 @@ if ($PSVersionTable.PSEdition -eq 'Core') {
114114
exit 1
115115
}
116116

117-
# Remove the Mark-of-the-Web (Zone.Identifier) from all files in the script folder so the
118-
# dot-sourced scripts load without per-file security prompts. The stream is added when the
119-
# ZIP is downloaded with a browser and extracted with Explorer, and a Group-Policy-scoped
117+
# Remove the Mark-of-the-Web (Zone.Identifier) from the PowerShell script files so they
118+
# dot-source without per-file security prompts. The stream is added when the ZIP is
119+
# downloaded with a browser and extracted with Explorer, and a Group-Policy-scoped
120120
# execution policy overrides the -ExecutionPolicy Bypass that Run.bat passes, so launcher
121-
# flags alone cannot prevent the prompts. See issue #720.
122-
Get-ChildItem -Path $PSScriptRoot -Recurse -File | Unblock-File -ErrorAction SilentlyContinue
121+
# flags alone cannot prevent the prompts. Only script/module files are unblocked -- other
122+
# file types are not affected by the mark and keep their zone information. See issue #720.
123+
Get-ChildItem -Path $PSScriptRoot -Recurse -File |
124+
Where-Object { $_.Extension -in '.ps1', '.psm1', '.psd1' } |
125+
Unblock-File -ErrorAction SilentlyContinue
123126

124127
# Check if script is running as administrator
125128
$isAdmin = ([Security.Principal.WindowsPrincipal] `

0 commit comments

Comments
 (0)