Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extensions can no longer be started by osquery on Windows #7324

Closed
sroache opened this issue Sep 23, 2021 · 0 comments · Fixed by #7355
Closed

Extensions can no longer be started by osquery on Windows #7324

sroache opened this issue Sep 23, 2021 · 0 comments · Fixed by #7355
Labels
bug extensions Related to osquery extension SDK or to extensions themselves Windows
Milestone

Comments

@sroache
Copy link

sroache commented Sep 23, 2021

Bug report

What operating system and version are you using?

+------------+-------+----------+
| version    | build | platform |
+------------+-------+----------+
| 10.0.17763 | 17763 | windows  |
+------------+-------+----------+

but this is not limited to specific windows versions

What version of osquery are you using?

+---------+
| version |
+---------+
| 5.0.1   |
+---------+

What steps did you take to reproduce the issue?

Run osquery.exe --allow_unsafe --extension=testExtension.exe

What did you expect to see?

The extension should have been launched and registered with osquery so that the tables were available to query.

What did you see instead?

The extension was not launched.
This appears to be because of a recent change - 9266838#diff-976be69b93d9364552ca301a07c92b98a8a9486767f3f546812772a1e81aadbd.
On Windows the checkStatus call that is used to determine if the process has ever run or is currently running calls GetExitCodeProcess which when called with invalid handle (the default of the id_ for the process not launched yet) returns STILL_ALIVE (https://github.com/osquery/osquery/blob/master/osquery/process/windows/process.cpp#L100) This causes ext_valid to be true and the extension never launched.

This can be shown with:

int main()
{
	DWORD exit;
	auto res = GetExitCodeProcess(INVALID_HANDLE_VALUE, &exit);
	if (res == 0)
	{
		std::cout << "FAIL " << GetLastError();
	}
	else
	{
		std::cout << "EXIT - " << exit;
	}
}

which prints 'EXIT - 259' which is STILL_ALIVE (https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getexitcodeprocess)

@mike-myers-tob mike-myers-tob added bug extensions Related to osquery extension SDK or to extensions themselves triage Issue needs to be verified, reproduced and prioritized Windows labels Sep 23, 2021
@directionless directionless added this to the 5.1.0 milestone Sep 28, 2021
@mike-myers-tob mike-myers-tob removed the triage Issue needs to be verified, reproduced and prioritized label Oct 21, 2021
ameily added a commit to ameily/osquery that referenced this issue Oct 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug extensions Related to osquery extension SDK or to extensions themselves Windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants