Repository navigation
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
🚧 Files skipped from review as they are similar to previous changes (6)
📝 WalkthroughWalkthroughThe Chromium cookie importer detects 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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 |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/browser/browser-cookie-import.ts (1)
1807-1820: 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick winThe
app-bound-encryptionwarning never fires because of an earlier return.
importedanddecryptedCookies.lengthstay in lock-step: every push todecryptedCookies(around line 1777) is immediately followed byimported++(line 1803). This means wheneverimported === 0,decryptedCookies.lengthis also0.The block at Lines 1807-1820 already returns early when
decryptedCookies.length === 0, before the function reaches the new warning logic at Lines 1869-1875:if (decryptedCookies.length === 0) { ... return { ok: true, profileId: '', summary: { ..., domains: [] } } }The new check
if (imported === 0 && appBoundEncrypted > 0)at Line 1872 can only be true whendecryptedCookies.length === 0, which means the function has already returned by then. This is exactly issue#13192's scenario: a browser where every cookie isv20app-bound produces zero imports, so it hits the early return and never reaches the warning code. Theapp-bound-encryptionwarning this PR adds cannot ever be surfaced for the case it was built to fix.Move the warning computation into the early-return branch, and drop the now-unreachable check further down.
🐛 Proposed fix: compute the warning before the early return
if (decryptedCookies.length === 0) { closeStagingDb() discardStagingFile() + const earlyWarning: BrowserCookieImportSummary['warning'] = + appBoundEncrypted > 0 + ? { code: 'app-bound-encryption', encryptedCookies: appBoundEncrypted } + : undefined + if (earlyWarning) { + diag(` ${appBoundEncrypted} cookies use app-bound encryption (v20) and cannot be decrypted`) + } return { ok: true, profileId: '', summary: { totalCookies: sourceRows.length, importedCookies: 0, skippedCookies: skipped + integritySkipped, - domains: [] + domains: [], + ...(earlyWarning ? { warning: earlyWarning } : {}) } } }let warning: BrowserCookieImportSummary['warning'] - // Why: without this the import reports a clean zero, which reads as "no cookies to import" - // rather than "this browser encrypts cookies in a way Orca cannot read" (`#13192`). - if (imported === 0 && appBoundEncrypted > 0) { - warning = { code: 'app-bound-encryption', encryptedCookies: appBoundEncrypted } - diag(` ${appBoundEncrypted} cookies use app-bound encryption (v20) and cannot be decrypted`) - } if (memoryFailed > 0 && stagingAvailable) {Also applies to: 1869-1875
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: b1638627-95e7-4637-9e4d-f2878788b01c
📥 Commits
Reviewing files that changed from the base of the PR and between 54a9b58 and 093c369f72914f7ebca0a40058e3957b5da6093c.
📒 Files selected for processing (5)
src/main/browser/browser-cookie-import-app-bound.test.tssrc/main/browser/browser-cookie-import.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/lib/browser-cookie-import-toast.tssrc/shared/types.ts
|
Correcting this PR — the original commit did not fix the reported case. Acting on the observation that PRs here get closed for unverified mechanisms rather than style, I went back to prove the warning actually reaches the caller instead of only testing the predicate. It didn't.
Fixed in e0d8f8e88d, with an end-to-end test ( Also worth recording for review: with no key available the import already fails cleanly with "Could not access Google Chrome encryption key", so this path only matters when the key works and the rows are app-bound — i.e. Windows with Chrome/Edge 140+. 605 tests in |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/browser/browser-cookie-import.ts (1)
1729-1737: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winSkip
v20rows beforedecryptCookieValueRaw.Lines 1731-1733 detect app-bound encryption, but Line 1734 still attempts standard decryption. This conflicts with the stated v20 behavior. Increment
skippedand continue after incrementingappBoundEncrypted.Proposed fix
if (isAppBoundEncryptedCookie(encBuf)) { appBoundEncrypted++ + skipped++ + continue } const raw = sourceKey ? decryptCookieValueRaw(encBuf, sourceKey) : null
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: c75e99bc-a298-4af2-aa92-778b1ee36364
📥 Commits
Reviewing files that changed from the base of the PR and between 093c369f72914f7ebca0a40058e3957b5da6093c and e0d8f8e88da5a45327ac148925e45a85732356f0.
📒 Files selected for processing (2)
src/main/browser/browser-cookie-import-app-bound-surface.test.tssrc/main/browser/browser-cookie-import.ts
e0d8f8e to
bef02bd
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
…zero Chrome and Edge 140+ on Windows wrap every cookie in app-bound encryption (v20 prefix), which only the browser's own elevation service can unwrap. decryptCookieValueRaw accepts any /^v\d\d$/ prefix and hands v20 to the AES-256-GCM path, where it fails and returns null. The caller counts that as `skipped`, identical to a malformed row, so the import reports importedCookies: 0 with no error — a failure that looks like an empty profile. Detect the v20 prefix while scanning rows and surface a warning naming the cause and the workaround (export from the browser, then Import from File). Decryption behaviour is unchanged; v10/v11 on macOS and Linux are untouched. True v20 decryption is not viable outside the browser's elevation service, so an honest error is the useful outcome here. Closes stablyai#13192 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ZcrKK54K7sRnSkT6a6Jut
The warning was attached below a `decryptedCookies.length === 0` early return, so it never fired for the case the issue actually reports: a Chrome 140 profile where *every* cookie is app-bound decrypts nothing, returns there, and still reported a clean zero. Add an end-to-end test that drives importCookiesFromBrowser against a real SQLite fixture of v20 rows with a working key. It failed against the previous commit, which is how the gap surfaced. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ZcrKK54K7sRnSkT6a6Jut
bef02bd to
c3ea2c0
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
|
Thanks for this — the diagnosis is right and the I've opened #14683, which supersedes this one. It keeps the core insight (detect the app-bound prefix and report it rather than swallowing it) and extends it in four ways:
Not a criticism of the work here; the general defect turned out to be the missing distinction between "decryption failed" and "no cookies present" rather than the |
Review-loop findings on the initial commit, all fixed here. - CORRECTNESS: v11 rows were attempted with the v10 key when the keyring was unavailable. AES-128-CBC is unauthenticated, so a wrong key that yields valid PKCS#7 padding was accepted — roughly 1 in 256 per row. Garbage values were written into the jar as real cookies, and because those rows counted as successes the warning this PR adds could never fire. Key eligibility is now explicit per version rather than implicit in key ordering. - CORRECTNESS: the CBC path returned an empty Buffer for a prefix-only value BEFORE checking eligibility. An empty Buffer is truthy, so an ineligible row counted as imported and reached the live-jar clear. Eligibility now precedes that branch and empty CBC ciphertext is rejected as malformed. - ACCURACY: a named cause reported the TOTAL failure count, so one v20 row plus one corrupt row claimed both failed to app-bound encryption. Counts are now exact per cause, with the remainder reported separately and a tie falling back to 'unknown'. Exact-count approach carried over from #13193. - The app-bound copy no longer dead-ends. It names the existing in-app file import without describing how to produce the file — Chrome has no native decrypted-cookie export, so concrete guidance would send users to an extension that can read their whole session jar. - Direct prefix edge tests carried forward from #13193. Repo-wide search found no second multi-key unauthenticated-CBC first-success site, so this pattern was one occurrence rather than a class. Co-authored-by: manuaudio <manuaudio@users.noreply.github.com>
* fix(browser): report cookies an import could not decrypt Supersedes #13193, which reported only the Windows v20 case. Nothing distinguished "decryption failed" from "no cookies present". A row that would not decrypt was folded into the generic `skipped` counter, and a profile whose rows all failed returned ok:true with importedCookies:0 and no warning — a green "Imported 0 cookies from Google Chrome." The two situations produce opposite result shapes and the worse one reported success. Attribute the cause at the point of failure, while the version prefix is still in hand, and surface it as one `cookies-undecryptable` warning carrying the reason. Covers all three known causes rather than one prefix: - app-bound-encryption: Chrome/Edge 140+ on Windows write `v20`, which only the writing browser can unwrap. The version gate is a FORMAT check (`/^v\d\d$/`), so v20 passed it and failed inside AES like corruption. - linux-keyring-unavailable: getLinuxEncryptionKey derived the v11 key from an empty password when both secret-tool lookups failed, so it never returned null and the "Could not access encryption key" guard was unreachable on Linux. - unknown: any other cause still warns instead of reporting success. Deliberately not a hard failure on Linux: Chrome falls back to the "peanuts" v10 key precisely when no keyring exists, so those profiles still import. Pinned by a regression test. Refs #13192, #14181 * fix(browser): attribute decrypt failures exactly and gate CBC by version Review-loop findings on the initial commit, all fixed here. - CORRECTNESS: v11 rows were attempted with the v10 key when the keyring was unavailable. AES-128-CBC is unauthenticated, so a wrong key that yields valid PKCS#7 padding was accepted — roughly 1 in 256 per row. Garbage values were written into the jar as real cookies, and because those rows counted as successes the warning this PR adds could never fire. Key eligibility is now explicit per version rather than implicit in key ordering. - CORRECTNESS: the CBC path returned an empty Buffer for a prefix-only value BEFORE checking eligibility. An empty Buffer is truthy, so an ineligible row counted as imported and reached the live-jar clear. Eligibility now precedes that branch and empty CBC ciphertext is rejected as malformed. - ACCURACY: a named cause reported the TOTAL failure count, so one v20 row plus one corrupt row claimed both failed to app-bound encryption. Counts are now exact per cause, with the remainder reported separately and a tie falling back to 'unknown'. Exact-count approach carried over from #13193. - The app-bound copy no longer dead-ends. It names the existing in-app file import without describing how to produce the file — Chrome has no native decrypted-cookie export, so concrete guidance would send users to an extension that can read their whole session jar. - Direct prefix edge tests carried forward from #13193. Repo-wide search found no second multi-key unauthenticated-CBC first-success site, so this pattern was one occurrence rather than a class. Co-authored-by: manuaudio <manuaudio@users.noreply.github.com> * fix(pr): preserve split worktree slice Remove the unrelated rollback of the worktree-slice split and its forbidden max-lines baseline addition from this cookie-import PR. * fix(browser): match the unknown decrypt reason explicitly CI's type-aware code-quality gate flagged the reason switch as non-exhaustive: the 'unknown' member was handled by `default:` rather than matched. Matching it explicitly keeps the behaviour identical today and makes the gate enforce the thing that matters — adding a new reason to the union now fails the switch instead of falling silently into a generic message that would not describe it. This gate is separate from `oxlint` and is not covered by running oxlint on the changed files, which is why it only surfaced in CI. --------- Co-authored-by: manuaudio <manuaudio@users.noreply.github.com>
* fix(browser): report cookies an import could not decrypt Supersedes #13193, which reported only the Windows v20 case. Nothing distinguished "decryption failed" from "no cookies present". A row that would not decrypt was folded into the generic `skipped` counter, and a profile whose rows all failed returned ok:true with importedCookies:0 and no warning — a green "Imported 0 cookies from Google Chrome." The two situations produce opposite result shapes and the worse one reported success. Attribute the cause at the point of failure, while the version prefix is still in hand, and surface it as one `cookies-undecryptable` warning carrying the reason. Covers all three known causes rather than one prefix: - app-bound-encryption: Chrome/Edge 140+ on Windows write `v20`, which only the writing browser can unwrap. The version gate is a FORMAT check (`/^v\d\d$/`), so v20 passed it and failed inside AES like corruption. - linux-keyring-unavailable: getLinuxEncryptionKey derived the v11 key from an empty password when both secret-tool lookups failed, so it never returned null and the "Could not access encryption key" guard was unreachable on Linux. - unknown: any other cause still warns instead of reporting success. Deliberately not a hard failure on Linux: Chrome falls back to the "peanuts" v10 key precisely when no keyring exists, so those profiles still import. Pinned by a regression test. Refs #13192, #14181 * fix(browser): attribute decrypt failures exactly and gate CBC by version Review-loop findings on the initial commit, all fixed here. - CORRECTNESS: v11 rows were attempted with the v10 key when the keyring was unavailable. AES-128-CBC is unauthenticated, so a wrong key that yields valid PKCS#7 padding was accepted — roughly 1 in 256 per row. Garbage values were written into the jar as real cookies, and because those rows counted as successes the warning this PR adds could never fire. Key eligibility is now explicit per version rather than implicit in key ordering. - CORRECTNESS: the CBC path returned an empty Buffer for a prefix-only value BEFORE checking eligibility. An empty Buffer is truthy, so an ineligible row counted as imported and reached the live-jar clear. Eligibility now precedes that branch and empty CBC ciphertext is rejected as malformed. - ACCURACY: a named cause reported the TOTAL failure count, so one v20 row plus one corrupt row claimed both failed to app-bound encryption. Counts are now exact per cause, with the remainder reported separately and a tie falling back to 'unknown'. Exact-count approach carried over from #13193. - The app-bound copy no longer dead-ends. It names the existing in-app file import without describing how to produce the file — Chrome has no native decrypted-cookie export, so concrete guidance would send users to an extension that can read their whole session jar. - Direct prefix edge tests carried forward from #13193. Repo-wide search found no second multi-key unauthenticated-CBC first-success site, so this pattern was one occurrence rather than a class. Co-authored-by: manuaudio <manuaudio@users.noreply.github.com> * fix(pr): preserve split worktree slice Remove the unrelated rollback of the worktree-slice split and its forbidden max-lines baseline addition from this cookie-import PR. * fix(browser): match the unknown decrypt reason explicitly CI's type-aware code-quality gate flagged the reason switch as non-exhaustive: the 'unknown' member was handled by `default:` rather than matched. Matching it explicitly keeps the behaviour identical today and makes the gate enforce the thing that matters — adding a new reason to the union now fails the switch instead of falling silently into a generic message that would not describe it. This gate is separate from `oxlint` and is not covered by running oxlint on the changed files, which is why it only surfaced in CI. --------- Co-authored-by: manuaudio <manuaudio@users.noreply.github.com>
) * fix(browser): report cookies an import could not decrypt Supersedes stablyai#13193, which reported only the Windows v20 case. Nothing distinguished "decryption failed" from "no cookies present". A row that would not decrypt was folded into the generic `skipped` counter, and a profile whose rows all failed returned ok:true with importedCookies:0 and no warning — a green "Imported 0 cookies from Google Chrome." The two situations produce opposite result shapes and the worse one reported success. Attribute the cause at the point of failure, while the version prefix is still in hand, and surface it as one `cookies-undecryptable` warning carrying the reason. Covers all three known causes rather than one prefix: - app-bound-encryption: Chrome/Edge 140+ on Windows write `v20`, which only the writing browser can unwrap. The version gate is a FORMAT check (`/^v\d\d$/`), so v20 passed it and failed inside AES like corruption. - linux-keyring-unavailable: getLinuxEncryptionKey derived the v11 key from an empty password when both secret-tool lookups failed, so it never returned null and the "Could not access encryption key" guard was unreachable on Linux. - unknown: any other cause still warns instead of reporting success. Deliberately not a hard failure on Linux: Chrome falls back to the "peanuts" v10 key precisely when no keyring exists, so those profiles still import. Pinned by a regression test. Refs stablyai#13192, stablyai#14181 * fix(browser): attribute decrypt failures exactly and gate CBC by version Review-loop findings on the initial commit, all fixed here. - CORRECTNESS: v11 rows were attempted with the v10 key when the keyring was unavailable. AES-128-CBC is unauthenticated, so a wrong key that yields valid PKCS#7 padding was accepted — roughly 1 in 256 per row. Garbage values were written into the jar as real cookies, and because those rows counted as successes the warning this PR adds could never fire. Key eligibility is now explicit per version rather than implicit in key ordering. - CORRECTNESS: the CBC path returned an empty Buffer for a prefix-only value BEFORE checking eligibility. An empty Buffer is truthy, so an ineligible row counted as imported and reached the live-jar clear. Eligibility now precedes that branch and empty CBC ciphertext is rejected as malformed. - ACCURACY: a named cause reported the TOTAL failure count, so one v20 row plus one corrupt row claimed both failed to app-bound encryption. Counts are now exact per cause, with the remainder reported separately and a tie falling back to 'unknown'. Exact-count approach carried over from stablyai#13193. - The app-bound copy no longer dead-ends. It names the existing in-app file import without describing how to produce the file — Chrome has no native decrypted-cookie export, so concrete guidance would send users to an extension that can read their whole session jar. - Direct prefix edge tests carried forward from stablyai#13193. Repo-wide search found no second multi-key unauthenticated-CBC first-success site, so this pattern was one occurrence rather than a class. Co-authored-by: manuaudio <manuaudio@users.noreply.github.com> * fix(pr): preserve split worktree slice Remove the unrelated rollback of the worktree-slice split and its forbidden max-lines baseline addition from this cookie-import PR. * fix(browser): match the unknown decrypt reason explicitly CI's type-aware code-quality gate flagged the reason switch as non-exhaustive: the 'unknown' member was handled by `default:` rather than matched. Matching it explicitly keeps the behaviour identical today and makes the gate enforce the thing that matters — adding a new reason to the union now fails the switch instead of falling silently into a generic message that would not describe it. This gate is separate from `oxlint` and is not covered by running oxlint on the changed files, which is why it only surfaced in CI. --------- Co-authored-by: manuaudio <manuaudio@users.noreply.github.com>
|
Closing as fully superseded by merged #14683. That change carries this PR's I checked the complete scope and follow-up comments here, verified the current import/toast implementation, and reran the focused regression tests. No separate decryption implementation is being dropped: this PR deliberately leaves decryption unchanged. Thanks for identifying both the format issue and the original early-return gap. |
Closes #13192.
Summary
Importing cookies from Chrome/Edge 140+ on Windows now says why it failed instead of reporting a clean zero.
Before, the summary read
importedCookies: 0withtotalCookies > 0and no error — indistinguishable from an empty profile. Now the import surfaces a warning naming the cause and the workaround: export the cookies from the browser and use Import from File.Root cause
decryptCookieValueRawvalidates the version prefix as/^v\d\d$/and then routes anything on Windows to the AES-256-GCM path:v20satisfies that regex, so every app-bound row is fed to GCM with the user's DPAPI key, fails, and returnsnull. The caller then collapses it into the generic skip:which is the same branch a malformed row takes. That is why the failure is invisible: the rows are read fine, they just decode to nothing, and nothing distinguishes "one bad row" from "this entire profile uses an encryption scheme we cannot read".
What changed
isAppBoundEncryptedCookie()— exported predicate for thev20prefix.decryptCookieValueRawreturnsnullthey are indistinguishable from malformed ones.app-bound-encryptionwarning with the count.pnpm run sync:localization-catalog.Decryption behaviour is unchanged. The
v10/v11paths on macOS and Linux are untouched, and no attempt is made to decryptv20— as the issue notes, that requires the browser's own elevation service (IElevator::DecryptData) and is not viable from Electron. An honest, actionable error is the useful outcome.Credit to the reporter for the diagnosis; this implements the "at a minimum" suggestion from the issue rather than the fork patch, which I did not have access to.
Screenshots
A warning toast where there was previously a silent success. No layout or component change — it reuses the existing warning-toast mechanism and its discriminated union, so it renders exactly like the import warnings already in the flow.
I don't have a Windows machine with a Chrome 140 profile to capture it against, which is the same reason the end-to-end note below exists.
Testing
pnpm lintpnpm typecheckpnpm test— scoped to the touched tree, not the full suite (see below)pnpm buildpnpm typecheckandoxlintpass. All three localization verifiers (catalog,extraction,coverage) exit 0. 603 tests acrosssrc/main/browser/pass, including the existing cookie-import suites. Scoped suites rather than a fullpnpm build; no packaging or dependency surface is touched.New
browser-cookie-import-app-bound.test.tscovers thev20prefix, thev10/v11prefixes it must not touch, a plaintext value, and short/empty buffers.Verified non-blind: stubbing the predicate to
return falsefails only the detection assertion while the four negative cases keep passing — so the test distinguishes the fix from its absence rather than merely exercising the function.I could not reproduce on Windows from this machine, so the detection is verified at the byte level and by unit test rather than against a live Chrome 140 profile. Worth a maintainer with Windows confirming the toast end to end before this lands.
AI Review Report
Reviewed with Claude Opus 5 against the CONTRIBUTING checklist.
v20appears, which is Windows. macOS/Linuxv10/v11decryption is untouched and covered by the existing suites; the new negative cases pin that those prefixes are not caught by the predicate. No path handling, shell behaviour, accelerator or shortcut label involved.What it flagged and I acted on: the first cut inferred app-bound encryption from "imported 0 of N", which would also fire on a profile whose rows all failed for unrelated reasons. It now counts the
v20rows explicitly before decryption is attempted, so the warning names a cause it actually observed.Security Audit
Reviewed for input handling, command execution, path handling, auth, secrets, dependency and IPC risk. This one touches cookie material, so it got the closest look.
v10/v11GCM and DPAPI paths are byte-for-byte unchanged.Follow-up: none required for this change. The underlying inability to read
v20is a browser-imposed limit, not something to work around.Notes
Windows-specific in practice —
v20app-bound encryption ships in Chrome/Edge 140+ on Windows only. The code path is platform-neutral but will not fire on macOS or Linux profiles.The one open item is the end-to-end confirmation on a real Windows profile, flagged above. If someone on the team has one handy I'd appreciate the check; if it looks wrong I'll fix it.
X: @manuaudiomix