{"record":{"id":"c488a55c23dd05ac","repo":"moonD4rk/HackBrowserData","slug":"open-keychain-w","errorCode":null,"errorMessage":"open keychain: %w","messagePattern":"open keychain: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"masterkey/retriever_darwin.go","lineNumber":61,"sourceCode":"\t\tr.records, r.err = DecryptKeychainRecords()\n\t})\n\tif r.err != nil {\n\t\tlog.Debugf(\"gcoredump: %v\", r.err)\n\t\treturn nil, nil //nolint:nilerr // intentional silent fallthrough\n\t}\n\n\tkey, err := findStorageKey(r.records, hints.KeychainLabel)\n\tif err != nil {\n\t\tlog.Debugf(\"gcoredump: %v\", err)\n\t\treturn nil, nil //nolint:nilerr // intentional silent fallthrough\n\t}\n\treturn key, nil\n}\n\nfunc loadKeychainRecords(password string) ([]keychainbreaker.GenericPassword, error) {\n\tkc, err := keychainbreaker.Open()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"open keychain: %w\", err)\n\t}\n\tif err := kc.Unlock(keychainbreaker.WithPassword(password)); err != nil {\n\t\treturn nil, fmt.Errorf(\"unlock keychain: %w\", err)\n\t}\n\treturn kc.GenericPasswords()\n}\n\nfunc findStorageKey(records []keychainbreaker.GenericPassword, storage string) ([]byte, error) {\n\tfor _, rec := range records {\n\t\tif rec.Account == storage {\n\t\t\treturn darwinParams.deriveKey(rec.Password), nil\n\t\t}\n\t}\n\treturn nil, fmt.Errorf(\"%q: %w\", storage, errStorageNotFound)\n}\n\n// KeychainPasswordRetriever unlocks login.keychain-db with the macOS login password (no root).\n// Records are cached once and reused across browsers.","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/moonD4rk/HackBrowserData/blob/0503d04d7a8d0379d060268a74f1b149e5a0aad5/masterkey/retriever_darwin.go#L43-L79","documentation":"loadKeychainRecords fails to open the macOS login keychain via keychainbreaker.Open() and wraps the cause with \"open keychain: %w\". This is the first step of the keychain-based retriever; nothing can proceed without an open keychain handle.","triggerScenarios":"Calling KeychainPasswordRetriever.RetrieveKey with a non-empty password when keychainbreaker.Open() returns an error (keychain database missing, corrupted, or unreadable).","commonSituations":"login.keychain-db moved or deleted, running as a different user whose keychain path doesn't exist, filesystem permission problems, or corrupted keychain after a failed macOS upgrade.","solutions":["Verify ~/Library/Keychains/login.keychain-db exists and is readable by the current user","Open Keychain Access and repair/unlock the keychain to rule out corruption","Check you are running as the user who owns the keychain, not root or another account","Follow the wrapped cause (errors.Unwrap) for the specific OS-level reason"],"exampleFix":"// before\nkeychain := os.Getenv(\"HOME\") + \"/Library/Keychains/login.keychain-db\"\n// after\nkeychain := os.Getenv(\"HOME\") + \"/Library/Keychains/login.keychain-db\"\nif fi, err := os.Stat(keychain); err != nil || fi.IsDir() {\n\treturn nil, fmt.Errorf(\"keychain db not available at %s\", keychain)\n}","handlingStrategy":"validation","validationCode":"kcPath := filepath.Join(os.Getenv(\"HOME\"), \"Library\", \"Keychains\", \"login.keychain-db\")\nif _, err := os.Stat(kcPath); err != nil {\n\treturn fmt.Errorf(\"keychain db missing: %w\", err)\n}","typeGuard":"func keychainExists() bool {\n\t_, err := os.Stat(filepath.Join(os.Getenv(\"HOME\"), \"Library/Keychains/login.keychain-db\"))\n\treturn err == nil\n}","tryCatchPattern":"key, err := retriever.RetrieveKey(hints)\nif err != nil && strings.HasPrefix(err.Error(), \"open keychain:\") {\n\treturn nil, fmt.Errorf(\"cannot access login keychain: %w\", err)\n}","preventionTips":["Run under the macOS user who owns the keychain, not root","Confirm login.keychain-db exists before invoking the retriever","Repair corrupted keychains via Keychain Access first"],"tags":["macos","keychain","file-open-failed","darwin"],"backgroundTag":"file-open-failed","analyzedSha":"0503d04d7a8d0379d060268a74f1b149e5a0aad5","analyzedAt":"2026-09-06T13:38:28.707Z","contentChangedAt":"2026-09-06T13:38:28.707Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}