Skip to content

Connect: end-to-end encrypt device traffic so Cloudflare only relays ciphertext #2542

Closed

Description

@DoodleBears

Why

Under ADR-0241, TLS on the Connect route ends at Cloudflare's edge. Cloudflare can therefore read every message, image, approval and secret exchanged between a phone or remote browser and the Host. Vain decided on 2026-10-21 not to accept that risk: Connect users get the same confidentiality that Tailscale users have. Connect has not shipped, so the protocol can still change.

#2541 blocks secrets on Connect in the meantime. This issue removes that block and protects everything else too.

Decided by Vain (2026-10-21): the phone drops the WebView full client

The phone's WebView full client loads its page code from the Host origin. Over Connect, that code crosses Cloudflare in plaintext and could be read or tampered with, so encrypting only the API calls would not be enough. Vain decided to remove the mobile full client entirely, on every route, not only on Connect. Everything the phone does goes through native screens over the encrypted channel.

Remove apps/mobile/src/ui/full-client-view.tsx, apps/mobile/src/host/full-client.ts, open-full-client.tsx, the /full-client route, their strings and apps/mobile/test/full-client.test.ts. Remove every entry point (paths as of main e6b367e5):

  • Settings: the "Open the full client" row (settings-view.tsx).
  • Chat page: the header button and overflow menu item (conversation-screen.tsx). Also the private input card's "安全填写" (onFill → /full-client, kind private-input). It needs a native private input form that submits over the encrypted channel.
  • Routines page: routine-screen.tsx (/full-client for a DM).
  • Activity / create menu: shell/bottom-navigation.tsx opens /full-client for "new Bot" and "new Channel" on a Host. These need native flows, or are hidden until those exist.

Anything that only the full client offered today must either get a native screen in the same change or be listed as a known gap with Vain's sign-off. That includes the PersonaBot Computer and Browser viewers, which are proxied under /botharness-device/web/. Their WebRTC signaling must also run over the encrypted channel.

On the Host, once no client uses it, remove the gateway's cookie-authenticated /botharness-device/web/ path, the web session cookie and DEVICE_WEB_MUX_PATH. The ADR also amends ADR-0242's note that keeps that path.

Direction (to settle in a new ADR that amends ADR-0241)

Pin the Host key at pairing.

  • The Host keeps a long-term X25519 identity key in the credentials service (machine-local and never in the repo).
  • Its public key travels in the pairing link payload (ADR-0199 and ADR-0242) and in the account pairing offer.
  • For account pairing (ADR-0241), the relay must not be able to swap the key. The offer is signed by the Host, or the phone shows a fingerprint for comparison. The ADR picks one.

Encrypt the session, not just fields. Over Connect, the client and Host run an authenticated key exchange against the pinned key, then carry the application stream as AEAD frames inside the existing HTTPS/WebSocket transport. Cloudflare sees only ciphertext and framing. Two candidate designs:

  1. Noise IK or XK over the remote.mux WebSocket. All unary calls and attachment transfers move onto the mux whenever the route is Connect. This gives forward secrecy and one channel to audit.
  2. HPKE (RFC 9180) with a sealed context per request. Simpler to bolt onto unary HTTP, but without forward secrecy.

The ADR picks one; option 1 is recommended. Libraries: @noble/curves and @noble/ciphers (pure JS: phone, browser and Node), or @hpke/core.

The Web Client remote chat (ADR-0242) is served by its own Host, so only its calls to the Remote Host need the channel. It uses the same shared apps/mobile/src/host/ client.

Bindings. Bind the transcript and AAD to hostId, the device ID and the route. Use a key exchange per connection, with no fallback to plaintext once a Host has advertised the capability. A Host on Connect refuses plaintext application calls.

Unchanged. Pairing credentials, revocation, content-free push (ADR-0202) and the Tailscale and loopback routes. Those routes may skip the extra layer.

Deliverables

  1. ADR (amending ADR-0241 and ADR-0242) with:
    • the decisions above;
    • the full client removal and the list of affected flows;
    • a threat model covering Cloudflare as a passive or active adversary, a compromised relay, a stolen Host key and a stolen phone.
  2. Remove the mobile full client and its entry points, adding native replacements (at least the private input form).
  3. Tracer bullet on the ADR-0241 rig: a phone over Connect opens a DM, sends an image, approves a tool call and submits a private input natively. A capture at the cloudflared origin listener shows no plaintext.
  4. Remove the Connect: refuse secret-bearing calls on the Connect route until it is end-to-end encrypted #2541 refusal once the phone and the Web Client remote chat both use the channel.
  5. CLI parity: deepseekbot connect status reports whether the channel is encrypted and the Host key fingerprint.

Reported by Vain.

Additional acceptance — adopted remote-transport research (2026-10-22)

Human approved these contract clarifications after reviewing ds-harness-remote at 28a2da05. Preserve this issue's existing implementation, chosen protocol, ADR and recorded evidence; this is not a request to restart crypto selection, replace the current owner or add a second device trust store. Already-covered items can point to exact-source tests and qualification evidence; missing coverage stays explicit.

  • Document how the existing pairing ceremony binds the intended Host/device to their keys, including first enrollment and account pairing. Later key pinning alone does not prove that the relay cannot substitute a key on first enrollment; do not weaken the existing Host-key verification requirement to automatic trust of a server descriptor.
  • Each fresh authenticated channel binds the intended Host, admitted device, protocol/route context and connection identity or equivalent fresh transcript generation. Stale channel messages, mismatched identity and key substitution are rejected before application effects; route/reconnect does not create new trust or revive a revoked device.
  • Endpoint-level negative tests cover tampering and replay, including replay after reconnect. Ensure hostile ciphertext reaches the receiving endpoint instead of attributing an outer relay rejection to cryptographic protection; assert no accepted application effect. Fixed vectors are useful contracts, not an independent security audit or proof of interoperability by themselves.
  • Keep encryption/counter advancement and transmission correctly ordered under concurrent sends, with explicit bounded queued bytes/messages, in-flight work and reassembly where present. Slow consumers, overload, close/revoke and channel replacement clear only owned resources and produce coded refusals without plaintext fallback.
  • Publish ready only after authenticated handlers and cleanup ownership are installed. Connection resources and delayed callbacks are scoped to their concrete instance; reconnect cannot replay uncertain mutations or silently redirect a remote operation to the local Host.

Video consumers in Spec #2555 / T6 #2563 inherit these guarantees and add actual media-revocation evidence. The carrier does not become a video relay. No change to this issue's implementation claims, PR ownership, release status or existing dependencies is implied.

Integration evidence and remaining qualification (2026-10-22)

The additional carrier contracts above are covered by the integration report, receiving-gateway regressions and the existing ADR-0244 trust ceremony. These checkmarks do not claim an external audit or production/device qualification.

Vain explicitly approved merge before integrated Simulator QA, so the following checks are follow-up acceptance for the shared main-branch batch, not merge blockers. Keep their status explicit and add actual screenshots to the merged PR body afterward:

  • Complete the native DM → image → real tool approval → private-input tracer on the integrated candidate, with correlated outer-channel and Host evidence. Prior iOS password/pairing receipts remain valid for their recorded sources, but do not prove this entire sequence.
  • Qualify deployed account enrollment through the independent Host comparison and exact device-key approval ceremony.
  • Record remaining Android/physical-iPhone and assistive-technology/Chinese-rendering coverage separately; no device result may be inferred from static checks or Simulator evidence.

Connect Browser/Computer remains explicitly disabled pending its separate qualification (#2563). Independent cryptographic audit/cross-implementation qualification and coordinated rollout remain release concerns; code merge does not constitute deployment.

Final acceptance — completed 2026-10-22

Shared Simulator Batch53 verified matched main46bb44b2 Before and integrated ea36821 After on the existing QA iOS27 dev client. The actual native DM → photo → tool approval → private-input tracer passed after fixing React Native Blob byte reading in #2578, merged as4de4982443d501af9b68372848bc7fec36f7d7c4 with explicit Human authorization. Full CI39739723972 and CodeRabbit passed.

HTTP502, malformed-handshake and exact-device-revocation failures refused the native password submission without plaintext fallback; canonical requests stayed pending. Explicit successful recovery cleared the form. The instrumented real Cloudflare tunnel captured2,524 records/51 channel upgrades with no synthetic secrets/application markers and fallback0;2 deliberate plaintext probes returned404.

Formal deployed same-account enrollment passed after separately Human-authorized relay update toebedbe4d-8b7c-42ce-bb68-5d8dcb630fa7. Full Host fingerprint was independently compared; only the exact phone key was approved. Native Settings loaded over the managed tunnel with Host state encrypted, unchanged App PID4008 and no cold restart. The legacy relay incompatibility was observed as refusal before trust, not a plaintext fallback.

Final report and coverage limits. Actual before/after, password failure and account-pairing screenshots are embedded in #2547 and #2578. Temporary task Host/tunnels/keys/credentials/fixtures were cleaned and the shared device lease released; existing device and original connection preserved.

Android, physical iPhone, VoiceOver, CJK rendering, external cryptographic audit and cross-implementation qualification are explicitly not covered by this Simulator acceptance. Browser/Computer remains disabled under #2563; app release qualification stays with its release owner. These separate limits do not reopen the completed native tracer and account-enrollment checks above.

Activity

  1. DoodleBears commented on Oct 21, 2026

    @DoodleBears
    ContributorAuthor

    Agent work claim

    • Agent: Codex
    • Task: codex/local/01a15f6b-a5c1-7db2-b5b1-a33a1153fbc6 (not a DSH Session)
    • Issue scope: Proposed ADR and threat model only. Encryption implementation remains blocked on Vain approval.
    • Branch: codex/2541-connect-secret-safety
    • Started: 2026-10-21 17:06 UTC
    • State: active
  2. self-assigned this
    on Oct 21, 2026
  3. added
    agent:activeOne or more coding-agent tasks currently claim this issue; see claim comments for task IDs
    on Oct 21, 2026
  4. DoodleBears commented on Oct 21, 2026

    @DoodleBears
    ContributorAuthor

    Agent work continuation

  5. DoodleBears commented on Oct 21, 2026

    @DoodleBears
    ContributorAuthor

    Agent work scope update — Track B approved

    • Agent: Codex
    • Task: codex/local/01a15fc3-2dc9-7e13-a9c5-8ca7f162d141
    • State: active
    • Human authorization (2026-10-22): Vain approved implementation of the Noise XK end-to-end encryption design and explicitly requested a stacked PR above fix(connect): refuse secret entry and retire the phone full client #2546, using the implement workflow.
    • Branch: codex/2542-connect-noise-xk; base: codex/2541-connect-secret-safety (fix(connect): refuse secret entry and retire the phone full client #2546).
    • Scope: pinned Host/device trust, authenticated encrypted transport for phone and remote Web Client, encrypted pairing/admission/resources, native private input, no plaintext downgrade, CLI channel status/fingerprint, adversarial and runtime verification. Existing full-WebView removal remains in Track A.
    • Tests at the approved ADR's public boundaries: handshake/transport interoperability and hostile frames; client ↔ gateway ↔ native Host behavior (including enrollment/revocation); native/Web private-input flow and CLI status. No user-data deployment, merge or release authorized.
  6. DoodleBears commented on Oct 21, 2026

    @DoodleBears
    ContributorAuthor

    Agent work outcome — handed off for review

    • Agent: Codex; task: codex/local/01a15fc3-2dc9-7e13-a9c5-8ca7f162d141. State: handed-off. This closes this task’s active implementation claim and its superseded predecessor claim, not the issue.
    • Approved Noise XK implementation is in stacked Draft feat(connect): encrypt paired-device traffic with pinned Noise XK #2547 at 16d4e6450cde95ea8c1f44953806577d0bdeb8e9, based on Track A fix(connect): refuse secret entry and retire the phone full client #2546 at b842d3ce0750b5085106defef21c4d4eb0112f81.
    • Pinned Host/device trust, explicit key approval, encrypted pairing/RPC/resources/streams, masked native private input and no plaintext fallback are implemented. Full phone WebView removal remains in Track A.
    • Final-head CI: all three test shards pass (8,217 tests, 24 skipped), along with static/build/docs, Android native-module tests and isolated-Host smoke. Aggregate remains red only on Expo Doctor’s 11 SDK patch-version checks, reproduced on unchanged Track A. Offline iOS/Android Hermes exports pass. The local full-suite run was stopped after 50 minutes of timeout failures and is not counted as passing.
    • Real isolated-Host encrypted traffic, official DeepSeek replies, Web/Expo Web private submission, canonical approval rejection and encrypted image byte round-trip passed. Two-axis review and evidence.
    • Remaining: resolve the separate Expo dependency baseline, Human QA, authorized real Cloudflare/account-enrollment validation, native storage/lifecycle/device acceptance and independent security review. The shared native queue remains paused by the Human. No merge, release or deployment was performed.
  7. removed
    agent:activeOne or more coding-agent tasks currently claim this issue; see claim comments for task IDs
    on Oct 21, 2026
  8. DoodleBears commented on Oct 21, 2026

    @DoodleBears
    ContributorAuthor

    Agent work resumed — Expo CI repair

  9. added
    agent:activeOne or more coding-agent tasks currently claim this issue; see claim comments for task IDs
    on Oct 21, 2026
  10. DoodleBears commented on Oct 21, 2026

    @DoodleBears
    ContributorAuthor

    Agent work outcome — Expo CI repair complete, handed off

    • Agent: Codex; task: codex/local/01a15fc3-2dc9-7e13-a9c5-8ca7f162d141. State: handed-off; resumed Expo repair scope completed.
    • Existing Draft feat(connect): encrypt paired-device traffic with pinned Noise XK #2547 now points to 52d6ef5e60e9a3d904970acd1f36d4005dd5174a, still based on fix(connect): refuse secret entry and retire the phone full client #2546 (codex/2541-connect-secret-safety). No merge, release or deployment.
    • Aligned 11 direct Expo SDK 58 patch versions and the official transitive graph; preserved React/React Native versions and general package-age policy, with exact-version exceptions only. The dynamic sharing-plugin configuration was already present.
    • Exact-head full CI is green, including all three test shards, static/build/docs, Host smoke, Android native-module tests, Doctor and iOS/Android exports, and the aggregate gate. Local Doctor 20/20, compatibility check, root/mobile types, formatting and 1,060 mobile tests passed (9 tests skipped). Both review axes found no concrete new findings.
    • Updated review evidence, PR description and deferred device-QA entry. This supersedes the previous Expo baseline blocker.
    • Expo patch/native-module updates make the previous development binary stale; rebuild and qualify a new binary when the Human resumes the paused native queue. The earlier real-network, native lifecycle, Human QA and independent security-review gates remain separate.
  11. 34 remaining items

  12. added and removed
    needs-triageMaintainer needs to evaluate this issue
    agent:activeOne or more coding-agent tasks currently claim this issue; see claim comments for task IDs
    on Oct 22, 2026
  13. DoodleBears commented on Oct 22, 2026

    @DoodleBears
    ContributorAuthor

    Agent work resumed — main Simulator acceptance

  14. added
    agent:activeOne or more coding-agent tasks currently claim this issue; see claim comments for task IDs
    on Oct 22, 2026
  15. DoodleBears commented on Oct 22, 2026

    @DoodleBears
    ContributorAuthor

    Main Simulator Batch52 completed on 55e0ce95200faf2cfc9a20ec4d41acc24be15c9a, reusing the existing QA iOS27/client. Pinned report; eight actual screenshots now embedded in merged PR #2547 (exact body readback + PNG200 verified).

    • PASS: full Host fingerprint comparison/exact phone-key approval without cold restart; real direct-DeepSeek DM; masked private input, tunnel refusal and explicit recovery/clearing; real tool approval; malformed-handshake and revoked-device refusals.
    • Outer capture: 3,240 records /82 encrypted-channel upgrades, synthetic markers absent, plaintext fallback trap0. One explicit negative plaintext probe returned404; separate from application behavior.
    • FAIL: native photo upload before canonical attachment, because React Native Blob has no arrayBuffer(). Fix fix(mobile): support native Blob uploads over Connect #2578 at ea36821ea92904260ba3d78d21db84a3a7d60b13 includes newer main and passes full CI39739723972; native recheck awaits the next owner-cut batch. The complete native tracer therefore remains unchecked.
    • Deployed account enrollment is still unqualified. Android/physical iPhone, accessibility/CJK and external audit are not inferred from this Simulator run.

    Batch52 resources cleaned and lane explicitly RELEASED; original device, My Mac pairing and ten photos retained. #2542 remains open pending acceptance, with no release/deployment claim.

  16. DoodleBears commented on Oct 22, 2026

    @DoodleBears
    ContributorAuthor

    Agent work outcome

  17. removed
    agent:activeOne or more coding-agent tasks currently claim this issue; see claim comments for task IDs
    on Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions