Skip to content

Commit 2fae082

Browse files
committed
Skip SID translation for capability SIDs
Signed-off-by: Hiroshi Hatake <[email protected]>
1 parent 792555a commit 2fae082

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

ext/winevt/winevt_utils.cpp

+12-6
Original file line numberDiff line numberDiff line change
@@ -885,14 +885,20 @@ render_system_event(EVT_HANDLE hEvent, BOOL preserve_qualifiers, BOOL preserveSI
885885
if (preserveSID_p) {
886886
rbstr = rb_utf8_str_new_cstr(pwsSid);
887887
rb_hash_aset(hash, rb_str_new2("UserID"), rbstr);
888-
LocalFree(pwsSid);
889888
}
890-
if (ExpandSIDWString(pRenderedValues[EvtSystemUserID].SidVal,
891-
&expandSID) == 0) {
892-
rbstr = rb_utf8_str_new_cstr(expandSID);
893-
free(expandSID);
894-
rb_hash_aset(hash, rb_str_new2("User"), rbstr);
889+
/* S-1-15-3- is used for capability SIDs. So, we need to skip
890+
* SID translation.
891+
* See also: https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/manage/understand-security-identifiers
892+
*/
893+
if (strnicmp(pwsSid, "S-1-15-3-", 9) != 0) {
894+
if (ExpandSIDWString(pRenderedValues[EvtSystemUserID].SidVal,
895+
&expandSID) == 0) {
896+
rbstr = rb_utf8_str_new_cstr(expandSID);
897+
free(expandSID);
898+
rb_hash_aset(hash, rb_str_new2("User"), rbstr);
899+
}
895900
}
901+
LocalFree(pwsSid);
896902
}
897903
}
898904

0 commit comments

Comments
 (0)