Repository navigation
Fix #7: resolve PowerShell by absolute path to prevent CWD hijacking - #8
Merged
Merged
Conversation
The Windows host module invoked PowerShell by the bare name "powershell". Windows resolves a bare executable name through the search order, which includes the current working directory before System32. Because the README tells users to run the scanner from their Downloads folder - a user-writable location - a planted powershell.exe there would be executed during the host checks, and could return forged check results. Pin the interpreter to its absolute System32 path and run the child process in a controlled working directory. An absolute path is never resolved through the search order, so only the real interpreter can run; if it is absent the check fails to a coverage gap rather than executing a same-named file from elsewhere. Adds regression tests asserting the interpreter path is absolute. Reported by @okba14 in #7.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #7. The Windows host module invoked PowerShell by the bare name
powershell, which Windows resolves through the executable search order — including the current working directory before System32. Because the README instructs users to run the scanner from their Downloads folder (a user-writable location), a plantedpowershell.exethere would execute during the host checks and could return forged results, as demonstrated in the report.Change
host.py: the interpreter is pinned to its absolute path (%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe). An absolute path is never resolved through the search order, so only the real interpreter can run; if it is absent the call fails to a coverage gap rather than executing a same-named file from elsewhere.powershell.exe.Testing
Reported by @okba14. Thank you for the detailed write-up and proof-of-concept.