wifi-densepose/v2/crates/wifi-densepose-bfld/tests
rUv a369fbe66e
fix(bfld security): close HIGH privacy-bypass in process_to_frame (identity surface leaked despite restrictive class) + JSON-injection (#1075)
* fix(bfld): route process_to_frame payload through PrivacyGate (ADR-141 privacy bypass)

BfldPipeline::process_to_frame stamped the frame header with the active
privacy class but serialized the caller-supplied BfldPayload UNCHANGED via
BfldFrame::from_payload. This let a frame labeled Anonymous(2) or
Restricted(3) carry the full identity-leaky compressed_angle_matrix
(+ amplitude/phase proxies, csi_delta) that PrivacyGate::demote is documented
and tested (privacy_gate_demote.rs) to strip at exactly those classes.

A NetworkSink accepts class >= Derived(1), so such a frame would publish the
beamforming angle matrix — the identity surface — across the node boundary
despite its restrictive class byte. The class byte lied about payload content.

Fix: after building the frame at the active class, apply PrivacyGate::demote to
the same class. demote() strips sections by target-class threshold (independent
of any class transition), so a same-class demote performs no class change but
brings the payload into policy compliance. Research classes (Raw/Derived) keep
the full payload — demote is a no-op there.

Pinned by three fails-on-old tests in pipeline_to_frame.rs:
- process_to_frame_at_anonymous_strips_identity_leaky_sections (FAILED pre-fix)
- process_to_frame_in_privacy_mode_strips_amplitude_and_phase (FAILED pre-fix)
- process_to_frame_at_derived_preserves_full_payload (guards against over-strip)
The pre-existing round-trip test is updated to assert the gated payload.

Co-Authored-By: claude-flow <ruv@ruv.net>

* fix(bfld): JSON-escape zone_id in MQTT state-topic payload

render_events emitted the zone_activity payload as format!("\"{zone}\"") with no
escaping, while ha_discovery.rs already escapes operator-controlled strings via
push_str_field. A zone name containing a double-quote or backslash therefore
produced malformed / injectable JSON on the state topic that Home Assistant
parses (e.g. zone `a"b` -> payload `"a"b"`).

Fix: add json_string_literal() mirroring ha_discovery's escaping (", \, \n, \r,
\t, control chars) and use it for the zone payload. Value-identical for normal
zone names (living_room etc.).

Pinned by zone_payload_escapes_json_metacharacters (FAILED pre-fix); the
existing zone_payload_is_json_string_with_quotes still passes unchanged.

Co-Authored-By: claude-flow <ruv@ruv.net>

* docs(adr-141): record bfld privacy+security review findings + CHANGELOG

Document the two fixed bugs (process_to_frame privacy-bypass; zone_id JSON
injection) and the dimensions confirmed clean (event-field gating, witness/hash
framing, fail-closed) in ADR-141, plus CHANGELOG [Unreleased] Security/Fixed
entries.

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-06-14 16:15:42 -04:00
..
availability_topic.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
bfld_error_display.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
changelog_entry.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
ci_workflow.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
coherence_gate.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
crate_readme.rs fix(bfld): make README quickstart test robust to CRLF line endings 2026-05-31 04:27:25 -04:00
crc32_polynomial.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
embedding_ring.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
emitter_hasher.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
emitter_pipeline.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
event_gating_irreversibility.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
event_privacy_gating.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
example_handle.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
example_minimal.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
frame_header_size.rs feat(adr-118/p1): scaffold wifi-densepose-bfld crate + frame header (3/3 tests GREEN) 2026-05-24 13:34:05 -04:00
frame_payload_integration.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
frame_roundtrip.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
frame_trailing_bytes.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
gate_clock_skew.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
ha_blueprints.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
ha_discovery.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
ha_discovery_publish.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
handle_soul_oracle.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
header_roundtrip.rs feat(adr-118/p1.2): header encode/decode + 6 round-trip tests (9/9 GREEN) 2026-05-24 13:38:11 -04:00
identity_embedding.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
identity_features_encoder.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
identity_risk_score.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
json_hash_format.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
mosquitto_integration.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
motion_publish_rate.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
mqtt_publish_loop.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
mqtt_topic_routing.rs fix(bfld security): close HIGH privacy-bypass in process_to_frame (identity surface leaked despite restrictive class) + JSON-injection (#1075) 2026-06-14 16:15:42 -04:00
payload_sections.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
pipeline_determinism.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
pipeline_facade.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
pipeline_gate_observability.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
pipeline_handle_worker.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
pipeline_i3_isolation.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
pipeline_to_frame.rs fix(bfld security): close HIGH privacy-bypass in process_to_frame (identity surface leaked despite restrictive class) + JSON-injection (#1075) 2026-06-14 16:15:42 -04:00
presence_latency.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
privacy_class_capability.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
privacy_gate_demote.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
public_api_snapshot.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
reserved_flags.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
root_readme_link.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
rumqttc_lwt.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
rumqttc_publisher_smoke.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
serialization_throughput.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
signature_hasher.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
sink_enforcement.rs feat(adr-118/p1.3): Sink marker traits + PrivacyClass::try_from (17/17 GREEN) 2026-05-24 13:43:05 -04:00
soul_match.rs test(bfld): measured §3.6 separability + audit's cardiac-alone negative result 2026-06-11 21:16:20 -04:00
soul_match_oracle.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00
user_guide_section.rs feat(adr-118): BFLD — Beamforming Feedback Layer for Detection (#789) 2026-05-24 20:20:25 -04:00