-
Notifications
You must be signed in to change notification settings - Fork 21
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
Accept events which fail to parse when 'RenderedText' used #46
Comments
P.S. if anyone can point me in the right direction to actually get WEF to send me full events rather than truncated events I'd be very grateful 😃 |
Hi @dvas0004! I haven't come across such a situation 😞 . I do agree that it seems to be more a problem with the Windows event logging system rather than openwec. To confirm this statement and perhaps try to diagnose the problem:
As you said, not being able to parse an event will "block" the events stream from that machine for this subscription, which is undesirable in most cases. In fact, except for debugging openwec, I can't find any real-world use cases where the current behavior is better than what you're suggesting. I don't think that the event forwarder is going to "correct" the event it's trying to send because it gets a 500... So I don't even think it's necessary to make it configurable. If you are willing to create a PR, I would rename By the way, I would recommend using the |
It appears rendered properly:
(PS thanks didnt know about this util! 🙂) They are shown correct but without the
windows 11 with US lang. What may be pertinent is that it's windows "home" edition and not joined to a domain
i will have the opportunity of testing this later.. at the moment this happens on just one PC (my dev laptop)
no unexpected error messages
I agree... I modified the The resulting "bad" event looks like this after testing: {
"System":{
"Provider":{
"Name":"Microsoft-Windows-Security-Auditing",
"Guid":"{54849625-5478-4994-a5ba-3e3b0328c30d}"
},
"EventID":4798,
"Version":0,
"Level":0,
"Task":13824,
"Opcode":0,
"Keywords":"0x8020000000000000",
"TimeCreated":"2023-09-29T13:39:08.7234692Z",
"EventRecordID":980236,
"Correlation":{
"ActivityID":"{f59bb999-ec5b-0008-f6b9-9bf55becd901}"
},
"Execution":{
"ProcessID":1440,
"ThreadID":16952
},
"Channel":"Security",
"Computer":"xxxx_xps"
},
"EventData":{
"SubjectLogonId":"0x3e7",
"TargetDomainName":"xxxxx_xps",
"CallerProcessId":"0x28d4",
"CallerProcessName":"C:\\\\Windows\\\\System32\\\\svchost.exe",
"TargetUserName":"davev",
"SubjectDomainName":"WORKGROUP",
"SubjectUserName":"xxxxx_XPS$",
"TargetSid":"S-1-5-21-1604529354-1295832394-4197355770-1001",
"SubjectUserSid":"S-1-5-18"
},
"OpenWEC":{
"IpAddress":"127.0.0.1",
"TimeReceived":"2023-09-29T14:33:12.574363325+00:00",
"Principal":"demo-client",
"Subscription":{
"Uuid":"91E05B32-F8F6-48CF-8AB4-4038233B83AC",
"Version":"523D1886-E73E-4A96-A95D-F0326CB282F0",
"Name":"my-test-subscription"
},
"Errors":{
"OriginalContent":"<Event xmlns='http://schemas.microsoft.com/win/2004/08/events/event'><System><Provider Name='Microsoft-Windows-Security-Auditing' Guid='{54849625-5478-4994-a5ba-3e3b0328c30d}'/><EventID>4798</EventID><Version>0</Version><Level>0</Level><Task>13824</Task><Opcode>0</Opcode><Keywords>0x8020000000000000</Keywords><TimeCreated SystemTime='2023-09-29T13:39:08.7234692Z'/><EventRecordID>980236</EventRecordID><Correlation ActivityID='{f59bb999-ec5b-0008-f6b9-9bf55becd901}'/><Execution ProcessID='1440' ThreadID='16952'/><Channel>Security</Channel><Computer>dvas0004_xps</Computer><Security/></System><EventData><Data Name='TargetUserName'>davev</Data><Data Name='TargetDomainName'>xxxxx_xps</Data><Data Name='TargetSid'>S-1-5-21-1604529354-1295832394-4197355770-1001</Data><Data Name='SubjectUserSid'>S-1-5-18</Data><Data Name='SubjectUserName'>xxxxx_XPS$</Data><Data Name='SubjectDomainName'>WORKGROUP</Data><Data Name='SubjectLogonId'>0x3e7</Data><Data Name='CallerProcessId'>0x28d4</Data><Data Name='CallerProcessName'>C:\\\\Windows\\\\System32\\\\svchost.exe</Data></EventData><RenderingInfo Culture='en-US'><Message>A user's local group membership was enumerated. Subject: 	",
"ErrorMessage":"Failed to parse event XML"
}
}
} if you like this approach i'll issue a PR next week 🙂otherwise i'll revert the behavior to not sending an empty
you are very right... though after a very quick survey of SOC analyst colleagues, they find the rendered field very useful, and they would like to keep it if possible.... |
The fact that the Event Viewer formats it correctly is unexpected. I would assume that the code that builds
I installed a Windows 11 Home VM, version 22H2 (build 22621.1413) with the US language pack, but I couldn't reproduce the problem...
The "best effort" approach is interesting, especially if the problem occurs regularly (does it?). The Event schema specifies that
|
What do you think of the following implementation: vruello@92f20d3? I've used the data you provided to create test cases, I hope it's ok for you. |
Edition Windows 11 Home
That's right! Though I doubt the issue is here, as there is no indication of HTTP(S) level issues... the event isnt exactly truncated, only the
Worth noting I see the same issue on both outputs (files and redis)...
This is phenomenal - nicely done!!!! 💪
On my test setup, almost all the "security" event have this issue, but i suspect it's because these issues tend to have a lot of newlines and tabs in their rendered content. So it happens very often - in fact I came up my initial implementation of the "recoverable error" to see if it affected all event or just some.... (it affects some, but not all) |
Could you enable the This is a bit more work on your end, but it would be interesting to see what happens with an official Windows "wec" server. I would happily do it myself but for now I can't reproduce the problem... |
Confirming it's already malformed there:
time permitting i'll try this and let you know 🙂 |
Hi @dvas0004! Have you found some time to try and reproduce this behavior with a Windows Server WEC? |
hey @vruello !!! unfortunately not 😟😟 but please keep this issue on me and I will try especially if I manage to get a test setup up |
There seem to be instances when if
--content-format RenderedText
is used in a subscription, windows doesn't send properly formatted XML messages. This in turn causes oenwec to return HTTP error 500 back to the source as it fails to parse the XML (as expected) :I double checked and I very much doubt the malformed XML is an openwec problem (i'd be happy to hear otherwise), but if you turn on tracing you'll observe that the underlying hyper server reports receiving a malformed payload - which happens before openwec does much processing:
In the above screenshot note how the event is sent with a truncated
RenderingInfo
XML tag, though it is correct encapsulated in a SOAP event... again leading me to suspect this is a windows problem rather than openwec. This doesnt happen with all events. The same source on the same subscription will send properly formatted events - the issue seems related to those events which contain tabs/newlines/etc in their rendered info (such as most security events)In this kind of situation, it might be beneficial to accept the event anyway but mark it as malformed, while saving the original content. Like that the source can keep on sending events (rather than stopping at an HTTP 500), and admins can troubleshoot why an event was not accepted.
I realise this is not ideal in all environments since it depends on your use case... in which case maybe the behavior can be controlled by a CLI flag?
I am using this branch to address the above (though the behavior is hardcoded rather than behind a flag as I suggested): https://github.com/CyberSift/openwec/tree/flexible_error
In this branch if the event contains a malformed event it is anyway stored, but we modified the fields stored to contain an error message and the original event content, for example, note the new
Error
field containing theErrorMessage
andOriginalContent
fields:The text was updated successfully, but these errors were encountered: