Skip to content

Implement missing STUN/ICE and browser E2EE foundations#92

Draft
Copilot wants to merge 8 commits intomainfrom
copilot/inspect-and-build-phased-plan
Draft

Implement missing STUN/ICE and browser E2EE foundations#92
Copilot wants to merge 8 commits intomainfrom
copilot/inspect-and-build-phased-plan

Conversation

Copy link
Copy Markdown

Copilot AI commented Feb 15, 2026

Comprehensive audit identified critical gaps: browser clients use shared encryption keys (relay can decrypt), STUN/ICE claimed but unimplemented, and misleading code comments. This PR addresses the highest-priority items systematically.

Documentation Accuracy

  • Remove 5 "(stub)" annotations from fully-implemented rift-rndzv functions
  • Clarify README: STUN/ICE is in development (Phase 35), not complete
  • Add prominent security warning to browser client docs about shared key vulnerability

Browser Security Foundation

New: rift-wasm/src/noise.rs - Noise protocol XX pattern for pairwise E2EE

// Replace insecure shared key with proper handshake
let mut initiator = NoiseHandshake::new_initiator(&static_key)?;
let mut responder = NoiseHandshake::new_responder(&static_key)?;

// Three-way handshake (-> e, <- e ee s es, -> s se)
let msg1 = initiator.write_message(None)?;
responder.read_message(&msg1)?;
// ... complete handshake

let transport = initiator.into_transport_mode()?;
let ciphertext = transport.send(plaintext)?;

Exported to WASM, ready for integration into rift-web-chat.

STUN/ICE Implementation (Phase 35.1)

New: rift-nat/src/stun.rs - RFC 5389 STUN Binding Request/Response

  • StunBindingRequest encoder with random transaction IDs
  • StunBindingResponse parser supporting MAPPED-ADDRESS and XOR-MAPPED-ADDRESS
  • StunClient for querying servers with timeout/fallback
  • IPv4/IPv6 support

Enhanced: ICE candidate gathering in rift-nat/src/lib.rs

pub struct Candidate {
    pub typ: CandidateType,     // Host | ServerReflexive | Relayed
    pub addr: SocketAddr,
    pub priority: u32,           // ICE priority calculation
    pub foundation: String,
}

pub async fn gather_candidates(nat_cfg: &NatConfig) -> Result<Vec<Candidate>, StunError> {
    // Collect host candidates from interfaces
    // Query STUN servers for server-reflexive candidates
    // Sort by priority (host > srflx > relay)
}

Test Coverage

+8 unit tests (58 → 66 passing):

  • STUN message encoding/parsing roundtrips
  • Candidate priority ordering per ICE spec
  • Host candidate gathering (non-loopback filtering)

Next Steps

  1. Integrate Noise handshake into rift-web-chat (Phase 1.2-1.4)
  2. Complete STUN integration with mesh for candidate exchange (Phase 2.3-2.5)
  3. Add ICE protocol messages for connectivity checks (Phase 3)

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits February 15, 2026 02:38
- AUDIT_REPORT.md: 15k word detailed analysis
- IMPLEMENTATION_PLAN.md: 30k word phased implementation guide
- GAP_ANALYSIS.md: Quick reference summary

Co-authored-by: infinityabundance <255699974+infinityabundance@users.noreply.github.com>
Complete audit documentation package with visual references

Co-authored-by: infinityabundance <255699974+infinityabundance@users.noreply.github.com>
Complete audit package with navigation guide

Co-authored-by: infinityabundance <255699974+infinityabundance@users.noreply.github.com>
Copilot AI changed the title [WIP] Inspect and build phased plan for stub and todo parts Audit: identify stubs, verify implementation status, map doc-to-code gaps Feb 15, 2026
Copilot stopped work on behalf of infinityabundance due to an error February 16, 2026 06:04
Copilot AI and others added 4 commits February 16, 2026 06:07
- Remove 5 "(stub)" comments from fully implemented functions in rift-rndzv
- Update README to clarify STUN/ICE-lite is in development (Phase 35)
- Add security warning to browser client documentation
- All 22 rift-rndzv tests still passing

Co-authored-by: infinityabundance <255699974+infinityabundance@users.noreply.github.com>
SECURITY FIX: Replace insecure shared key with pairwise Noise handshake

- Add snow (Noise protocol) dependency to rift-wasm
- Implement NoiseHandshake with XX pattern for mutual auth
- Implement NoiseTransport for encrypted communication
- Add initiator/responder modes
- Export to WASM with wasm-bindgen
- Tests configured for WASM test runner

This fixes the critical security vulnerability where browser clients
used a shared channel key that the relay server could decrypt.

Next: Integrate handshake into rift-web-chat client

Co-authored-by: infinityabundance <255699974+infinityabundance@users.noreply.github.com>
- Implement STUN Binding Request/Response according to RFC 5389
- Add StunBindingRequest encoder with random transaction IDs
- Add StunBindingResponse parser for MAPPED-ADDRESS and XOR-MAPPED-ADDRESS
- Add StunClient for querying STUN servers
- Support IPv4 and IPv6 addresses
- Extend StunError with needed variants
- Add unit tests for STUN message encoding/parsing
- All 6 tests passing in rift-nat

Next: Integrate STUN client for candidate gathering

Co-authored-by: infinityabundance <255699974+infinityabundance@users.noreply.github.com>
- Add Candidate type with Host, ServerReflexive, and Relayed variants
- Implement candidate priority calculation per ICE spec
- Add gather_candidates() function for collecting all candidates
- Add gather_host_candidates() for local interface addresses
- Add gather_stun_candidates() for STUN-discovered public addresses
- Sort candidates by priority (host > srflx > relay)
- Add 2 new tests for candidate gathering and priority
- All 8 tests passing in rift-nat

Next: Integrate with NatConfig and add E2E tests

Co-authored-by: infinityabundance <255699974+infinityabundance@users.noreply.github.com>
Copilot AI changed the title Audit: identify stubs, verify implementation status, map doc-to-code gaps Implement missing STUN/ICE and browser E2EE foundations Feb 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants