Back to Ruview

ADR-050: Quality Engineering Response — Security Hardening & Code Quality

docs/adr/ADR-050-quality-engineering-security-hardening.md

0.7.04.0 KB
Original Source

ADR-050: Quality Engineering Response — Security Hardening & Code Quality

FieldValue
StatusAccepted
Date2026-03-06
Decidersruv
Depends onADR-032 (Multistatic Mesh Security)
Issue#170

Context

An independent quality engineering analysis (issue #170) identified 7 critical findings across the Rust codebase. After verification against the source code, the following findings are confirmed and require action:

Confirmed Critical Findings

#FindingLocationVerified
1Fake HMAC in secure_tdm.rs — XOR fold with hardcoded keyhardware/src/esp32/secure_tdm.rs:253YES — comments say "sufficient for testing"
2sensing-server/main.rs is 3,741 lines — CC=65, god objectsensing-server/src/main.rsYES — confirmed 3,741 lines
3WebSocket server has zero authenticationRust WS codebaseYES — no auth/token checks found
4Zero security tests in Rust codebaseEntire workspaceYES — no auth/injection/tampering tests
554K fps claim has no supporting benchmarkNo criterion benchmarksYES — no benchmarks exist

Findings Requiring Further Investigation

#FindingStatus
6Unauthenticated OTA firmware endpointNot found in Rust code — may be ESP32 C firmware level
7WASM upload without mandatory signaturesNeeds review of WASM loader
8O(n^2) autocorrelation in heart rate detectionNeeds profiling to confirm impact

Decision

Address findings in 3 priority sprints as recommended by the report.

Sprint 1: Security (Blocks Deployment)

  1. Replace fake HMAC with real HMAC-SHA256 in secure_tdm.rs

    • Use the hmac + sha2 crates (already in Cargo.lock)
    • Remove XOR fold implementation
    • Add key derivation (no more hardcoded keys)
  2. Add WebSocket authentication

    • Token-based auth on WS upgrade handshake
    • Optional API key for local-network deployments
    • Configurable via environment variable
  3. Add security test suite

    • Auth bypass attempts
    • Malformed CSI frame injection
    • Protocol tampering (TDM beacon replay, nonce reuse)

Sprint 2: Code Quality & Testability

  1. Decompose main.rs (3,741 lines -> ~14 focused modules)

    • Extract HTTP routes, WebSocket handler, CSI pipeline, config, state
    • Target: no file over 500 lines
  2. Add criterion benchmarks

    • CSI frame parsing throughput
    • Signal processing pipeline latency
    • WebSocket broadcast fanout

Sprint 3: Functional Verification

  1. Vital sign accuracy verification

    • Reference signal tests with known BPM
    • False-negative rate measurement
  2. Fix O(n^2) autocorrelation (if confirmed by profiling)

    • Replace brute-force lag with FFT-based autocorrelation

Consequences

Positive

  • Addresses all critical security findings before any production deployment
  • main.rs decomposition enables unit testing of server components
  • Criterion benchmarks provide verifiable performance claims
  • Security test suite prevents regression

Negative

  • Sprint 1 security changes are breaking for any existing TDM mesh deployments (fake HMAC -> real HMAC requires firmware update)
  • main.rs decomposition is a large refactor with merge conflict risk

Neutral

  • The report correctly identifies that life-safety claims (disaster detection, vital signs) require rigorous verification — this is an ongoing process, not a single sprint

Acknowledgment

Thanks to @proffesor-for-testing for the thorough 10-report analysis. The full report is archived at the original gist.

References

  • Issue #170: Quality Engineering Analysis
  • ADR-032: Multistatic Mesh Security Hardening
  • ADR-028: ESP32 Capability Audit