# How Chrome encrypts cookies on Mac, and our per-profile key

> Chrome on a Mac turns a Keychain password into an AES key with PBKDF2. Our engine lets Mosaic pass each profile its own password and keeps the v10 format.

Source: https://mosaicbrowser.com/blog/cookie-key-per-profile

## Mosaic gives every profile's cookies their own key

Chrome on a Mac turns a Keychain password into an AES key with PBKDF2. Our engine lets Mosaic pass each profile its own password and keeps the v10 format.

![One password per profile, the same v10 envelope, beside a screenshot: importing a cookie jar into a Mosaic profile](https://mosaicbrowser.com/covers/cookie-key-per-profile.webp)

On a Mac, Chrome encrypts each cookie value with AES-128-CBC, using a key it derives from a password kept in your login Keychain. The password is an item called `Chrome Safe Storage`, made from 16 random bytes the first time Chrome needs it. Chrome runs it through PBKDF2 and writes every encrypted value with a `v10` prefix into the profile's `Cookies` database. Our engine, Tesseract Chrome, runs every profile with `--use-mock-keychain`, which keeps all of that but replaces the password with a constant from Chromium's source. A change in our engine lets Mosaic pass each profile a password of its own instead, and changes nothing else.

## How Chrome encrypts a cookie on macOS

Four lines cover it. We read them off Chromium's source and then decrypted real cookies from our own disk with them, before any of our code was allowed near a jar:

```
password        = Keychain item "Chrome Safe Storage" (Base64 of 16 random bytes)
key             = PBKDF2-HMAC-SHA1(password, salt "saltysalt", 1003 iterations, 16 bytes)
plain           = SHA-256(host_key) || value
encrypted_value = "v10" || AES-128-CBC(key, IV = 16 spaces, PKCS#7(plain))

```

Where people trip when they read the file by hand:

- On a Chromium build the item is `Chromium Safe Storage`, not `Chrome Safe Storage`.
- 32 bytes of garbage before the value? That's the SHA-256 of the host, and it means your key was right. Chromium glues it on so a blob moved to another host's row won't decrypt as valid. Skip it.
- The "wants to use Chrome Safe Storage" prompt is this Keychain read. Chrome makes it on a worker thread, and nothing decrypts until it returns.

On Windows the scheme is different, with App-Bound Encryption on top; that story is in [App-Bound Encryption, and why tools stopped reading Chrome's cookies](https://mosaicbrowser.com/blog/chrome-app-bound-encryption).

Mosaic is a desktop app

Email yourself the link and open it on your computer.

[How it works: Local first](https://mosaicbrowser.com/features/local-first)

## Why our engine does not use the Keychain

There is one login Keychain for the whole machine, and Mosaic runs many browser profiles on it. The first finished build of our engine wrote `Local State` and then sat at 0% CPU with no window, its main thread inside `SecItemCopyMatching` waiting for an access dialog. Every launcher bundle was a new code identity to the Keychain, so "Always Allow" lasted one launch.

`--use-mock-keychain` removes the dialog. It does not remove encryption: the format, the salt and the `v10` prefix all stay, and the password becomes `mock_password`, a constant anyone can read in Chromium's source. Before this change existed, one command against a real profile printed a live session cookie in about a second. [Chromium's mock keychain](https://mosaicbrowser.com/blog/mock-keychain-cookies) has that measurement and the rest of what we sealed after it.

## What the change does

Two files. A new switch in `components/os_crypt/common/os_crypt_switches.h`:

```
inline constexpr char kOsCryptPassword[] = "os-crypt-password";

```

and a dozen lines in `keychain_key_provider.mm`, the one place on macOS where a password becomes a key. The change does it like this:

```
std::string password;
const base::CommandLine& mosaic_cmd = *base::CommandLine::ForCurrentProcess();
if (mosaic_cmd.HasSwitch(os_crypt::switches::kOsCryptPassword)) {
  password = mosaic_cmd.GetSwitchValueASCII(os_crypt::switches::kOsCryptPassword);
} else {
  KeychainPassword keychain_password(*keychain_to_use);
  password = keychain_password.GetPassword();
}

```

We check the switch first, before `KeychainPassword` is ever constructed. Had it come second, a profile with its own password could still have hung on a dialog, or quietly fallen back to the constant when the read failed. From that line down it's Chromium's code untouched (PBKDF2, AES-128-CBC, `v10`). Open one of our jars with the right password and you can't tell it from any other Chromium jar.

We changed only the asynchronous key provider because in Chromium 153, when we wrote it, that was the single place a macOS password became a key. `grep -rl saltysalt components/` found the POSIX and Freedesktop providers and this one, and the old synchronous backend was gone.

## Where each profile's password comes from

Mosaic does not store the cookie passwords anywhere. At launch it derives one from the library's data key and the profile's id:

```
cookie password = Base64( scrypt(data key, "mosaic-cookies:<profile id>", N = 2^14, r = 8, p = 1, 32 bytes) )

```

and passes it as `--os-crypt-password`. Delete a profile from the store and its key is gone too; there's no id left to derive from. Copy a profile folder to another machine and no key goes with it. The data key itself is wrapped under your Mosaic account, plus your app-lock password when that is on, which is what lets us say the store and cookie jars are encrypted on disk. What that protects, and what it does not, is in [local-first](https://mosaicbrowser.com/features/local-first).

It also means Mosaic can open a stopped profile's jar itself, read-only, no browser needed. That's where `GET /profiles/:id/cookies` gets its answer when the profile is closed; the response says `source: "jar"` rather than `"live"`.

## Old jars keep the key they were written with

We wired the switch on 14 September 2026 and ran the jar reader over the library. It printed `87 of 92 cookies across 9 jars open with Chromium's published password`. Pass those nine profiles a fresh password and Chromium can't read a cookie it wrote, so all nine are logged out of everything.

What we do instead, per profile folder:

- **No jar yet:** write `.mosaic-cookie-key` (it holds `v1`) and launch with the profile's own key.
- **Marker present:** launch with the profile's own key.
- **Jar but no marker:** launch on the old mock password, untouched.

The marker lives beside the data, not in the store, because a store restored from a week-old backup shouldn't vouch for bytes it never saw. There is a re-key routine for the third case: copy the jar, rewrite it, read every row back under the new key, then rename. A crash anywhere leaves the original. Nothing in the window calls it yet, so old jars stay on the old key for now.

What this change does not fix, because it was never broken: one profile seeing another's cookies. Each has its own data folder, and nineteen jars on one machine shared nothing. The leak was the files, to anyone holding the laptop, a backup or a dead Mac's disk.

The price is that the password is on the browser's command line, and `ps` shows it to the user who launched it. We took that. Argv is never written to disk, and code running as you could read the key from Mosaic's memory anyway. The rest of our changes to Chromium, and why the engine is ours, is in [why we built our own Chromium](https://mosaicbrowser.com/blog/why-we-built-our-own-chromium).

## Sources

1. [Chromium source: components/os_crypt/async/browser/keychain_key_provider.mm](https://chromium.googlesource.com/chromium/src/+/main/components/os_crypt/async/browser/keychain_key_provider.mm), read November 3, 2026
2. [Chromium source: components/os_crypt/common/keychain_password_mac.mm](https://chromium.googlesource.com/chromium/src/+/main/components/os_crypt/common/keychain_password_mac.mm), read November 3, 2026

## Questions

### Where does Chrome store the cookie encryption key on a Mac?

In the login Keychain, as a generic password item named Chrome Safe Storage (Chromium Safe Storage for Chromium builds). Chrome creates it on first use from 16 random bytes, Base64-encoded, and derives the actual AES key from it each time it starts.

### What algorithm does Chrome use to encrypt cookies on macOS?

AES-128-CBC with a fixed IV of sixteen spaces. The key is PBKDF2-HMAC-SHA1 over the Keychain password with the salt saltysalt and 1003 iterations. Each encrypted value starts with the three bytes v10.

### Why does a decrypted Chrome cookie start with 32 bytes of junk?

Those bytes are the SHA-256 of the cookie's host. Recent Chromium versions put that hash in front of the value before encrypting it, so a blob copied from one row cannot be pasted into another host's row and still read as valid.

### Does --use-mock-keychain turn cookie encryption off?

No. It keeps the same format and swaps the Keychain password for a constant in Chromium's source. Anyone with the Cookies file and that constant can decrypt every value.

### Can Mosaic read a profile's cookies while the browser is closed?

Yes. Mosaic derives the profile's cookie password itself, so it can open the stopped profile's Cookies file read-only and decrypt it with the same arithmetic Chromium uses. The REST API's cookies route answers from that jar when the profile is not running.

## Related

[Chromium's mock keychain, and why we encrypt the store](https://mosaicbrowser.com/blog/mock-keychain-cookies): Chromium's --use-mock-keychain keeps cookie encryption on but uses a password from its own source. We read a live session cookie off disk, then sealed it.

[App-Bound Encryption, and why tools stopped reading Chrome's cookies](https://mosaicbrowser.com/blog/chrome-app-bound-encryption): App-Bound Encryption ties Chrome's cookie key on Windows to Chrome itself, so tools reading the Cookies file broke. Export from inside the browser.

[Local first: your profiles stay on your computer](https://mosaicbrowser.com/features/local-first): Mosaic has no cloud copy of your profiles. Profiles, cookies and proxies stay on your computer, encrypted on disk, with app lock, daily backups and a trash.

[Why we built our own Chromium instead of injecting JavaScript](https://mosaicbrowser.com/blog/why-we-built-our-own-chromium): Mosaic changes fingerprint values inside its own engine. Three measured differences between Chrome and plain Chromium explain why that matters.

[Why we accept a cookie key on the command line](https://mosaicbrowser.com/blog/a-secret-on-the-command-line): Arguments are readable through ps by other accounts on a Mac, but never written to disk. Mosaic puts a cookie key there anyway, for one threat.

[Device-bound sessions and the end of copying a cookie](https://mosaicbrowser.com/blog/device-bound-session-credentials): With Device Bound Session Credentials in Chrome, a site reissues its session cookie only to the device with the key. A copied cookie lasts until it expires.

[Chrome kept third-party cookies. What that means for cookie jars](https://mosaicbrowser.com/blog/chrome-keeps-third-party-cookies): Chrome is not removing third-party cookies: Google dropped the phase-out and then the prompt. A jar per account matters as much as it did before.



## Mosaic, on your own computer

The browser this blog is about: its own Chromium, fingerprints from real machines and a proxy IP per profile. Free covers 3 profiles with no card, and Pro is $25 a month for any number of them.

Mosaic is a desktop app

Email yourself the link and open it on your computer.
