security: fix single percent detection and add fsutil to PowerShell

setup.bat:
- Fix percent sign detection to catch single % (not just %%)
- Use string substitution for reliable detection

install-core.ps1:
- Add fsutil reparsepoint query to Test-SecureDirectory
- Matches batch script's dual-layer detection approach
- Keep .NET attribute check as fallback

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
unknown 2026-02-01 00:46:46 +11:00
parent 7eead7d48a
commit 1248758d46
No known key found for this signature in database
GPG key ID: FE478DD75EE21194
2 changed files with 11 additions and 4 deletions

View file

@ -69,9 +69,14 @@ function Test-SecureDirectory {
return $true # Directory doesn't exist yet, will be created return $true # Directory doesn't exist yet, will be created
} }
$dirInfo = Get-Item $Path -Force # Primary check: use fsutil for reliable reparse point detection (matches batch script)
$fsutilResult = & fsutil reparsepoint query $Path 2>&1
if ($LASTEXITCODE -eq 0) {
Write-Err "Directory '$Path' is a reparse point (symlink or junction). Possible symlink attack detected."
}
# Check for symlinks/junctions # Fallback: check .NET attributes
$dirInfo = Get-Item $Path -Force
if ($dirInfo.Attributes -band [System.IO.FileAttributes]::ReparsePoint) { if ($dirInfo.Attributes -band [System.IO.FileAttributes]::ReparsePoint) {
Write-Err "Directory '$Path' is a symbolic link or junction. Possible symlink attack detected." Write-Err "Directory '$Path' is a symbolic link or junction. Possible symlink attack detected."
} }

View file

@ -48,8 +48,10 @@ if !errorlevel! equ 0 (
echo ERROR: LOCALAPPDATA contains invalid shell characters echo ERROR: LOCALAPPDATA contains invalid shell characters
goto :error goto :error
) )
echo !LOCALAPPDATA! | findstr /c:"%%" >nul REM Check for percent signs (both single and double)
if !errorlevel! equ 0 ( set "TEMP_CHECK=!LOCALAPPDATA!"
set "TEMP_CHECK=!TEMP_CHECK:%%=!"
if not "!TEMP_CHECK!"=="!LOCALAPPDATA!" (
echo ERROR: LOCALAPPDATA contains percent signs echo ERROR: LOCALAPPDATA contains percent signs
goto :error goto :error
) )