Skip to content

feat(web): the browser signs in with a non-extractable device key, or pairs for this session only - #27552

Merged
OrcaWin merged 3 commits into
mainfrom
np/d2b-web-keys
Oct 11, 2026
Merged

OrcaWin merged 3 commits into
mainfrom
np/d2b-web-keys

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​783 $\color{#cf222e}{\Huge{\mathbf{−}}}$​6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​777
Prod 24 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1307 $\color{#cf222e}{\Huge{\mathbf{−}}}$​134 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1173

ELI5

The Orca web client used to remember its pairing code in the browser's localStorage. Any script running on that page could read the code and reuse it from anywhere. Now the browser makes its own sign-in key, one that even the page itself cannot read out, and it forgets the code.

Where the browser cannot keep such a key safely, it now pairs for the current tab only:

  • the page is plain http:// on another machine, or
  • the browser has no Ed25519 keys.

Browsers that are already paired keep working, and nobody has to pair again.

What Changed

Before: the pairing code sat in localStorage and was sent on every connection, forever (#17399).

After:

  • Secure page, and the browser supports WebCrypto Ed25519 (current Chrome, Edge, Safari and Firefox):
    • The browser creates a non-extractable Ed25519 key and stores it in IndexedDB.
      • The stored CryptoKey can sign but can never be exported.
      • The write is create-exclusive with add(), so two open tabs end up with the same key.
    • On its next connection to a host that advertises pairing.device-key.v1, the browser:
      1. opens a v2 session with its pairing code;
      2. checks the capability;
      3. signs a register proof over that session's transcript and calls pairing.registerDeviceKey;
      4. marks the key active;
      5. replaces the stored code with a non-secret placeholder (migrated:<deviceId>);
      6. reconnects with key auth. Key auth carries the client capabilities, which v2 token auth cannot.
    • From then on, the browser signs a fresh proof for each connection, and its requests carry no token.
    • Other holders of the same code are untouched, because the host forks a new row.
    • With an older host that lacks the capability, the browser simply stays on its code.
  • Plain-http page on another machine, or no Ed25519:
    • An existing stored pairing keeps working exactly as before. A small corner notice says the browser keeps a reusable code and suggests https, localhost, or an SSH tunnel.
    • An https page without Ed25519 gets its own wording: it suggests a current browser, not a tunnel.
    • A new pairing is kept in memory only and never written to localStorage. If the host supports session keys (feat(runtime): session-only browser keys and opt-in for pairing from plain-http pages (host) #27540), the browser registers an in-memory key with ephemeral: true and forgets the code.
    • The connect screen explains that this pairing lasts only while the tab is open.
  • Verdicts:
    • Only a sealed device_revoked that names this browser's key deletes the key and the pairing.
    • bad_auth after key auth means the host was downgraded. The browser keeps the key and says so.
    • registry_unavailable retries with backoff, and the key is kept.
    • insecure_origin shows the host's refusal with the opt-in instructions and the LAN-attacker warning.
  • Every web socket is marked with ?orca-client=web, so the host can tell the web client from a phone (feat(runtime): session-only browser keys and opt-in for pairing from plain-http pages (host) #27540).
  • A key belongs to one pairing. The key record stores the pairing revision. A re-pair saves a fresh code under a new revision, so the browser connects with that code instead of an old key the host may no longer accept, for example after a downgrade or a lost row. It then migrates again.
  • Broken IndexedDB never cuts a pairing.
    • A code that never migrated connects without reading the key store at all.
    • A migrated pairing whose key store fails retries with backoff instead of leaving the connection dead.
  • Several tabs:
    • A tab that finds the key already active (another tab migrated, or a run closed mid-migration) forgets its code at once.
    • Saving a stale copy of the same pairing (same id and revision) never puts a real code back over a migrated: placeholder.
    • A tab whose copy predates another tab's re-pair never deletes the newer key and never overwrites the newer stored pairing. It stays on its own code.
  • Shared handshake core: it now takes an async device-key credential, v2 only. Legacy framing refuses it, and it signs encodeDeviceProofMessage('auth', transcriptHash).
  • Code layout: the web transport's auth logic moved into web-runtime-connection-auth.ts, and its timers into web-runtime-connection-timers.ts.

Why

  • Why non-extractable WebCrypto and not a stored secret: any script on the page can read anything in localStorage or IndexedDB that is plain data. A non-extractable key can be used by such script, but it cannot be taken to another machine.
  • Why session-only on insecure pages: a key stored by a page that a LAN attacker can replace protects little. The owner chose session-only there (Decision D2-Q2), and existing pairings are not cut.
  • Why migrate on a separate v2 token socket: the registration proof must be bound to a v2 transcript, and v2 token auth cannot carry client capabilities. A short registration socket followed by a key socket keeps every feature working.
  • Why reconnect instead of switching in place: the host binds identity at auth time, so a new credential needs a new connection.

Linked Issue

Fixes #17399 for browsers with Ed25519 on secure pages. Session-only elsewhere, as decided.

Visual Proof

No screenshot (no browser automation available here). What the user sees:

  • Corner notice (bottom-right, card style, dismissible for the page): an alert icon, then for example "This browser keeps a reusable pairing code, because this page is plain http on another machine. Anyone who can read this browser's storage could use it. For a safer pairing, open Orca over https, at localhost on this computer, or through an SSH tunnel, and pair again."
  • Connect screen on such a page: a muted info box saying "This pairing lasts only while this tab is open, …".
  • Refused new pairing from an http LAN page: the connect error explains why, and says how the operator can opt in with ORCA_ALLOW_INSECURE_WEB_PAIRING=1.

Testing

  • tests/e2e/cross-version-wire/cross-version-web-device-key.unit.test.ts runs the real web transport against the real host socket wiring, registry and key registration:

    • the browser registers a non-extractable key, reconnects with it, sends no request token, and the token row survives;
    • against the released host (latest tag) it keeps its code;
    • an existing stored code on an insecure page is unchanged;
    • a session pairing registers an ephemeral row;
    • a host revocation deletes the key and the pairing;
    • after a migration, a downgrade to the released host followed by a re-pair connects with the fresh code;
    • every socket the browser opens carries the web marker.
  • src/renderer/src/web/web-runtime-credential-source.test.ts:

    • a re-pair uses the fresh code;
    • a tab still holding the code forgets it once the key is active;
    • a broken key store never blocks an unmigrated code;
    • a migrated pairing with a broken store schedules a retry.
  • src/renderer/src/web/web-runtime-environment-token.test.ts: a stale save keeps the placeholder, and a re-pair stores its fresh code.

  • src/renderer/src/web/web-device-key.test.ts:

    • a WebCrypto Ed25519 signature verifies with tweetnacl on the host;
    • the key is non-extractable;
    • two tabs adopt one key;
    • the support probe distinguishes insecure pages, missing Ed25519 and full support.
  • src/renderer/src/web/web-runtime-auth-verdict.test.ts: the I8 verdict table.

  • src/shared/paired-e2ee-device-key-auth.test.ts:

    • key auth signs this transcript with purpose auth and carries capabilities;
    • v2 token auth stays exact-key;
    • legacy framing and a pre-ready session refuse a key.
  • The existing web client, preload and runtime suites pass.

  • pnpm tc, oxlint, check:code-quality:changed, pnpm lint (including localization) pass.

  • Automated tests added/updated

Agent skill upstream boundary

  • Not applicable.

Notes

  • Stacking: stacked on feat(runtime): session-only browser keys and opt-in for pairing from plain-http pages (host) #27540 (host half). Both need the host and its served web client at the same version. A browser facing an older host stays on its code.
  • SSH: a page reached through an SSH tunnel is localhost, so it is a secure context and gets a persistent key.
  • Why a new pairing on a secure page still writes its code to localStorage until the first connection:
    • It is the same reusable code the pairing link already carries, and today's behaviour keeps it there forever.
    • The first connection replaces it with a placeholder within one round trip.
    • If the host lacks device keys, the code must persist anyway to keep the pairing.
    • Keeping it in memory first would need a second store path for that short window.
  • Remaining: desktop and CLI keys (B5) and phone keys (B6) are separate.

m4air added 3 commits October 11, 2026 14:41
… pairs for this session only

- On a secure page with WebCrypto Ed25519, the browser registers a non-extractable key
  (stored in IndexedDB, create-exclusive across tabs) over a v2 token socket, then
  reconnects with key auth and replaces its stored pairing code with a placeholder.
  Requests on a keyed socket carry no token.
- On a plain-http page on another machine, or without Ed25519, existing stored pairings
  keep working unchanged (with a warning); new pairings stay in memory and, when the host
  supports it, register a session-only key.
- Only a sealed device_revoked naming this browser's key deletes it; a downgraded host,
  a bad proof or host storage trouble keep it.
- The shared handshake core gains an async device-key credential (v2 only).
…ken key store

- Every web socket carries ?orca-client=web so hosts gate only the web bundle.
- A key record belongs to one pairing revision: a re-pair uses its fresh code.
- A code that never migrated connects without reading IndexedDB; a migrated
  pairing whose key store fails retries instead of going dead.
- A tab that finds the key already active forgets its code, and saving a stale
  copy of the same pairing never puts the code back over a placeholder.
A key record from a newer pairing revision is left alone (the tab stays on its
code), and saving an older revision never replaces a newer stored pairing.
@OrcaWin
OrcaWin changed the base branch from np/d2b-web-session-host to main October 11, 2026 21:58
@OrcaWin
OrcaWin marked this pull request as ready for review October 11, 2026 22:16
@OrcaWin
OrcaWin requested a review from brennanb2025 as a code owner October 11, 2026 22:16
@OrcaWin
OrcaWin merged commit 0663e27 into main Oct 11, 2026
43 of 57 checks passed
nwparker added a commit that referenced this pull request Oct 17, 2026
…s again (#29984)

Partially reverts #27540 and the plain-http part of #27552, which broke web
pairing on upgrade for 1.4.227 users who open Orca at a LAN or Tailscale address:

- The host no longer refuses a first pairing from a plain-http page on another
  machine (insecure_origin, ORCA_ALLOW_INSECURE_WEB_PAIRING).
- Such a page keeps its pairing code in local storage and signs in with it, as
  in 1.4.227, so reloads, new tabs and bookmarks stay paired; no notice.
- Session-only browser keys (pairing.device-key-ephemeral.v1, the idle sweep)
  stay for browsers without Ed25519.
- A web client whose credentials are refused shows the host's reason instead
  of an empty workspace and "Session restore failed".
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.

Security: replace browser client localStorage bearer token with proof-of-possession

1 participant