Skip to content

Commit 5e1d6ee

Browse files
authored
Merge pull request #48 from fluent-plugins-nursery/skip-sid-translation-for-capability-sids
Skip SID translation for capability SIDs
2 parents 792555a + f09c877 commit 5e1d6ee

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

ext/winevt/winevt_utils.cpp

+13-6
Original file line numberDiff line numberDiff line change
@@ -885,14 +885,21 @@ 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+
* ref: https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/manage/understand-security-identifiers
892+
* See also: https://learn.microsoft.com/en-us/troubleshoot/windows-server/windows-security/sids-not-resolve-into-friendly-names
893+
*/
894+
if (strnicmp(pwsSid, "S-1-15-3-", 9) != 0) {
895+
if (ExpandSIDWString(pRenderedValues[EvtSystemUserID].SidVal,
896+
&expandSID) == 0) {
897+
rbstr = rb_utf8_str_new_cstr(expandSID);
898+
free(expandSID);
899+
rb_hash_aset(hash, rb_str_new2("User"), rbstr);
900+
}
895901
}
902+
LocalFree(pwsSid);
896903
}
897904
}
898905

0 commit comments

Comments
 (0)