Documentation
¶
Overview ¶
Package keyretriever owns the master-key acquisition chain shared by all Chromium variants (Chrome, Edge, Brave, Arc, Opera, Vivaldi, Yandex, …). The chain is built once per process and reused for every profile.
Firefox and Safari do not route through this package — Firefox derives its own keys from key4.db via NSS PBE, and Safari reads InternetPassword records directly from login.keychain-db. Each browser package owns its own credential-acquisition strategy; see rfcs/006-key-retrieval-mechanisms.md §7 for the rationale.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChainRetriever ¶
type ChainRetriever struct {
// contains filtered or unexported fields
}
ChainRetriever tries multiple retrievers in order, returning the first success. Used on macOS (gcoredump → password → security) and Linux (D-Bus → peanuts).
func (*ChainRetriever) RetrieveKey ¶
func (c *ChainRetriever) RetrieveKey(storage, localStatePath string) ([]byte, error)
type DBusRetriever ¶
type DBusRetriever struct{}
DBusRetriever queries GNOME Keyring / KDE Wallet via D-Bus Secret Service.
func (*DBusRetriever) RetrieveKey ¶
func (r *DBusRetriever) RetrieveKey(storage, _ string) ([]byte, error)
type KeyRetriever ¶
KeyRetriever retrieves the master encryption key for a Chromium-based browser. Each platform has different implementations:
- macOS: Keychain access (security command) or gcoredump exploit
- Windows: DPAPI decryption of Local State file
- Linux: D-Bus Secret Service or fallback to "peanuts" password
func NewChain ¶
func NewChain(retrievers ...KeyRetriever) KeyRetriever
NewChain creates a ChainRetriever that tries each retriever in order.
type MasterKeys ¶
MasterKeys bundles the per-cipher-version Chromium master keys used to decrypt data from a single profile. decryptValue dispatches on the ciphertext's version prefix and picks the matching key; a missing (nil) key for a tier means "that cipher version cannot be decrypted", but the other tiers remain usable — a Chrome 127+ profile upgraded from pre-127 carries mixed v10+v20 ciphertexts, and Linux profiles may carry mixed v10+v11 for analogous reasons.
- V10: Chrome 80+ key with "v10" cipher prefix.
- Windows: os_crypt.encrypted_key decrypted by user-level DPAPI (AES-GCM ciphertexts).
- macOS: derived from Keychain via PBKDF2(1003, SHA-1) (AES-CBC ciphertexts).
- Linux: derived from "peanuts" hardcoded password (Chromium's kV10Key, AES-CBC).
- V11: Chrome Linux key with "v11" cipher prefix, derived from D-Bus Secret Service (KWallet / GNOME Keyring) via PBKDF2. Nil on Windows and macOS (v11 prefix not used there).
- V20: Chrome 127+ Windows key with "v20" cipher prefix, retrieved via reflective injection into the browser's elevation service. Nil on non-Windows platforms.
func NewMasterKeys ¶
func NewMasterKeys(r Retrievers, storage, localStatePath string) (MasterKeys, error)
NewMasterKeys fetches every configured tier in r independently and returns the assembled MasterKeys together with any per-tier errors joined into one. Nil retrievers and retrievers returning (nil, nil) (the "not applicable" signal — e.g. ABERetriever on a non-ABE fork) contribute nil keys silently; only non-nil errors propagate.
The returned error, when non-nil, is an errors.Join of per-tier failures formatted as "<tier>: <err>" (e.g. "v10: dpapi decrypt: ..."). Callers are expected to log it at whatever severity fits their context — this function itself never logs, leaving logging policy to its callers. Other pieces of the keyretriever package (e.g. ChainRetriever) may still log on their own failures; the "no-logging" guarantee is scoped to NewMasterKeys.
type PosixRetriever ¶
type PosixRetriever struct{}
PosixRetriever produces Chromium's kV10Key by applying PBKDF2 to the hardcoded password "peanuts". Matches Chromium's upstream PosixKeyProvider (components/os_crypt/async/browser/ posix_key_provider.cc): a deterministic 16-byte AES-128 key used to encrypt ciphertexts with the "v10" prefix when no keyring is available (headless servers, Docker, CI).
func (*PosixRetriever) RetrieveKey ¶
func (r *PosixRetriever) RetrieveKey(_, _ string) ([]byte, error)
type Retrievers ¶
type Retrievers struct {
V10 KeyRetriever
V11 KeyRetriever
V20 KeyRetriever
}
Retrievers is the per-tier retriever configuration passed to NewMasterKeys. Each slot runs independently — failure or absence of one tier does not affect others. Platform injectors set only the slots that apply to their platform and leave the rest nil (e.g. Linux populates V10+V11, leaves V20 nil).
func DefaultRetrievers ¶
func DefaultRetrievers() Retrievers
DefaultRetrievers returns the Linux Retrievers, one per cipher tier. Chromium on Linux emits distinct prefixes for distinct key sources:
- v10 prefix → PBKDF2("peanuts") — Chromium's kV10Key, emitted when no keyring is available (headless servers, Docker, CI).
- v11 prefix → PBKDF2(keyring secret) — Chromium's kV11Key, emitted when D-Bus Secret Service (GNOME Keyring / KWallet) is reachable.
A profile can carry both prefixes if the host moved between keyring-equipped and headless sessions, so both tiers run independently with per-tier logging rather than a first-success chain.