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

Wrong schema retrieval with TraceLogging events #193

Open
tomer-gavish opened this issue Jul 13, 2022 · 2 comments
Open

Wrong schema retrieval with TraceLogging events #193

tomer-gavish opened this issue Jul 13, 2022 · 2 comments

Comments

@tomer-gavish
Copy link

Since querying the schema can be a demanding task, a cache is used in krabs::schema_locator to speed up schema retrieval for future events.

The cache key is calculated using the following event attributes:

  • Provider ID
  • Event ID
  • Opcode
  • Level
  • Version

While for manifest-based ETW this should uniquely identify an event, this is not the case for TraceLogging, as mentioned in the docs:

For manifest-free ETW (i.e. TraceLogging), the Id field is usually not meaningful and will normally be set to 0. TraceLogging events are generally identified by their event name, not the event ID.

The result is that two events emitted by the same provider with the default level and opcode are considered to have the same schema, which is clearly wrong. Parsing the second event with the same trace_context (And hence the same schema_locator) will use the first event's schema, and will most probably fail if they don't share the same fields in the same order.

I would suggest adding the event name to the schema_key for TraceLogging events, but it is not available in the EVENT_RECORD struct before calling to TdhGetEventInformation, which is exactly the call we are trying to avoid.
Another option is to parse it from the relevant EVENT_HEADER_EXTENDED_DATA_ITEM struct, but is undocumented.

Would appreciate your help here - am I missing something?

Thanks

@matterpreter
Copy link

Bumping this. I'm running into the same issue in my code and can't process two events from the same Tracelogging provider.

@swannman
Copy link
Member

swannman commented Feb 9, 2024

Hi Matt, would it be possible to provide a minimal repro so we can investigate? Thanks!

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

3 participants