Repository navigation
feat: pair receivers with a code from the Mac and seal the signaling - #21
Conversation
Before this, any device on the network could stream the Mac's screen, take over another receiver's extended screen with its published device id, or move the Mac's monitors (security audit, run 1). Now a receiver must be let in by the owner, and everything it says to the host is protected. Pairing (crates/host/src/pairing.rs, crates/app/assets/pair.js): - The first connection asks the Mac to pair. The Mac shows a 6-digit code (a dialog in the app, the terminal otherwise) and the receiver asks for it. Both sides run SPAKE2 (the spake2 crate; pair.js matches it byte for byte), so the code never crosses the network and a listener has nothing to guess against. Three wrong codes end the attempt; a code lasts 2 min. - The host then gives the receiver its own device id and a 32-byte secret, sealed with the SPAKE2 key, after proving it knew the code as well. The Mac keeps them in ~/Library/Application Support/Mullion/paired.json (0600). - Every connection: a one-time challenge, then the offer sealed with keys from the secret and the challenge (ChaCha20-Poly1305), and the answer sealed back. Unpaired offers, replays and tampering are refused. The SDP carries the DTLS fingerprints, so the video's own encryption is now bound to the paired ends. - /devices, /screens and /screens/layout take a request signed with the secret (X-Mullion-Auth), or come from this Mac itself (loopback without a foreign Origin), so the menu's Arrange Screens still works. - Menu: Forget Paired Devices… ends every session and makes each device pair again. - The page has no crypto.subtle over plain http, so the primitives come from @noble/curves, hashes and ciphers 2.4.0, vendored by tools/vendor-crypto/build.sh from a lockfile (vendor/noble.js, 50 KB). Also from the audit: - A crafted offer made str0m panic while the shared session lock was held, which poisoned it and took signaling and the menu down until restart. The offer is now built under catch_unwind and the lock recovers from poisoning; the crashing offer is a regression test. - The Host header reaches the receiver page only as address characters. Checked: 68 tests pass, including a Rust test with vectors from pair.js for SPAKE2, the sealed offer and the request signature, and an HTTP test of the whole flow. In Chrome against a dev host: wrong code (2 tries left), right code, streaming; reconnect without a code; unsigned /screens and plain offers refused.
EvidenceI captured this on 2026-11-12 against a dev host built from this branch, with the receiver page open in Chrome on the same Mac. The files are in For privacy, the Mac's host name is shown as 1. First connection: the page asks for the code the Mac shows 2. A wrong code uses up one of three tries 3. Host log ( 4. Checks from the page (
5. Tests ( 68 tests pass, including:
6. CI on this PR: macOS, Windows and Android builds all pass. Not shown: the Mac app's code dialog (the dev host printed the code to the terminal), and the Windows and Android apps by hand. The beta built from this merge will cover those. |
Evidence: where the code comes fromThe code is shown on the Mac the device connects to. To capture it, I built Mullion.app from this branch, signed it like the releases, and ran it as the menu bar app on port 47201, next to the installed one. The device was the receiver page in Chrome, named "iPad test". Files: 1. The device asks to pair, and the Mac shows the code 2. The person types that code on the device 3. Paired and streaming, and the dialog closed by itself ( The page showed The Mac's host name is replaced with |
|
❌ The last analysis has failed. |
![Code prompt: 'Code shown on [Mac name]' with a 6-digit field, Pair and Cancel](https://github.com/th3r-dev/mullion/raw/46ac98e4bcd2b85ce99d771047f2f91a13403262/docs/evidence/pairing/2-code-prompt.png)



Fixes the three high findings from the security audit (run 1). Today any device on the network can:
What changes for people
How it works
spake2crate on the host.pair.jsmatches it byte for byte, and a Rust test checks that against vectors frompair.js.paired.jsonwith mode0600.401./devices,/screensand/screens/layoutneed a request signed with the device secret, or must come from the Mac itself (loopback, with no foreign Origin).crypto.subtleover plain HTTP. The primitives come from@noble/*2.4.0, vendored from a lockfile bytools/vendor-crypto/build.sh.str0moffer handling runs undercatch_unwind, and the session lock recovers from poisoning. The offer that crashed it is now a regression test.Testing
cargo testpasses (68 tests)./screens./screensand plain offers are refused.Not in this PR
The audit's other findings come in a follow-up PR:
/nearbyrunning one sweep at a time, plus thehellodeadline;nilcrash.