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):
| File | Role | Format |
|---|---|---|
logins.json | encrypted usernames + passwords | JSON, base64 ASN.1 blobs |
key4.db | the key store | SQLite |
key3.db | key store on pre-2018 Firefox | Berkeley 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:
| OS | Path |
|---|---|
| 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 rowid = 'password'carries the global salt (item1) and a password-check blob (item2).nssPrivate— the row whosea102equals the well-known idf8000000000000000000000000000001carriesa11, 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
- Load
key4.db(orkey3.db) andlogins.json— drop both onto the in-browser parser. - Enter the primary password. Leave it blank if none was set.
- 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:
| OID | Scheme |
|---|---|
1.2.840.113549.1.12.5.1.3 | pbeWithSha1And3KeyTripleDES-CBC (legacy 3DES) |
1.2.840.113549.1.5.13 | PBES2 → 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_decrypton a system libnss3 below 3.113 — fails on migrated entries, typically withCredentials 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_decrypt | In-browser decryptor | |
|---|---|---|
| Crypto engine | the system libnss3 (real NSS) | a self-contained Rust/WASM port |
| Install | Python 3.9+ and a matching libnss3 | nothing; a browser tab |
| Firefox 144 AES entries | needs libnss3 ≥ 3.113 | not yet: 3DES login entries only |
| Profile input | a folder with profiles.ini | the two raw files |
| Output | --format human/csv/json/tabular/pass | an 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-checkfails and there is no shortcut — it gates everything. - key3.db. Very old profiles use the Berkeley-DB
key3.dbinstead ofkey4.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 inlogins.json— you need both files, every time.