← Back to all articles

Decrypt Firefox Passwords from key4.db and logins.json (Offline)

2026-06-17 · 6 min

Chrome leans on the OS keystore — DPAPI on Windows, the Keychain on macOS. Firefox does its own thing: saved passwords are protected by NSS (Network Security Services), the same crypto library Firefox uses for TLS. Nothing is tied to your Windows account, which makes Firefox passwords more recoverable offline than Chrome's — you just need two files and, if the user set one, the primary password.

This page is both the practical how-to and the byte-level reference. The first half decrypts a profile in four steps; the second half explains what is happening inside key4.db so you can verify the crypto rather than just run it.

Decrypt Firefox passwords in 4 steps

1. Acquire the two files

Both sit in the profile root, the randomly-named Profiles/<xxxx>.default-release/ folder (see Firefox file locations):

FileRoleFormat
logins.jsonencrypted usernames + passwordsJSON, base64 ASN.1 blobs
key4.dbthe key storeSQLite
key3.dbkey store on pre-2018 FirefoxBerkeley DB

Modern Firefox uses key4.db. If the profile predates 2018 you'll find key3.db instead — grab whichever is present. You need the key store and logins.json together; one without the other is useless. Note that cookies.sqlite is not in this picture: Firefox stores cookie values in cleartext, so no key is involved (see browser cookies in forensics and Chrome cookie encryption, which does the opposite).

Profile paths per OS:

OSPath
Windows%APPDATA%\Mozilla\Firefox\Profiles\<xxxx>.default-release\
macOS~/Library/Application Support/Firefox/Profiles/<xxxx>.default-release/
Linux~/.mozilla/firefox/<xxxx>.default-release/

2. What's inside each file

logins.json is an array of entries. Each encryptedUsername and encryptedPassword is base64 of an ASN.1 structure: a key id, the cipher + IV, and the ciphertext.

{
  "logins": [
    {
      "hostname": "https://example.com",
      "encryptedUsername": "MDIEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECC4...",
      "encryptedPassword": "MEIEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECF...",
      "timeCreated": 1700000000000,
      "timeLastUsed": 1701234567890,
      "timePasswordChanged": 1700500000000
    }
  ]
}

key4.db is SQLite. Two tables matter:

  • metaData — the row id = 'password' carries the global salt (item1) and a password-check blob (item2).
  • nssPrivate — the row whose a102 equals the well-known id f8000000000000000000000000000001 carries a11, the wrapped key that decrypts the login entries.

3. The primary password

By default Firefox sets no primary password (formerly "master password"), so the leave-it-blank case is the common one. If the user set one, it is required to unwrap the key, and there is no bypass — this tool does not crack or brute-force it.

The decryption is self-validating. Before touching any login, NSS checks the entered password against the item2 password-check blob. A wrong password fails cleanly; it never produces garbage plaintext. So if you get credentials back, they are real — and if the password is rejected, you know to keep looking for the right one rather than doubting the output.

4. Decrypt it

  1. Load key4.db (or key3.db) and logins.json — drop both onto the in-browser parser.
  2. Enter the primary password. Leave it blank if none was set.
  3. Decrypt.

Each result row maps to a logins.json entry: hostname, the decrypted username and password, plus the timeCreated and timeLastUsed timestamps (timePasswordChanged is in the JSON too, if you read the file directly). Pull those timestamps into a timeline — they show when a credential was first saved and last used, independent of browsing history.

The work runs in a Rust/WASM NSS module entirely in the browser tab, so nothing is uploaded. The rest of this page is what that module does.

Inside key4.db

Both the item2 password-check and the a11 key are wrapped the same way, by a key derived from the global salt and your primary password (empty by default). Which wrapping is used is announced by the algorithm OID in the ASN.1 header:

OIDScheme
1.2.840.113549.1.12.5.1.3pbeWithSha1And3KeyTripleDES-CBC (legacy 3DES)
1.2.840.113549.1.5.13PBES2 → PBKDF2-HMAC-SHA256 + AES-256-CBC (modern)

Modern profiles wrap the key with PBES2 (AES-256). Older ones use the 3DES PBE scheme. In both, the primary password is mixed in only through an initial SHA1(globalSalt || primaryPassword); with no password set, that reduces to SHA1(globalSalt) and everything unwraps with no secret at all.

The PBES2 path has one NSS quirk worth knowing when you implement it: the stored IV is 14 bytes, and the real 16-byte AES IV is those bytes prefixed with 04 0e.

The self-check that makes it trustworthy

You never have to guess whether the derivation worked. Decrypt item2 and the plaintext must be exactly the string password-check followed by its two PKCS#7 padding bytes (\x02\x02). If it matches, the primary password and the whole derivation are correct, so a wrong password fails loudly instead of silently producing garbage. This is the same "decrypt-proves-itself" property as the DPAPI masterkey HMAC.

Once item2 verifies, unwrap a11 to recover the login key, then decrypt each logins.json entry with it and strip PKCS#7 padding to get the cleartext username and password.

What changed in Firefox 144

For years the logins.json entries themselves were always 3DES-CBC, even on profiles whose key4.db key was AES-wrapped. That changed in Firefox 144 (October 2025), which re-encrypts saved logins to AES-256-CBC on disk (Mozilla bug 1974184). In practice:

  • Existing logins are migrated to AES the first time the profile is opened in 144+, so a profile last used on 143 or earlier still holds 3DES entries, while one opened on 144+ does not.
  • Tooling built only for 3DES login entries — including older firefox_decrypt on a system libnss3 below 3.113 — fails on migrated entries, typically with Credentials damaged or cert/key file mismatch. The key-store derivation (3DES PBE vs PBES2) is unchanged; only the per-entry cipher moved.

So when a profile refuses to decrypt on otherwise-correct inputs, check the Firefox version that last wrote it before assuming a wrong password.

Compared with the firefox_decrypt CLI

The common offline reference tool is firefox_decrypt (lclevy's firepwd is the key3.db ancestor). The difference is where the crypto runs:

firefox_decryptIn-browser decryptor
Crypto enginethe system libnss3 (real NSS)a self-contained Rust/WASM port
InstallPython 3.9+ and a matching libnss3nothing; a browser tab
Firefox 144 AES entriesneeds libnss3 ≥ 3.113not yet: 3DES login entries only
Profile inputa folder with profiles.inithe two raw files
Output--format human/csv/json/tabular/passan on-screen table

firefox_decrypt is scriptable and, because it calls the real NSS, tracks Firefox format changes as fast as the installed library does — at the cost of needing a version-matched libnss3 (NSS_LIB_PATH=/opt/nss/lib/ points it at a specific one; -l lists profiles, -c N picks one, -n runs non-interactively with the password on stdin). The in-browser route needs no install and uploads nothing, which makes it the quickest route for profiles last written by Firefox 143 or earlier; for a profile already migrated to AES entries, use firefox_decrypt with a current libnss3.

Pitfalls

  • Primary password. If the user set one and you don't have it, the password-check fails and there is no shortcut — it gates everything.
  • key3.db. Very old profiles use the Berkeley-DB key3.db instead of key4.db; the scheme is similar but the container differs.
  • Firefox 144+ AES entries. See above — a format change, not a wrong password.
  • Don't forget the salt source. The global salt is in key4.db, not in logins.json — you need both files, every time.

Further reading