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

Skip SID translation for capability SIDs #48

Merged
merged 2 commits into from
Aug 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions ext/winevt/winevt_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -885,14 +885,21 @@ render_system_event(EVT_HANDLE hEvent, BOOL preserve_qualifiers, BOOL preserveSI
if (preserveSID_p) {
rbstr = rb_utf8_str_new_cstr(pwsSid);
rb_hash_aset(hash, rb_str_new2("UserID"), rbstr);
LocalFree(pwsSid);
}
if (ExpandSIDWString(pRenderedValues[EvtSystemUserID].SidVal,
&expandSID) == 0) {
rbstr = rb_utf8_str_new_cstr(expandSID);
free(expandSID);
rb_hash_aset(hash, rb_str_new2("User"), rbstr);
/* S-1-15-3- is used for capability SIDs. So, we need to skip
* SID translation.
* ref: https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/manage/understand-security-identifiers
* See also: https://learn.microsoft.com/en-us/troubleshoot/windows-server/windows-security/sids-not-resolve-into-friendly-names
*/
if (strnicmp(pwsSid, "S-1-15-3-", 9) != 0) {
if (ExpandSIDWString(pRenderedValues[EvtSystemUserID].SidVal,
&expandSID) == 0) {
rbstr = rb_utf8_str_new_cstr(expandSID);
free(expandSID);
rb_hash_aset(hash, rb_str_new2("User"), rbstr);
}
}
LocalFree(pwsSid);
}
}

Expand Down
Loading