T07 · Tool Hijacking and Spoofing
Warning
- Location
- scripts/resolve_cli.ps1:3
- Finding
- Unverified Helper Executable Resolution Enables Local Tool Spoofing<![CDATA[ ## Vulnerability Details **File Locations**: - `scripts/resolve_cli.ps1:3-24` - `scripts/workflow_dev.ps1:62-111` - `scripts/workflow_dev.ps1:124-152` - `scripts/resolve_cli.sh:4-12` - `scripts/workflow_dev.sh:20-31` - `scripts/workflow_dev.sh:45-55` **Vulnerability Type**: Unauthenticated executable and application-bundle resolution **Risk Level**: Medium **Classification**: T07: Tool Hijacking and Spoofing ### Vulnerable Code Windows resolver: ```powershell $ErrorActionPreference = "Stop" $candidates = [System.Collections.Generic.List[string]]::new() foreach ($candidate in @( $Executable, $env:SCREEN_AUTOMATION_HELPER_EXE, (Join-Path $env:LOCALAPPDATA "Programs\Xiaozs\ScreenAutomationHelper\ScreenAutomationHelper.exe") )) { if (-not [string]::IsNullOrWhiteSpace($candidate)) { $candidates.Add($candidate) } } $appPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\App Paths\ScreenAutomationHelper.exe" if (Test-Path -LiteralPath $appPath) { $registered = (Get-Item -LiteralPath $appPath).GetValue("") if ($registered) { $candidates.Add([string]$registered) } } $command = Get-Command "ScreenAutomationHelper.exe" -ErrorAction SilentlyContinue if ($command -and $command.Source) { $candidates.Add($command.Source) } foreach ($candidate in $candidates) { $fullPath = [IO.Path]::GetFullPath([Environment]::ExpandEnvironmentVariables($candidate)) if (Test-Path -LiteralPath $fullPath -PathType Leaf) { return $fullPath } } ``` The workflow wrapper implements equivalent resolution logic and then executes the selected file: ```powershell $resolvedExecutable = Resolve-HelperExecutable -RequestedPath $Executable switch ($Action) { "cli-path" { $resolvedExecutable } "status" { $desktopStatus = (& $resolvedExecutable cli status | Out-String | ConvertFrom-Json) [ordered]@{ ok = $true executable = $resolvedExecutable desktop = $desktopStatus } | ConvertTo-Json ...[truncated 4992 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. **Verify Windows executable signatures** - Call `Get-AuthenticodeSignature` for every candidate. - Require a valid signature and compare the signing certificate or publisher against an embedded allowlist. - Reject unsigned files, invalid signatures, and unexpected publishers. 2. **Verify macOS bundle identity** - Use the platform code-signing APIs or `codesign` verification. - Validate the expected Team ID, bundle identifier, and designated requirement. - Verify both the main CLI and relevant bundled executable code. 3. **Remove ambiguous discovery fallbacks** - Do not resolve this helper through the general Windows `PATH`. - Prefer canonical installation directories established by a trusted installer. - Treat HKCU and environment-based values as untrusted hints rather than proof of identity. 4. **Restrict development overrides** - Allow `-Executable`, `SCREEN_AUTOMATION_HELPER_EXE`, and `SCREEN_AUTOMATION_MAC_APP` only in an explicit development mode. - Display the resolved path and require informed user approval before first execution of an override. - Document that environment overrides cross a code-execution trust boundary. 5. **Validate filesystem properties** - Resolve paths to their canonical targets before validation. - Reject unexpected symbolic links, junctions, and reparse points. - Reject candidates located in directories writable by untrusted users. - Confirm expected ownership and permissions where supported. 6. **Apply checks consistently** - Centralize helper resolution and authenticity verification so `resolve_cli` and `workflow_dev` cannot diverge. - Apply the same verification before executing the macOS embedded Python interpreter or bridge. - Fail closed when identity validation cannot be completed. ]]>
