Skip to content

Commit 337dc8f

Browse files
jamieknvidiaaraza008
authored andcommitted
feat(mxc): map remaining Sandboxing ETW events to OCSF
Close the last three ETW->OCSF gaps so the audit trail covers the full set of events the Sandboxing provider emits (12/12): - ProcessLaunched -> Process Activity [1007] "Launch" (confirmed start; carries the real processId/threadId, the twin of CreateProcessInSandbox which only has the request + command line). - SandboxProxyConfigured -> Device Config State Change [5019] (the one network-plane setup event; surfaces proxyPort, "no proxy" when 0). - SandboxConsoleReferencePlumbed -> Device Config State Change [5019] (console-handle plumbing). map_config_state now handles the full config/hardening/setup family and carries proxyPort/hasConsoleReference/creationFlags as unmapped fields. Verified on 7F203-MXC-001: 11/12 event types emit OCSF without a proxy (SandboxProxyConfigured requires proxy config to fire). Signed-off-by: Akber Raza <akberr@nvidia.com>
1 parent 2015c2b commit 337dc8f

1 file changed

Lines changed: 71 additions & 14 deletions

File tree

‎crates/openshell-driver-mxc/src/etw_consumer.rs‎

Lines changed: 71 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -974,12 +974,24 @@ fn process_event(index: &Mutex<AttributionIndex>, ev: DecodedEtwEvent) {
974974
tracing::debug!(target: "mxc_etw", pid = ev.process_id, sandbox_id = %sandbox_id, "{}", ev.summary());
975975
}
976976
}
977-
// Config [5019]: several distinct config/hardening state changes. Each is
978-
// a genuine audit-worthy config event; `SandboxConfig` is the richest but
977+
// Process [1007]: `ProcessLaunched` is the confirmation twin of
978+
// `CreateProcessInSandbox` — it carries the *actual* `processId`/`threadId`
979+
// of the started in-sandbox process (the create event only has the request +
980+
// command line). We emit it as a distinct PROC row so the trail records both
981+
// the launch request (with cmd line) and the confirmed start (with real pid).
982+
"ProcessLaunched" => {
983+
let ctx = etw_ctx(&sandbox_id, &sandbox_name);
984+
emit_ocsf(&sandbox_id, map_process_started(&ctx, &ev));
985+
}
986+
// Config [5019]: several distinct config/hardening/setup state changes. Each
987+
// is a genuine audit-worthy config event; `SandboxConfig` is the richest but
979988
// drops intermittently, so the reliably-captured hardening events
980989
// (`Win32kLockdownApplied`, `ApplyUILimits`, `EnforceOsPolicy`) guarantee
981-
// coverage.
982-
"SandboxConfig" | "Win32kLockdownApplied" | "ApplyUILimits" | "EnforceOsPolicy" => {
990+
// coverage. `SandboxProxyConfigured` (network/proxy setup — the one
991+
// network-plane event the provider emits) and `SandboxConsoleReferencePlumbed`
992+
// (console-handle plumbing) are additional per-sandbox setup state changes.
993+
"SandboxConfig" | "Win32kLockdownApplied" | "ApplyUILimits" | "EnforceOsPolicy"
994+
| "SandboxProxyConfigured" | "SandboxConsoleReferencePlumbed" => {
983995
let ctx = etw_ctx(&sandbox_id, &sandbox_name);
984996
emit_ocsf(&sandbox_id, map_config_state(&ctx, &ev));
985997
}
@@ -1012,12 +1024,15 @@ fn map_lifecycle_create(ctx: &SandboxContext, sandbox_name: &str) -> OcsfEvent {
10121024
.build()
10131025
}
10141026

1015-
/// A sandbox config/hardening ETW event → Device Config State Change [5019].
1027+
/// A sandbox config/hardening/setup ETW event → Device Config State Change [5019].
10161028
///
1017-
/// Handles both `SandboxConfig` (full posture snapshot) and
1018-
/// `Win32kLockdownApplied` (agentic win32k lockdown): whichever config-ish
1019-
/// fields the event carries ride along as `unmapped`, and `security_level`
1020-
/// reflects any hardening signal present.
1029+
/// Handles the full family of per-sandbox config state changes the Sandboxing
1030+
/// provider emits: `SandboxConfig` (full posture snapshot), the hardening events
1031+
/// (`Win32kLockdownApplied`, `ApplyUILimits`, `EnforceOsPolicy`),
1032+
/// `SandboxProxyConfigured` (network/proxy setup) and
1033+
/// `SandboxConsoleReferencePlumbed` (console-handle plumbing). Whichever
1034+
/// config-ish fields the event carries ride along as `unmapped`, and
1035+
/// `security_level` reflects any hardening signal present.
10211036
fn map_config_state(ctx: &SandboxContext, ev: &DecodedEtwEvent) -> OcsfEvent {
10221037
let flag = |k: &str| ev.get(k).map(|v| v == "1").unwrap_or(false);
10231038
let nonzero = |k: &str| ev.get(k).map(|v| v != "0").unwrap_or(false);
@@ -1029,10 +1044,17 @@ fn map_config_state(ctx: &SandboxContext, ev: &DecodedEtwEvent) -> OcsfEvent {
10291044
};
10301045

10311046
let message = match ev.event_name.as_deref().unwrap_or("") {
1032-
"Win32kLockdownApplied" => "MXC sandbox win32k lockdown applied",
1033-
"ApplyUILimits" => "MXC sandbox UI restrictions applied",
1034-
"EnforceOsPolicy" => "MXC sandbox OS policy enforced",
1035-
_ => "MXC sandbox OS policy configured",
1047+
"Win32kLockdownApplied" => "MXC sandbox win32k lockdown applied".to_string(),
1048+
"ApplyUILimits" => "MXC sandbox UI restrictions applied".to_string(),
1049+
"EnforceOsPolicy" => "MXC sandbox OS policy enforced".to_string(),
1050+
"SandboxConsoleReferencePlumbed" => "MXC sandbox console reference plumbed".to_string(),
1051+
// The one network-plane event the provider emits; `proxyPort=0` means no
1052+
// proxy was configured. Surface the port so the CONFIG row is self-describing.
1053+
"SandboxProxyConfigured" => match ev.get_unquoted("proxyPort").as_deref() {
1054+
Some("0") | None => "MXC sandbox proxy configured (no proxy)".to_string(),
1055+
Some(port) => format!("MXC sandbox proxy configured (port {port})"),
1056+
},
1057+
_ => "MXC sandbox OS policy configured".to_string(),
10361058
};
10371059

10381060
let mut builder = ConfigStateChangeBuilder::new(ctx)
@@ -1042,7 +1064,7 @@ fn map_config_state(ctx: &SandboxContext, ev: &DecodedEtwEvent) -> OcsfEvent {
10421064
.status(StatusId::Success)
10431065
.message(message);
10441066

1045-
// Superset of config-ish fields across both event shapes; only present
1067+
// Superset of config-ish fields across all event shapes; only present
10461068
// fields are attached.
10471069
for key in [
10481070
"useAppContainer",
@@ -1055,6 +1077,9 @@ fn map_config_state(ctx: &SandboxContext, ev: &DecodedEtwEvent) -> OcsfEvent {
10551077
"capabilities",
10561078
"agenticFlags",
10571079
"processId",
1080+
"proxyPort",
1081+
"hasConsoleReference",
1082+
"creationFlags",
10581083
] {
10591084
if let Some(v) = ev.get(key) {
10601085
builder = builder.unmapped(key, v.trim_matches('"').to_string());
@@ -1091,6 +1116,38 @@ fn map_process_launch(ctx: &SandboxContext, ev: &DecodedEtwEvent, cmd_line: &str
10911116
.build()
10921117
}
10931118

1119+
/// `ProcessLaunched` → Process Activity [1007] "Launch" (confirmed start).
1120+
///
1121+
/// Unlike `CreateProcessInSandbox` (the request, which carries the command line
1122+
/// but not the resulting pid), this event carries the real `processId`/`threadId`
1123+
/// of the process that actually started. We give the process a distinct name
1124+
/// (`sandboxed-process`) so the shorthand row is visibly the confirmed-start twin,
1125+
/// not a duplicate of the launch-request row.
1126+
fn map_process_started(ctx: &SandboxContext, ev: &DecodedEtwEvent) -> OcsfEvent {
1127+
let pid = ev
1128+
.get("processId")
1129+
.map(|v| v.trim_matches('"'))
1130+
.and_then(|v| v.parse::<i64>().ok())
1131+
.unwrap_or(0);
1132+
let tid = ev.get_unquoted("threadId").unwrap_or_default();
1133+
let tid_suffix = if tid.is_empty() {
1134+
String::new()
1135+
} else {
1136+
format!(", tid: {tid}")
1137+
};
1138+
ProcessActivityBuilder::new(ctx)
1139+
.activity(ActivityId::Open) // process label = "Launch"
1140+
.launch_type(LaunchTypeId::Spawn)
1141+
.action(ActionId::Allowed)
1142+
.disposition(DispositionId::Allowed)
1143+
.severity(SeverityId::Informational)
1144+
.status(StatusId::Success)
1145+
.process(Process::new("sandboxed-process", pid))
1146+
.actor_process(Process::new("wxc-exec", i64::from(ev.process_id)))
1147+
.message(format!("MXC sandbox process started (pid: {pid}{tid_suffix})"))
1148+
.build()
1149+
}
1150+
10941151
/// `ActivityError` / `FallbackError` → Detection Finding [2004] (informational).
10951152
fn map_finding(ctx: &SandboxContext, ev: &DecodedEtwEvent) -> OcsfEvent {
10961153
let kind = ev.event_name.as_deref().unwrap_or("SandboxError");

0 commit comments

Comments
 (0)