Repository navigation
feat: detect blob version and reject v2 offline password unlock - #23
Conversation
macOS 26.4+ re-keys the login keychain to v2 (0x200), which can't be decrypted offline from the password. WithPassword and PasswordHash now return ErrUnsupportedBlobVersion; WithKey still decrypts v2.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #23 +/- ##
==========================================
+ Coverage 75.81% 76.41% +0.59%
==========================================
Files 6 6
Lines 769 780 +11
==========================================
+ Hits 583 596 +13
+ Misses 112 111 -1
+ Partials 74 73 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR updates keychain unlocking behavior to detect the DBBlob version and to explicitly reject offline password-based unlock / hash export for macOS 26.4+ “v2” (0x200) login keychains, while keeping the WithKey path functional.
Changes:
- Parse and retain
magicandblobVersionfrom the DBBlob, and log them duringOpen. - Make
WithPassword(master-key derivation) andPasswordHash()returnErrUnsupportedBlobVersionwhenblobVersion != 0x100. - Add tests covering the version gate behavior and document the v2 recovery workflow in the README; CLI
dumpnow treatsErrUnsupportedBlobVersionas a metadata-only fallback case.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
unlock.go |
Rejects password-based master-key derivation when dbBlob.blobVersion is not v1. |
unlock_test.go |
Adds unit/integration tests for v2 rejection, v1 allowance, and metadata-only fallback via TryUnlock. |
parse.go |
Adds DBBlob version constants and parses magic + blobVersion from the DBBlob header. |
parse_test.go |
Extends DBBlob parsing test coverage for magic and blobVersion. |
keychainbreaker.go |
Logs parsed DBBlob magic/blobVersion; gates PasswordHash() to v1 only. |
keychainbreaker_test.go |
Adds regression test asserting PasswordHash() rejects v2. |
errors.go |
Introduces ErrUnsupportedBlobVersion for v2 offline password unlock/hash export cases. |
doc.go |
Documents that WithPassword is v1-only and returns ErrUnsupportedBlobVersion on v2. |
cmd/keychainbreaker/cmd/root.go |
Allows CLI dump to treat ErrUnsupportedBlobVersion like wrong-password for metadata-only export. |
README.md |
Documents v2 behavior and adds a recovery method to capture/replay the master key via WithKey. |
.golangci.yml |
Enables goconst and excludes it for _test.go files. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
macOS 26.4+ re-keys the login keychain to v2 (0x200), which can't be decrypted offline from the password alone.
magic/blobVersionfrom the DBBlobWithPasswordandPasswordHashreturnErrUnsupportedBlobVersionon v2 (was a misleading wrong-password error)WithKeystill decrypts v2; CLIdumpkeeps its metadata-only fallback