Skip to content

fix(cloud): honor OS certificate trust for first-party traffic - #15208

Open
Jinwoo-H wants to merge 2 commits into
mainfrom
aug17-p1-sta3864-tls-trust-boundary
Open

Jinwoo-H wants to merge 2 commits into
mainfrom
aug17-p1-sta3864-tls-trust-boundary

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​294 $\color{#cf222e}{\Huge{\mathbf{−}}}$​6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​288
Prod 13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​124 $\color{#cf222e}{\Huge{\mathbf{−}}}$​21 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​103

Summary

Fixes the Node-versus-browser TLS trust split behind transparent corporate TLS inspection for Orca-owned Cloud and Relay traffic.

  • Electron main-process HTTP uses net.fetch, inheriting Chromium/OS trust.
  • Node/headless HTTP uses a scoped undici.Agent with Node default roots plus policy-filtered system roots.
  • Relay control and data WebSockets use one cached SecureContext built from the same additive roots.
  • Cloud auth, org, artifact, Relay mint/assign, region catalog/probes, control WSS, and data WSS share this boundary.
  • TLS verification remains enabled; no global dispatcher, CA mutation, or certificate bypass is introduced.

The Node CA set is byte-identical to the same Electron/Node runtime launched with --use-system-ca (124/124 certificates on the validation host).

Invariant

For Orca first-party HTTPS/WSS traffic, a chain accepted by the runtime's additive system-CA mode must be accepted by the scoped Orca boundary, while that same chain must still fail without the trusted CA and hostname/certificate verification must remain enabled.

Deterministic reproduction

A local static CA/leaf fixture (valid 2020–2120, SANs localhost and 127.0.0.1) serves the byte-identical HTTPS/WSS oracle.

Variant Raw HTTPS Raw WSS First-party HTTP Control WSS Data WSS
v1.4.178 / current origin/main transport certificate rejection certificate rejection n/a n/a n/a
Candidate certificate rejection certificate rejection fixture-http-ok authenticated open fixture-wss-ok
Candidate with trust boundary disabled/reverted certificate rejection certificate rejection certificate rejection certificate rejection certificate rejection

Independent signals are the TLS verification failure on the raw path and exact HTTP/WSS response bytes plus the control-socket Bearer header on the trusted path.

Validation

  • 15 focused test files / 121 tests passed.
  • pnpm run typecheck:node passed.
  • Focused Oxlint with warnings denied passed.
  • Oxfmt and git diff --check passed.
  • pnpm run build:electron-vite passed.
  • Real Electron fixture: raw Node UNABLE_TO_VERIFY_LEAF_SIGNATURE; Electron net.fetch HTTP 200 with fixture-http-ok.
  • Packaged runtime verification copied [email protected]; the dependency closure includes it for Windows, macOS, and Linux.
  • Electron UI smoke rendered normally with zero renderer errors.
  • Three independent final reviews found no merge-blocking correctness, security, compatibility, packaging, performance, or oracle issue.

The aggregate unpacked-build wrapper is currently blocked before packaging by two unrelated renderer test-fixture type errors in open-tab-search-retention.test.ts. Direct Electron bundling passed; the packager then passed the main-runtime dependency verifier before later stopping on an absent prebuilt CLI artifact from the skipped aggregate build.

Scope and compatibility

  • No remote wire, RPC schema, stream opcode, SSH protocol, or folder-workspace behavior changes.
  • Mixed client/host versions remain compatible.
  • Trust is cached for process lifetime, matching the runtime behavior; newly installed roots require an Orca restart.
  • Transport error classification remains orthogonal and is covered separately by fix(cloud): name the transport failure sign-in and Relay swallow #13736.

Related to #13735

@Jinwoo-H
Jinwoo-H force-pushed the aug17-p1-sta3864-tls-trust-boundary branch from db127af to 8d30ba0 Compare August 18, 2026 01:35
@Jinwoo-H
Jinwoo-H marked this pull request as ready for review August 18, 2026 03:05
@coderabbitai

coderabbitai Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: edee3fba-49d0-48f1-ba0e-e675237ac871

📥 Commits

Reviewing files that changed from the base of the PR and between 8d30ba0 and 641fdaf.

📒 Files selected for processing (2)
  • src/main/runtime/relay/relay-control-client.ts
  • src/main/runtime/rpc/relay-transport.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/main/runtime/rpc/relay-transport.ts
  • src/main/runtime/relay/relay-control-client.ts

Included review availability: Your plan includes up to 10 reviews per rolling hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

The change adds firstPartyFetch with Undici-based Node dispatch, Electron browser-runtime dispatch, and first-party TLS certificates. It adds relay WebSocket helpers with trust preparation, authentication, compression settings, and payload limits. Artifact, Orca profile, relay HTTP, and relay region requests now use the first-party fetch boundary. Relay control and RPC transports now use the first-party WebSocket helpers. Tests cover fetch behavior, TLS trust, relay sockets, HTTP requests, region probes, and packaged runtime resources.

Merge Risk: ⚪ Minimal · up to 641fd

This change enables OS certificate trust for first-party HTTPS and WebSocket traffic while keeping certificate and hostname verification enabled; no actionable merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. 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 summarizes the main change: honoring OS certificate trust for first-party traffic.
Description check ✅ Passed The description clearly explains the change, rationale, scope, validation, compatibility, and related issue, despite omitting several template headings and checklist items.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/main/runtime/first-party-relay-websocket.test.ts (1)

104-130: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Close the HTTPS server in afterAll.

wss.close() does not close an externally supplied HTTPS server. Call server.close() after terminating clients and closing wss to release the listening handle.

Source: Linters/SAST tools


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e0bce478-7bc0-43cf-b1c8-4f6ad0666f7d

📥 Commits

Reviewing files that changed from the base of the PR and between 0e96b82 and 8d30ba0.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (18)
  • config/packaged-runtime-node-modules.cjs
  • config/scripts/package-electron-runtime-contract.test.mjs
  • package.json
  • src/main/artifacts/artifact-cloud-request.ts
  • src/main/global-fetch-call-site-audit.test.ts
  • src/main/orca-profiles/profile-cloud-client.ts
  • src/main/orca-profiles/profile-cloud-org-members-client.ts
  • src/main/runtime/first-party-fetch.test.ts
  • src/main/runtime/first-party-fetch.ts
  • src/main/runtime/first-party-relay-websocket.test.ts
  • src/main/runtime/first-party-relay-websocket.ts
  • src/main/runtime/first-party-tls-trust.ts
  • src/main/runtime/relay/relay-control-client.ts
  • src/main/runtime/relay/relay-http-client.test.ts
  • src/main/runtime/relay/relay-http-client.ts
  • src/main/runtime/relay/relay-region-preference.test.ts
  • src/main/runtime/relay/relay-region-preference.ts
  • src/main/runtime/rpc/relay-transport.ts

Included review availability: Your plan includes up to 10 reviews per rolling hour; 9 remain after this review.

@Minidoracat

Copy link
Copy Markdown
Contributor

This PR has been mergeable: false / dirty since main moved on, which looks like the actual reason it has been sitting for a week rather than any objection — CI here was green.

I rebased it onto current main and opened it as #16399, with both of your commits and authorship untouched (@Jinwoo-H). 18 of the 19 files are identical.

The one conflict was config/scripts/package-electron-runtime-contract.test.mjs, where main and this branch each appended a new it(...) at the same position. It cannot be resolved by keeping both hunks: current main leaves that file at the max-lines ceiling (598 of 600 effective lines), so re-adding the packaged-undici assertion there fails oxlint outright. In #16399 that single contract moved into its own file and the original suite is restored to its main content unchanged, which drops the conflict surface to zero.

I also verified the change on a host that actually reproduces the failure — a Windows machine where a locally installed HTTPS-filtering tool re-signs chains with a root present only in the OS store. Inside the real Electron main process, with a negative control to isolate the trust store as the deciding factor:

BEFORE  bare globalThis.fetch (ships in 1.4.188) => FAIL UNABLE_TO_VERIFY_LEAF_SIGNATURE
CONTROL undici, bundled roots only               => FAIL UNABLE_TO_VERIFY_LEAF_SIGNATURE
AFTER   undici + first-party trust (Node)        => HTTP 400
AFTER   firstPartyFetch() (Electron net)         => HTTP 400

BEFORE  bare ws (ships in 1.4.188)               => FAIL UNABLE_TO_VERIFY_LEAF_SIGNATURE
AFTER   first-party relay control socket         => TLS OK
AFTER   first-party relay data socket            => TLS OK

The WSS rows matter because #13735 specifically doubted whether the ws control socket was covered — the shared SecureContext does cover it.

Happy to close #16399 if you would rather rebase this one yourself; the only goal is getting the fix onto a mergeable base.

This branch has not been deployed

No deployments
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