# Encryption key stored next to the data: what it stops

> An encryption key stored next to the encrypted data, in a 0600 file, stopped the two attacks we measured but not a copied folder. App lock and the account did.

Source: https://mosaicbrowser.com/blog/encryption-that-travels-with-the-folder

## We stored the encryption key next to the encrypted data, on purpose

An encryption key stored next to the encrypted data, in a 0600 file, stopped the two attacks we measured but not a copied folder. App lock and the account did.

![The key sat beside the data, and we said so, beside a screenshot: mosaic security settings: everything on disk sealed with AES-256-GCM, and an optional app lock](https://mosaicbrowser.com/covers/encryption-that-travels-with-the-folder.webp)

An encryption key stored next to the encrypted data is not automatically pointless. It depends on who can read the key file and who could read the data before. Mosaic's first vault did exactly this, on purpose: the data key sat in a `0600` file beside the store. That stopped the two attacks we had measured on our own disk, and it did not protect a full copy of the folder. We wrote that limit into the code's own header, and closed it in two later steps.

## The two attacks we had measured

On 14 September 2026 we pointed one command at a real profile on the development Mac. Our engine launches with `--use-mock-keychain`, and under that flag Chromium encrypts cookies with a password that is a public constant in its own source. The command found the password, `mock_password`, and printed a live session cookie in about a second. Beside it, `mosaic.json`, the file holding every profile, was readable by any user on the machine and carried every proxy password in plain text.

So there were two problems with one cause: nothing in the data directory had a secret of its own. [Chromium's mock keychain](https://mosaicbrowser.com/blog/mock-keychain-cookies) has the full measurement and why the flag is there.

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)

## An encryption key stored next to the data, readable only by you

The fix was one random data key, with everything sensitive sealed under it. `mosaic.json` is encrypted as a whole, proxy credentials included, and each profile's cookies get their own password derived from the data key and the profile's id, handed to the engine through a switch our engine adds ([one key per profile's cookies](https://mosaicbrowser.com/blog/cookie-key-per-profile) covers that change).

That leaves the question every design like this has: where does the data key live? The default answer was `vault.json`, a `0600` file in the same folder. `0600` means read and write for the owner only. Another user account on the Mac cannot open it, and neither can anything that is handed `mosaic.json` or a `Cookies` file on its own. The app opens with no prompt and nothing that can go wrong at launch.

What it does not do is protect a copy of the whole folder. Copy the data directory to another machine and the key goes with it. The header of `vault.ts` says this in so many words: the default does not claim that a full copy of the data folder is safe on another machine, because the key travels with the folder.

## Why the key was not in the keychain

The obvious home for a key on a Mac is the keychain, and that is where the first version put it, through Electron's `safeStorage`. It made a copied folder useless, and it broke the app.

`safeStorage` grants access by the app's code signature. The build we ran then was ad-hoc signed, so every rebuild and every update was an identity the keychain had never seen, and the "Mosaic wants to use your confidential information" prompt came back after every update. Worse, the decrypt is synchronous. The main thread waited for the prompt, and a blocked main thread cannot draw the prompt it is waiting for, so the app hung. The keychain is now out of the app entirely, on every platform. [Why the app's secrets left the macOS keychain](https://mosaicbrowser.com/blog/secrets-leave-keychain) is that story in full.

A key in a file was the honest step back: it fixed what we had measured, and its limit was printed where the next person to touch the code would read it.

## What covered the copied folder

The first answer was app lock, in Settings › Security. With it on, the data key is not stored as itself. It is wrapped by scrypt over a password that only the operator has, with N set to 2^16 and r to 8, which costs about 64 MB of memory and a fifth of a second on our machine. That is unnoticeable once at unlock and expensive for someone guessing offline. Until the password is typed nothing decrypts, so a copied disk is ciphertext on any machine.

The second answer came with accounts, on 2 November 2026. In a build with an account server, a library's data key is wrapped under a key derived from two things: a secret the account server keeps for that account and hands only to a signed-in session on a computer it has bound, and, if app lock is on, the password as well. Nothing on the disk is enough on its own. A copied folder does not open for a different account, or for nobody signed in, and the same account can still open its own library on another of its computers, so a backup restored on a new Mac works.

Our server never has your profiles. It holds one random key per account, which opens nothing without the files on your computer. Deleting your Mosaic account deletes that key, so every library it made can never be opened again, by anyone.

## Two rules that made it usable

The data key never changes when its wrapping does. Turning app lock on or off, or adopting an old library into an account, rewraps one key and rewrites nothing sealed under it, so every cookie jar still opens. A security control whose failure mode is data loss does not get turned on.

And a failed decrypt throws an error. It never falls back to an empty store, because a wrong key that looks like a first run would show you a library with no profiles in it and invite you to start over. The longer case for keeping all of this on your own machine is on [local-first](https://mosaicbrowser.com/features/local-first).

## Questions

### Is it pointless to store the encryption key next to the encrypted data?

Not always. If the key file can only be read by your own user and the data used to be readable by everyone, it stops other users and anything that only reads the data file. It does not stop someone who copies the whole folder, key included.

### What does a 0600 file protect against?

Other user accounts on the same computer, and tools that read files they were given without the folder's permissions. A program running as you can still read it, so it is not a defence against malware on your own account.

### How does Mosaic protect a copied data folder now?

In builds with an account server, the data key is wrapped under a secret the account server hands only to a signed-in session on a computer it has bound. A copied folder does not open for another account or for nobody signed in. App lock adds your password as a second half.

### Can the Mosaic server open my profiles?

Our server never has your profiles. It keeps one random key per account, which on its own opens nothing; opening a library takes your account and the files on your computer.

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

[Mosaic gives every profile's cookies their own key](https://mosaicbrowser.com/blog/cookie-key-per-profile): 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.

[Why the app's secrets left the macOS keychain](https://mosaicbrowser.com/blog/secrets-leave-keychain): Electron safeStorage asked for the keychain after every update of our ad-hoc signed app, and hung it on a locked screen. So the key left the keychain.

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



[Do flight prices go up when you search twice? Testing the myth](https://mosaicbrowser.com/blog/flight-prices-repeat-searches): Flight prices rise between searches mostly because cheap fare buckets sell out and cached prices get refreshed. Two browsers at the same minute tell you which.

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