Skip to content

fix(desktop): encrypt browser cookies at rest - #63611

Closed
Hona wants to merge 1 commit into
devfrom
cookie-encryption
Closed

Hona wants to merge 1 commit into
devfrom
cookie-encryption

Conversation

@Hona

@Hona Hona commented Nov 12, 2026

Copy link
Copy Markdown
Member

Packaged desktop builds store browser cookies in plain text. This turns on Electron's cookie encryption, so the browser pane's sign-ins are encrypted with the OS key store.

Before After
EnableCookieEncryption fuse off (Electron default) on
Cookies database value in plain text encrypted_value
Key none Keychain (macOS), DPAPI (Windows), libsecret or kwallet (Linux)
// packages/desktop/electron-builder.config.ts
electronFuses: { enableCookieEncryption: true },

Why now

Notes for review

  • One-way. Turning the fuse off later, or a downgrade to an older build, cannot read the encrypted cookies: users are signed out of sites in the pane. The app does not crash.
  • Existing cookies stay in plain text until each is written again; new writes are encrypted.
  • Linux. With no keyring, Chromium falls back to a fixed key (obfuscation only). A locked keyring can prompt on first launch, and a changed keyring signs the user out of sites.
  • Unsigned macOS builds (local, PR dry runs) can show a Keychain prompt.
  • Signing. electron-builder flips the fuse before signing, so signatures stay valid.
  • To check in CI artifacts: bunx @electron/fuses read --app <built app> reports EnableCookieEncryption is Enabled. Not verified in a packaged build locally.
  • No other fuse changes. RunAsNode, the Node options and inspect fuses, and the asar fuses each need their own change and test.

Visual

<svg xmlns="http://www.w3.org/2000/svg" width="240" height="72" viewBox="0 0 240 72" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round">
  <rect x="24" y="14" width="132" height="44" rx="6" opacity=".35"/>
  <g opacity=".7">
    <path d="M36 28h60M36 38h84M36 48h44">
      <animate attributeName="opacity" values="1;1;0;0;1" keyTimes="0;.3;.45;.92;1" dur="4s" repeatCount="indefinite"/>
    </path>
  </g>
  <g opacity="0" stroke-dasharray="2 5" stroke-width="3">
    <path d="M36 28h60M36 38h84M36 48h44"/>
    <animate attributeName="opacity" values="0;0;.6;.6;0" keyTimes="0;.3;.45;.92;1" dur="4s" repeatCount="indefinite"/>
  </g>
  <rect x="178" y="32" width="32" height="24" rx="4" opacity=".85"/>
  <path d="M185 32v-7a9 9 0 0 1 18 0v7" opacity=".85">
    <animateTransform attributeName="transform" type="translate" values="0 -5;0 -5;0 0;0 0;0 -5" keyTimes="0;.3;.45;.92;1" dur="4s" repeatCount="indefinite"/>
  </path>
  <circle cx="194" cy="44" r="2.5" fill="currentColor" stroke="none" opacity=".85"/>
</svg>

Copilot AI balanced review requested due to automatic review settings November 12, 2026 21:56

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

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

The change looks sound. I couldn't run a packaged app here (no macOS/Windows, and the Linux sandbox is missing Electron's system libraries). What I did check: the new config sets EnableCookieEncryption from off to on when applied to the lockfile's Electron 44.9.1 binary. In electron-builder 26.15.7 the fuse is set before signing, the macOS release script re-signs every Mach-O file, and the Windows --prepackaged installer step skips packing, so it doesn't change the signed app again. electron-builder.config.test.ts passes, and tsc -b reports no errors. I'd still like the CI check you describe (@electron/fuses read on the built artifacts) to confirm it.

Public API: unchanged. This is a packaging setting only; the one visible effect is the cookie storage format, which is one-way, as you note.

One small, non-blocking point: changing the fuse breaks the existing signature on the Electron framework binary. A local bun run pack on Apple Silicon (built with identity=null, without the release script re-signing it) will therefore produce an app that macOS won't launch until it is re-signed. Adding resetAdHocDarwinSignature: true next to the fuse would keep those local builds runnable, and release builds would be unaffected because they are re-signed anyway.

@Hona

Hona commented Nov 16, 2026

Copy link
Copy Markdown
Member Author

Folded into #63002, which now carries this change (the cookie-encryption fuse, plus the ad-hoc re-sign and the run-as-Node hardening) with the rest of the browser work. Closing in its favour.

@Hona Hona closed this Nov 16, 2026
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