Skip to content

fix(browser): exclude Google cookies from imports - direct sign-in is the only Google path (STA-3811) - #13670

Merged
brennanb2025 merged 2 commits into
mainfrom
brennanb2025/sta-3811-import-preserve-google
Aug 11, 2026
Merged

brennanb2025 merged 2 commits into
mainfrom
brennanb2025/sta-3811-import-preserve-google

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

STA-3811: cookie imports never touch the Google cookie family. Unconditional, on every import path (native Chromium, file, Firefox, Safari) — an import writes no google.com-family cookie and removes none, regardless of what is already in the jar.

Why the general rule instead of a provenance check: an in-app Google sign-in is the only Google session that survives, because transplanted cookies get flagged by anti-fraud and expire within ~1h. So there is never a case where importing Google cookies beats what is already there — a live in-app session is more valuable, and an older imported session is worthless either way. Distinguishing the two only justified machinery (a cookies-changed provenance observer, an import-suppression window, provenance-conditional staged-DB handling) that the general policy makes unnecessary.

The exclusion is a named list, not new machinery:

// browser-cookie-import-policy.ts
const NON_TRANSPLANTABLE_DOMAINS = ['google.com'] as const

Criterion: sites with server-side device-bound sessions that reject transplanted cookies. A future site is one entry, not a new code path. isNonTransplantableCookieDomain() matches the registrable family (google.com and *.google.com, not withgoogle.com / google.com.evil.example); NON_TRANSPLANTABLE_HOST_KEY_SQL is derived from the same list for the Chromium host_key column.

Where it applies:

  • Incoming snapshot — Google rows are dropped before anything is written, on both the native decrypt loop and the validated-cookie path. Counted in skippedCookies.
  • Clear/replace step — the native path swaps clearStorageData({storages:['cookies']}) for removeAllCookiesExcept(...); the replace-imported-domains path never sees Google in its scope because the exclusion runs before the scope is computed. The staged restart-fallback DB uses DELETE FROM cookies WHERE NOT (<google>) so a cold-restart replay does not undo the exemption — it is the same clear step, just deferred.

isGoogleSourceBoundCookie (SIDCC / STRP / AEC) is kept but is now subsumed for google.com by the broader exclusion; it stays as the general rotation-only rule for any family added without a full exclusion, and is still directly unit-tested.

Disclosure (same PR — it discloses the policy). Both cookie-import menus carry a one-line muted caption so the exclusion is visible at the moment of decision: the browser toolbar Import Cookies submenu and the Settings browser-profile import dropdown. Copy: Google requires signing in directly - imports skip it. Rendered with DropdownMenuLabel (text-[11px] text-muted-foreground, font-normal) per docs/STYLEGUIDE.md, added through the localization catalog like neighboring strings. No confirmation dialog.

Screenshots

Text-only addition; caption appears at the top of both import menus.

Testing

  • pnpm lint (full gate: oxlint, native + type-aware code quality, reliability gates, max-lines ratchet, localization catalog/extraction/coverage)
  • pnpm typecheck
  • Changed-code quality gate: 0 new findings across 9 changed files (code quality, type-aware, React Doctor)
  • pnpm test — vitest run --config config/vitest.config.ts src/main/browser/ (34 files, 598 passed), plus src/renderer/src/i18n src/renderer/src/components/settings/browser (21 files, 159 passed) and the new disclosure suite
  • pnpm build
  • Mutation-resistant: emptying NON_TRANSPLANTABLE_DOMAINS flips 9 tests red across the predicate, the SQL, the file path, and the native path. Deleting the caption JSX flips the render test red.

Coverage added:

  • browser-cookie-import-google-exclusion.test.ts — file path: import with Google cookies present writes none and removes none, whether the existing Google cookies came from an in-app sign-in or an older import; native path: no wholesale clearStorageData, live Google cookies survive, live Google rows stay in the staged restart DB.
  • browser-cookie-import-policy.test.ts — registrable-family matching incl. lookalikes, the host_key SQL run against a real SQLite table, the deliberate youtube.com exemption, removeAllCookiesExcept semantics and failure aggregation.
  • browser-cookie-import-google-disclosure.test.tsx — both menus render the caption; catalog entries match the copy on both surfaces.

AI Review Report

Reviewed both import pipelines end to end for the new invariant (never write, never remove). Risks checked: (1) suffix confusion — the predicate normalizes and requires the registrable family, asserted at both the TS and SQL layers against withgoogle.com and google.com.evil.example; (2) the replace-scope path — the exclusion must run before replaceCookiesForImportedDomains computes its scope, or Google would be cleared and not repopulated, so the ordering is asserted by a test that fails if the filter moves; (3) the deferred clear — the staged DB replaces the whole live DB at cold start, so leaving DELETE FROM cookies unqualified would silently reintroduce the wipe one restart later; covered by a staged-rows assertion; (4) skippedCookies accounting stays exact on both paths so the existing toast copy remains truthful. Cross-platform: main-process only, no shortcuts or labels, no new paths; the predicates and SQL are platform-independent; existing per-platform decryption is untouched. Session mocks in three suites gained cookies.get because the clear step now enumerates the jar instead of calling clearStorageData.

Security Audit

No new IPC surface, no command execution, no new file reads. The SQL predicate is built from a module-level literal list, never from user or cookie data. The selective clear reads only cookie name/domain/path/secure and reuses the existing removal-URL construction, so it cannot widen removal scope beyond what clearStorageData already did. Fail-closed behavior preserved: removal failures aggregate and abort the import through the existing error path. Net effect is strictly less destructive than before — one fewer domain family is ever deleted.

Notes

  • Behavior change: imports no longer carry Google cookies at all. Users who want Google in Orca sign in directly in the browser pane; the caption says so in both import menus. Clearing cookies (Settings → trash icon) is unchanged and still removes Google state.
  • Scope: the google.com registrable family only. youtube.com (incl. accounts.youtube.com) is deliberately not excluded — YouTube accepts a transplanted session and re-issues its cookies via the sign-in relay, so excluding it would silently drop imports users asked for. Documented at the list and locked in by a test.
  • Dropped from the earlier revision: the Google-provenance state machine on browserSessionRegistry (persisted in-app / imported marker in browser-session-meta.json), its cookies changed sign-in observer, the beginCookieImport/endCookieImport suppression window, and browser-google-session-protection.ts. None of it is needed once imports never touch Google.
  • Toast copy from feat(browser): Google direct sign-in notice after cookie imports (STA-3811) #13666 is untouched and still reads correctly under this policy; the two PRs' files are disjoint.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Cookie imports now exclude Google-family and other non-transplantable domains. Selective cleanup preserves excluded cookies and supports rollback after removal failures. Chromium staging and restart fallback retain excluded database rows. Import summaries include skipped excluded cookies. Browser import menus now explain the direct Google sign-in requirement. Tests cover policy behavior, file imports, Chromium imports, fallback staging, and menu disclosures.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: excluding Google cookies from browser imports.
Description check ✅ Passed The description covers the required sections, user-visible behavior, testing, AI review, security audit, and platform notes; only the build remains unchecked.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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
📝 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.

Imports never write and never remove a google.com-family cookie, on any
path. Signing in directly inside Orca is the only Google session that
survives, so the live jar always beats anything an import could plant.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/sta-3811-import-preserve-google branch from 95e7202 to ffe6ca6 Compare August 10, 2026 22:46
@brennanb2025 brennanb2025 changed the title fix(browser): preserve in-app Google session across cookie imports (STA-3811) fix(browser): exclude Google cookies from imports - direct sign-in is the only Google path (STA-3811) Aug 10, 2026

@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.

🧹 Nitpick comments (1)
src/main/browser/browser-cookie-import-policy.ts (1)

57-65: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Shorten this source comment.

Keep the non-obvious policy reason in one concise comment. Move the detailed operational explanation to the ticket or policy documentation.

Proposed change
-// Why (STA-3811): registrable families whose sessions are device-bound server-side, so a
-// transplanted cookie is rejected (or flagged and expired within ~1h) no matter how faithfully
-// it is copied. Signing in directly inside Orca is the only path that produces a working
-// session, so an import must never write these cookies and never remove them either — the
-// live session is always more valuable than anything an import could put in its place.
-// Adding a site is one entry here.
+// Google sessions are device-bound. Preserve Google-family cookies during imports.

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ca599718-867a-4895-b849-0b34cf9cc493

📥 Commits

Reviewing files that changed from the base of the PR and between 84bd306 and 02069ff.

📒 Files selected for processing (10)
  • src/main/browser/browser-cookie-import-google-exclusion.test.ts
  • src/main/browser/browser-cookie-import-policy.test.ts
  • src/main/browser/browser-cookie-import-policy.ts
  • src/main/browser/browser-cookie-import-replacement.test.ts
  • src/main/browser/browser-cookie-import.test.ts
  • src/main/browser/browser-cookie-import.ts
  • src/renderer/src/components/browser-cookie-import-google-disclosure.test.tsx
  • src/renderer/src/components/browser-pane/browser-toolbar-menu-dropdown.tsx
  • src/renderer/src/components/settings/BrowserProfileRow.tsx
  • src/renderer/src/i18n/locales/en.json

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Visual QA — STA-3811 Google cookie import disclosure

Captured on branch head 02069ffa3d via pnpm dev (app: Orca: brennanb2025/sta-3811-import-preserve-google).

  1. Browser toolbar → ⋯ menu → Import Cookies submenu — muted caption visible: “Google requires signing in directly - imports skip it.”
    Browser toolbar Import Cookies dropdown

  2. Settings → Browser → Session & Cookies → Import Cookies — same muted caption at the top of the menu.
    Settings Import Cookies dropdown

Did not run a live cookie import against host Chrome/Safari profiles (keychain consent / non-throwaway data). Both menu disclosure surfaces are verified; non-Google import entries remain available (Chrome / Safari / File).

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Updated visual QA — menu footer with icon

All four cookie-import entry points now show the same footer:

Google logins are not imported
Sign in to Google directly in Orca.

Browser toolbar hint

Browser toolbar hint

Browser overflow menu

Browser overflow menu

Settings — Agent Browser Use setup / Re-import

Agent Browser Use setup and Re-import

Settings — profile row

Settings profile row

@brennanb2025
brennanb2025 merged commit 686f5dc into main Aug 11, 2026
44 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
… the only Google path (STA-3811) (stablyai#13670)

* fix(browser): exclude Google cookies from imports (STA-3811)

Imports never write and never remove a google.com-family cookie, on any
path. Signing in directly inside Orca is the only Google session that
survives, so the live jar always beats anything an import could plant.

* fix(browser): roll back selective cookie clears
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.

1 participant