Escape service binary path in manage-osqueryd.ps1 #8569
Merged
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.
This pull request fixes a security vulnerability in the Windows service installation script (tools\deployment\osqueryd\manage-osqueryd.ps1). The issue is related to an unquoted service binary path, which could lead to privilege escalation if an attacker places a malicious executable in an unquoted directory path.
Issue:
When installing the osqueryd service, the script currently does not properly quote the service binary path:
If $kServiceBinaryPath contains spaces (e.g., C:\Program Files\osquery\osqueryd.exe), Windows may attempt to execute a malicious executable placed in a higher-level directory (e.g., C:\Program.exe).
Fix:
This PR ensures the path is correctly quoted:
Security Impact:
This change mitigates a potential privilege escalation vulnerability by ensuring that Windows correctly interprets the full path to osqueryd.exe as a single argument.
Testing:
Verified that the script correctly installs the service with the quoted path.
Ensured that osqueryd.exe starts without errors after installation.
Confirmed that the fix prevents unintended execution of other executables in unquoted paths.
References:
Microsoft Documentation on Unquoted Service Paths