Skip to content

Conversation

@smithclay
Copy link
Contributor

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:

New-Service -BinaryPathName "$kServiceBinaryPath $startupArgs" \
            -Name $kServiceName \
            -DisplayName $kServiceName \
            -Description $kServiceDescription \
            -StartupType Automatic

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:

New-Service -BinaryPathName "`"$kServiceBinaryPath`" $startupArgs" \
            -Name $kServiceName \
            -DisplayName $kServiceName \
            -Description $kServiceDescription \
            -StartupType Automatic

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

@smithclay smithclay requested review from a team as code owners March 18, 2025 19:58
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Mar 18, 2025

CLA Signed


The committers listed above are authorized under a signed CLA.

Copy link
Member

@directionless directionless left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think good. Thank you so much!

@directionless directionless merged commit 0c952af into osquery:master Mar 25, 2025
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants