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

Loss of data for EventData in Windows Event Logs #8298

Open
Demonslay335 opened this issue Mar 15, 2024 · 0 comments
Open

Loss of data for EventData in Windows Event Logs #8298

Demonslay335 opened this issue Mar 15, 2024 · 0 comments

Comments

@Demonslay335
Copy link

Demonslay335 commented Mar 15, 2024

Bug Report

When an Event Log on Windows contains EventData with Data nodes that are missing the Name attribute, and there are also other nodes (e.g. Binary), all Data nodes have their data saved as an object with the same key: "". This causes any JSON parsing library to condense the keys, overwriting data.

This is a result of this function, which detects whether to save the Data nodes all as an object with keys matching the Name attributes, or a single array.

The issue however, is that the non-Data nodes do not get this treatment. In the case where the Data nodes are treated as a combined array, but other nodes exist, they are added to the property tree as if it were an object; forcing it into being an object. Now, since it was an array, all existing elements now have an object key of "".

What operating system and version are you using?

 version = 10.0.19045
   build = 19045
platform = windows

What version of osquery are you using?

version = 5.11.0

What steps did you take to reproduce the issue?

  1. Run query against the event log. Any formatter works since the data itself is serialized as JSON no matter what.
osqueryi --json "SELECT * FROM windows_eventlog WHERE channel='Application' AND provider_name='MsiInstaller';"

Output:
{"channel":"Application","computer_name":"DESKTOP-LGPP4E9","data":"{\"EventData\":{\"\":\"Python 3.11.1 Core Interpreter (64-bit)\",\"\":\"3.11.1150.0\",\"\":\"1033\",\"\":\"0\",\"\":\"Python Software Foundation\",\"\":\"(NULL)\",\"\":\"\",\"Binary\":\"7B35443145464635312D343734302D344536322D384534392D3131433133444543333443337D3030303039333463656639663166653563346664393362366264366263323663636232303030303030393034\"}}","datetime":"2023-01-13T21:49:56.5321775Z","eventid":"1033","keywords":"0x80000000000000","level":"4","pid":"0","provider_guid":"","provider_name":"MsiInstaller","task":"0","tid":"0"}
  1. Unescape and isolate the data element.
{"EventData":{"":"Python 3.11.1 Core Interpreter (64-bit)","":"3.11.1150.0","":"1033","":"0","":"Python Software Foundation","":"(NULL)","":"","Binary":"7B35443145464635312D343734302D344536322D384534392D3131433133444543333443337D3030303039333463656639663166653563346664393362366264366263323663636232303030303030393034"}}
  1. Put thru any JSON parser or pretty-printer.
{
    "EventData": {
        "": "",
        "Binary": "7B35443145464635312D343734302D344536322D384534392D3131433133444543333443337D3030303039333463656639663166653563346664393362366264366263323663636232303030303030393034"
    }
}

What did you expect to see?

All data from the EventData element.

What did you see instead?

An empty object with only valid data from the Binary node.

Possible Fixes

I see two possible fixes for this:

  1. Add an additional level to the EventData object called Data. This would prevent other nodes from forcing it into an object when it was an array.

Result:

{
    "EventData": {
        "Binary": "7B35443145464635312D343734302D344536322D384534392D3131433133444543333443337D3030303039333463656639663166653563346664393362366264366263323663636232303030303030393034",
        "Data": [
            "Python 3.11.1 Core Interpreter (64-bit)",
            "3.11.1150.0",
            "1033",
            "0",
            "Python Software Foundation",
            "(NULL)",
            ""
        ]
    }
}

I see this as the easier and more consistent route, but understand it could break dependencies if anyone is actually parsing this. It would also be applied recursively, since it seems Data nodes can exist under other children nodes of EventData as well.

  1. Make non-Data nodes adhere to the as_array logic and merge.

Result:

{
    "EventData": [
        "Python 3.11.1 Core Interpreter (64-bit)",
        "3.11.1150.0",
        "1033",
        "0",
        "Python Software Foundation",
        "(NULL)",
        "",
        "7B35443145464635312D343734302D344536322D384534392D3131433133444543333443337D3030303039333463656639663166653563346664393362366264366263323663636232303030303030393034"
    ]
}

This would break any context of those extra nodes though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant