Repository navigation
fix(browser): exclude Google cookies from imports - direct sign-in is the only Google path (STA-3811) - #13670
Conversation
📝 WalkthroughWalkthroughCookie 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)
✨ Finishing Touches📝 Generate docstrings
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. Comment |
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.
95e7202 to
ffe6ca6
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/browser/browser-cookie-import-policy.ts (1)
57-65: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winShorten 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
📒 Files selected for processing (10)
src/main/browser/browser-cookie-import-google-exclusion.test.tssrc/main/browser/browser-cookie-import-policy.test.tssrc/main/browser/browser-cookie-import-policy.tssrc/main/browser/browser-cookie-import-replacement.test.tssrc/main/browser/browser-cookie-import.test.tssrc/main/browser/browser-cookie-import.tssrc/renderer/src/components/browser-cookie-import-google-disclosure.test.tsxsrc/renderer/src/components/browser-pane/browser-toolbar-menu-dropdown.tsxsrc/renderer/src/components/settings/BrowserProfileRow.tsxsrc/renderer/src/i18n/locales/en.json
… 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






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:
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.comand*.google.com, notwithgoogle.com/google.com.evil.example);NON_TRANSPLANTABLE_HOST_KEY_SQLis derived from the same list for the Chromiumhost_keycolumn.Where it applies:
skippedCookies.clearStorageData({storages:['cookies']})forremoveAllCookiesExcept(...); thereplace-imported-domainspath never sees Google in its scope because the exclusion runs before the scope is computed. The staged restart-fallback DB usesDELETE 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) perdocs/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 typecheck0 new findingsacross 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), plussrc/renderer/src/i18n src/renderer/src/components/settings/browser(21 files, 159 passed) and the new disclosure suitepnpm buildNON_TRANSPLANTABLE_DOMAINSflips 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 wholesaleclearStorageData, live Google cookies survive, live Google rows stay in the staged restart DB.browser-cookie-import-policy.test.ts— registrable-family matching incl. lookalikes, thehost_keySQL run against a real SQLite table, the deliberate youtube.com exemption,removeAllCookiesExceptsemantics 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.comandgoogle.com.evil.example; (2) the replace-scope path — the exclusion must run beforereplaceCookiesForImportedDomainscomputes 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 leavingDELETE FROM cookiesunqualified would silently reintroduce the wipe one restart later; covered by a staged-rows assertion; (4)skippedCookiesaccounting 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 gainedcookies.getbecause the clear step now enumerates the jar instead of callingclearStorageData.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
clearStorageDataalready 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
google.comregistrable 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.browserSessionRegistry(persistedin-app/importedmarker inbrowser-session-meta.json), itscookieschangedsign-in observer, thebeginCookieImport/endCookieImportsuppression window, andbrowser-google-session-protection.ts. None of it is needed once imports never touch Google.