-
Notifications
You must be signed in to change notification settings - Fork 1
[PPSC-602] CWE-22: Path traversal in install.ps1 #131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
290c4c1
60de804
eb01e0b
6c0376b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -171,6 +171,48 @@ function Main { | |||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # Validate install directory is under standard user-profile locations. | ||||||||||||||||||||||||||
| # Program Files is intentionally excluded — it requires admin privileges and | ||||||||||||||||||||||||||
| # writing there could enable DLL/EXE planting. Non-standard paths are allowed | ||||||||||||||||||||||||||
| # only with explicit interactive confirmation. | ||||||||||||||||||||||||||
| # Note: install.sh uses a different model (character-set + traversal deny-list) | ||||||||||||||||||||||||||
| # because Unix paths don't have canonical env-var-based user directories. | ||||||||||||||||||||||||||
| $allowedPrefixes = @($env:LOCALAPPDATA, $env:APPDATA, $env:USERPROFILE) | ||||||||||||||||||||||||||
| $isAllowlisted = $false | ||||||||||||||||||||||||||
| foreach ($prefix in $allowedPrefixes) { | ||||||||||||||||||||||||||
| if (-not $prefix) { continue } | ||||||||||||||||||||||||||
| # Normalize prefix the same way $InstallDir was normalized above, | ||||||||||||||||||||||||||
| # then append trailing backslash to prevent prefix confusion | ||||||||||||||||||||||||||
| # (e.g., "LocalLow" matching "Local") | ||||||||||||||||||||||||||
| $prefix = [System.IO.Path]::GetFullPath($prefix) | ||||||||||||||||||||||||||
| $normalizedPrefix = $prefix.TrimEnd('\') + '\' | ||||||||||||||||||||||||||
| if ($InstallDir.StartsWith($normalizedPrefix, [System.StringComparison]::OrdinalIgnoreCase)) { | ||||||||||||||||||||||||||
|
Comment on lines
+188
to
+189
|
||||||||||||||||||||||||||
| $normalizedPrefix = $prefix.TrimEnd('\') + '\' | |
| if ($InstallDir.StartsWith($normalizedPrefix, [System.StringComparison]::OrdinalIgnoreCase)) { | |
| $normalizedPrefixRoot = $prefix.TrimEnd('\') | |
| $normalizedPrefix = $normalizedPrefixRoot + '\' | |
| if ( | |
| [string]::Equals( | |
| $InstallDir.TrimEnd('\'), | |
| $normalizedPrefixRoot, | |
| [System.StringComparison]::OrdinalIgnoreCase | |
| ) -or | |
| $InstallDir.StartsWith($normalizedPrefix, [System.StringComparison]::OrdinalIgnoreCase) | |
| ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The header usage comment still shows an example installing under
C:\Program Files\..., but this block now explicitly discourages/excludes Program Files and may require confirmation (or fail in non-interactive mode). Please update the usage comment/help text to reflect the new recommended install locations/behavior.