feat(mxc): warn when the ETW consumer receives zero provider events - #3499
Open
pkhodade-NV wants to merge 1 commit into
Open
pkhodade-NV wants to merge 1 commit into
pkhodade-NV wants to merge 1 commit into
Conversation
EnableTraceEx2 succeeding only proves the request to enable the Sandboxing provider succeeded, not that the provider exists on this host/build or will ever fire. A provider-identity mismatch or a non-firing provider left the ETW->OCSF audit trail silently empty across real, successful sandbox lifecycles, with no error, warning, or diagnostic anywhere. Track raw provider-matched events received per session and add a zero-events watchdog on the consumer thread: once real sandbox activity has happened (register_launch called at least once) and a grace period elapses with zero events matched, log a warning and emit a Detection Finding [2004] naming the gap. Gated on actual activity (not just session uptime) so an idle gateway with etw_audit=true and no sandboxes created never warns. Also exposes EtwSession::events_received() alongside the existing is_capture_alive(), so a status/diagnostics surface can query capture health directly, not just infer it from tracing output. The watchdog's decision logic is extracted into a pure function (should_warn_zero_events) so it's unit-testable without a real ETW session or elevation. Signed-off-by: Prashant Khodade <pkhodade@nvidia.com> (cherry picked from commit 4fcfa716a808eaa91c6476e9c69366f91702b1fa)
pkhodade-NV
requested review from
a team,
derekwaynecarr,
mrunalp and
sjenning
as code owners
September 20, 2026 15:12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
EnableTraceEx2/StartTraceWboth reported success, the consumer thread ran correctly, but zero OS-sourced events were ever decoded across two full, successful sandbox lifecycles -- with no error, warning, or diagnostic anywhere pointing at why.EnableTraceEx2success only proves the request to enable the provider succeeded, not that the provider exists on this host/build or will ever actually fire. A provider-identity mismatch (or a non-firing provider) left the audit trail silently empty. This PR is specifically about detection and surfacing, not diagnosing the underlying GUID/provider question, which is an environment/OS-build question outside what static code changes can resolve.Related Issue
No linked issue -- this is a localized observability fix (a missing diagnostic for an existing, real failure mode) to the MXC ETW consumer.
Changes
etw_consumer.rs:CaptureHealthgains anevents_matched: AtomicU64counter, incremented on the consumer thread for every raw event that made it through the callback's provider-GUID filter, regardless of whether TDH decode later succeeds. Exposed via a newEtwSession::events_received()accessor, alongside the existingis_capture_alive().AttributionIndexgains atotal_launchescounter (never decremented byforget), so the watchdog can tell "real sandbox activity has happened" apart from "the index is currently non-empty" (whichforgetclears on every normal sandbox completion).total_launches() > 0and a generous grace period (30s) elapses withevents_matchedstill at zero, log atracing::warn!with an actionable message and emit a Detection Finding [2004] (severity: High,is_alert: true) into the OCSF stream itself, so the gap is visible in the audit log the same way the driver's own internal events already are.etw_audit=truethat simply hasn't created any sandboxes yet never warns -- only "activity happened, nothing arrived" does.should_warn_zero_events) is extracted into a small pure function, so it's directly unit-testable without a real ETW session or elevation.Testing
total_launches_survives_forget,zero_events_watchdog_stays_quiet_without_sandbox_activity,zero_events_watchdog_stays_quiet_once_any_event_matched,zero_events_watchdog_waits_out_the_grace_period,zero_events_watchdog_fires_once_grace_elapses.cargo test -p openshell-driver-mxc --target x86_64-pc-windows-msvc --lib.Checklist
Originally opened as GitLab MR !117 against our internal mirror; re-opened here against
windowsfor upstream review. Rebased ontowindows's independently-evolvedetw_consumer.rs(queue-overload reporting, PID-reuse rewrite, and byte-tracking additions that landed there since this MR was authored) -- both sets of changes are preserved side by side.