Skip to content

fix(pairing): pairing with this same Orca profile is refused - #27166

Merged
OrcaWin merged 1 commit into
mainfrom
OrcaWin/d4-d4-i2a
Oct 10, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
OrcaWin/d4-d4-i2a

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​51 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​51
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​60 $\color{#cf222e}{\Huge{\mathbf{−}}}$​18 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​42

ELI5

Orca can connect to Orca running on another computer by pasting a pairing code. Nothing stopped you from pasting a code that this same Orca made, so Orca saved "itself" as a remote server, which can never work properly. Now Orca recognises its own code and says so instead of saving a broken entry.

What Changed

  • Before: pasting a pairing code generated by this Orca profile (in Settings, orca environment add, or the ephemeral-VM flow) saved a remote server entry that points back at this same Orca.
  • After: the add is refused with "This pairing code is for this Orca itself. Generate the code on the other computer instead." Nothing is saved. Codes from any other Orca still pair normally, including ones reached over a loopback address (for example through an SSH tunnel).

Mechanism: every pairing code carries the issuing server's encryption public key. All add and re-pair paths go through one function in the environment store (addEnvironmentFromPairingCode / updateEnvironmentFromPairingCode), which now reads this profile's own public key from orca-e2ee-keypair.json (read-only, never created) and refuses when the two keys are equal. The key-file name and size limit moved to a small shared module so the main-process keypair loader and the store use the same definitions.

Why

The key is the only reliable signal: an address cannot tell "this machine" from "another machine behind a tunnel or on the LAN", so address checks would both miss real self-pairs and block legitimate ones. Putting the check in the store covers the desktop UI, the CLI, and the ephemeral-VM path at once, with no wire or protocol change. If the profile has no key file (or it cannot be read), there is no server on this profile that could have issued the code, so pairing proceeds as before. Detecting copied or reinstalled servers is out of scope here and follows separately.

Reimplements the guard from #9137 (credit @s546126).

Linked Issue

Fixes #17549

Visual Proof

N/A — the only visible change is an error message in the existing add-server error slot; no layout change.

Testing

  • Automated tests added/updated, or explained why not below
  • src/shared/runtime-environment-store.test.ts: refuses a code this profile issued (add and re-pair); still pairs a different key at a loopback address. The two refusal tests fail on origin/main (store file restored from main) and pass with this change.
  • Focused suites: store, e2ee keypair, CLI environments, pairing IPC, userData migration (397 passed). pnpm tc, oxlint, and check:code-quality:changed pass.

Review

P0/P1 review: own review plus an independent review.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Security: no secret material is read beyond the public key field; the file is read with a size bound. Cross-platform: path joins only. SSH/remote: the check runs where the environment store lives (the client); a remote server's key differs from the client's, so remote pairing is unaffected. Backward compatible: no stored-data or wire change.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

Every add/re-pair path goes through the environment store; it now compares the
offer's public key with this profile's own runtime key before saving.

Co-Authored-By: s546126 <s546126@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d60a6d4e-bca4-45d8-a2bc-9bc019c7dceb

📥 Commits

Reviewing files that changed from the base of the PR and between 5493c5e and fbc439d.


📒 Files selected for processing (5)
  • src/main/runtime/e2ee-keypair.ts
  • src/main/runtime/mobile-pairing-files.ts
  • src/shared/runtime-e2ee-keypair-file.ts
  • src/shared/runtime-environment-store.test.ts
  • src/shared/runtime-environment-store.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.



📝 Walkthrough

Walkthrough

The change adds shared helpers to read and compare a profile’s runtime E2EE public key. Initial pairing and re-pairing now reject pairing codes whose public key matches the current profile. Tests cover those rejections, confirm that saved environments remain unchanged, and verify that pairing with a different key succeeds at a loopback address.


Priority: ⬇️ Low

Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to fbc43

Pairing codes generated by the same Orca profile are now rejected with a clear message, while codes from other computers continue to pair. No merge-blocking risk was identified.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: refusing pairing attempts for the same Orca profile.
Description check Passed The description is complete and aligned with the template. It explains the user impact, mechanism, rationale, linked issue, testing, visual proof, compatibility considerations, and checklist status.
Linked Issues check Passed Issue #17549 requires rejection of self-pairing with runtime and UI coverage. parseRemotePairingCode compares the pairing offer public key with the profile key. Both addEnvironmentFromPairingCode …
Out of Scope Changes check Passed The changed key-file constants, bounded public-key reader, comparison helper, environment-store guard, and focused tests all support issue #17549. The changes do not show unrelated behavior or unrelat…

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@OrcaWin
OrcaWin merged commit f307391 into main Oct 10, 2026
32 checks passed
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.

Reject self-pairing the local Orca server as a remote

1 participant