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

[Winlogbeat] XML filtering #1054

Closed
jimmyjones2 opened this issue Feb 27, 2016 · 8 comments · Fixed by #29330
Closed

[Winlogbeat] XML filtering #1054

jimmyjones2 opened this issue Feb 27, 2016 · 8 comments · Fixed by #29330

Comments

@jimmyjones2
Copy link

The Windows API allows XML filtering of events - so you can only subscribe to "useful" events rather than the general torrent, again something I've used heavily in the past with nxlog.

<QueryList>
  <Query Id="0">
    <Select Path="Security">*[System[(EventID='4663')]]</Select>
  </Query>
</QueryList>
@andrewkroh
Copy link
Member

#1218 adds the ability to do simple filtering based on event_id, provider, and level.

Before adding the ability to specify arbitrary XML queries which can read from multiple logs, we need to change how "bookmarks" are persisted. Currently "bookmarks" are limited to a single event log so if a query read from multiple logs we wouldn't be able to persist all of the read positions. So a change needs to be made to allow writing the read position of all logs involved in a query (probably we will just persist the Windows XML bookmark).

Once that change is made then we can allow XML queries to be used.

@prehor
Copy link

prehor commented May 13, 2016

We would like to switch to Winlogbeat but without better support for event filtering unfortunately we can not. On the other hand, we do not need the full functionality of XML filtering, which requires substantial modification in Winlogbeat, but we would be satisfied with the XPath Query used for individual events channel:

winlogbeat:
  event_logs:
    - Name: Security
      select:>
        * [System [(EventID=4624 or EventID=4625 or EventID=4648) and
        (Level=0 or Level = 4) and
        Provider [@ Name = 'Microsoft-Windows-Security-Auditing']]]
      supress:>
        * [System [(EventID = 4624)]] and (
        * [EventData [Data [@ Name = "TargetUserSid"] = "S-1-5-7"]] or
        * [EventData [Data [@ Name = "TargetUserSid"] = "S-1-5-18"]] or
        * [EventData [Data [@ Name = "TargetUserSid"] = "S-1-5-19"]] or
        * [EventData [Data [@ Name = "TargetUserSid"] = "S-1-5-20"]]
        )

where event_logs.select could be ORed with the XPath Query created using event_logs.eventid, event_logs.level and event_logs.provider or could be used mutually exclusive.

@adrwh
Copy link

adrwh commented Mar 17, 2017

Hows this coming along, is using xml filtering an option yet in winlogbeat?

@SpencerLN
Copy link
Contributor

Has there been any additional work on this? It is a crucial feature for most security monitoring use cases.

@mgoritzk
Copy link

mgoritzk commented Mar 5, 2019

Winlogbeat: please add the ability to parse nested XML. Currently only the "event_data" is not parsed when it's in XML format.

@andrewkroh
Copy link
Member

This issue isn't about parsing nested XML. It's about allowing the user to define a query using the native XML format accepted by Windows for selecting the events to subscribe to.

@andrewkroh
Copy link
Member

andrewkroh commented Nov 16, 2021

It should be possible to implement this now given that winlogbeat uses bookmarks in the registry. Each event log reader stores its state based on the name of the channel. In order to be able to persist the state of the XML based query, which can read from multiple channels, we should require that each reader have a unique ID.

  • Add a new xml_query config option to the event log reader. (TBD on the name, could be xml_filter?)
  • Validate the xml_query is not used with ignore_older, event_id, level, provider, and name. Any of these options should be embedded in the provided XML query.
  • Require that an id be specified when using xml_query. This will be used to uniquely store state in the registry. It can be optionally specified when using name to allow more than one reader on the same channel. In the registry, collisions between id and channel name should be prevented (e.g. add a prefix to all id values or store them separately from name).
  • winlogbeat test config should validate the XML query (to what extent is TBD, either check that it's valid XML or test loading the query into Windows).

@elasticmachine
Copy link
Collaborator

Pinging @elastic/security-external-integrations (Team:Security-External Integrations)

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

Successfully merging a pull request may close this issue.

9 participants