Skip to content

Commit cafbeb1

Browse files
authored
fix(wasm-edge): sanitize non-finite host floats at the WASM↔host frame boundary (ruvnet#1102)
Closing beyond-SOTA security review of wifi-densepose-wasm-edge (ADR-040, ~70 edge modules). The two WASM↔host boundaries (lib.rs::on_frame/on_timer and bin/ghost_hunter.rs::on_frame) read raw IEEE-754 f32 from the csi_get_* imports with no finiteness check — the crate had zero is_finite/is_nan guards and its clamp helpers propagate NaN. A single non-finite host value latches NaN into long-lived per-module accumulators (EMA / Welford / phasor sums / anomaly baselines), after which detectors fail degraded (stuck gate state, silently-disabled checks) — silent corruption, not a crash. Add sanitize_host_f32() (non-finite -> 0.0, core-only for no_std) applied at every host_get_* float read: one chokepoint covering all downstream modules, mirroring the existing M-01 negative-n_subcarriers boundary clamp. LOW / defense-in-depth (the Tier-2 DSP firmware supplies the imports, a semi-trusted boundary). Pinned by boundary_tests::{sanitize_passes_finite_values_through, sanitize_maps_non_finite_to_zero, coherence_monitor_nan_latches_without_sanitize_but_not_with} — the last asserts on the current CoherenceMonitor that a raw NaN frame latches the smoothed score while the sanitized path stays finite. Other review dimensions attested clean with evidence (see CHANGELOG): no hot-path panics (all unwrap/expect are test-only or std-gated RVF builder), all bounds min()-clamped, all index-by-cast const-bounded or guarded, no leaking closures (no move||/forget/leak), no secrets. Verified: host `cargo test --features std,medical-experimental` 672 passed / 0 failed (+3 new tests); all three wasm32-unknown-unknown release artifacts build clean (lib default no_std/panic=abort, ghost_hunter standalone-bin, medical-experimental); Python proof VERDICT PASS, hash unchanged.
1 parent c859f6f commit cafbeb1

3 files changed

Lines changed: 103 additions & 7 deletions

File tree

0 commit comments

Comments
 (0)