How Firefox Derives Encryption Keys From Your Password
This article provides a complete overview of how a Mozilla Account (formerly Firefox Account) uses your password to secure your browser data. By utilizing client-side cryptographic hashing and key stretching, Firefox generates separate keys for server authentication and data encryption directly on your device. This zero-knowledge architecture ensures that your bookmarks, history, and saved passwords are encrypted before they ever leave your computer, making it mathematically impossible for Mozilla to read your synced data.
1. Local Password Stretching
When you log into your Mozilla Account in the Firefox browser, your raw password is never sent over the internet. Instead, Firefox immediately processes your password locally on your device.
Firefox combines your account email address (acting as a cryptographic "salt") with your password and runs them through a key-stretching algorithm called PBKDF2 (Password-Based Key Derivation Function 2) using 1,000 iterations of SHA-256. This process deliberately slows down the key generation to protect against brute-force attacks and results in a 32-byte "stretched" password.
2. Splitting Authentication from Encryption
Once Firefox has the stretched password, it must solve a fundamental problem: it needs to prove your identity to Mozilla's servers without giving Mozilla the information needed to decrypt your data.
To achieve this, Firefox passes the stretched password through an HKDF (HMAC-based Extract-and-Expand Key Derivation Function). This function splits the stretched password into two distinct, cryptographically isolated keys:
- The Authentication Key (
authPW): Used solely to log you into your Mozilla Account. - The Key-Wrapping Key (
unwrapBKey): Used to unlock your encryption keys. This key never leaves your device.
Note that because HKDF is a one-way mathematical function, someone who possesses the Authentication Key cannot work backward to figure out the Key-Wrapping Key or your original password.
3. Authenticating with Mozilla
Firefox sends the Authentication Key (authPW) to
Mozilla's servers. Mozilla hashes this key again on their end and checks
it against their database to verify your identity.
Once verified, the server knows who you are. In response, the Mozilla
server sends your browser a "wrapped" (encrypted) master key called
wrap(kB). Mozilla stores this wrapped key on its servers,
but because it is encrypted, Mozilla has no idea what the actual key
is.
4. Unlocking the Master Sync Key
Your browser now has the wrap(kB) key from the server,
and it still holds the unwrapBKey that it generated locally
in Step 2.
Firefox combines unwrapBKey and wrap(kB) to
decrypt the true master sync key, known simply as kB (Class
B Key). Because unwrapBKey never left your computer, your
local Firefox browser is the only entity in the world capable of
unlocking kB.
5. Encrypting Your Browser Data
The unlocked kB key is the ultimate secret that protects
your privacy. Firefox passes kB through another HKDF
process to generate the specific symmetric encryption keys (using
AES-256) used by Firefox Sync.
Before Firefox uploads your bookmarks, open tabs, browsing history,
or saved passwords to Mozilla’s cloud servers, it encrypts that data
locally using the keys derived from kB. When you sign into
Firefox on a second device, that device repeats this entire 5-step
process to derive the exact same kB key, allowing it to
download and decrypt your data locally.
The Consequence of Zero-Knowledge Security
Because Mozilla cannot derive your unwrapBKey, they have
zero knowledge of your master kB key and cannot read your
data. The ultimate proof of this architecture happens when you forget
your password. If you reset your Mozilla Account password without having
previously generated a local "Recovery Key," Mozilla has no way to
decrypt your old wrap(kB). Consequently, resetting your
password permanently wipes your synced data from Mozilla's servers, as
the old data becomes permanently indecipherable to everyone, including
Mozilla.