fix(darwin): accept wrapped go-keyring master keys#69
Open
lamost423 wants to merge 1 commit intolarksuite:mainfrom
Open
fix(darwin): accept wrapped go-keyring master keys#69lamost423 wants to merge 1 commit intolarksuite:mainfrom
lamost423 wants to merge 1 commit intolarksuite:mainfrom
Conversation
a46d3a9 to
cf6e1cd
Compare
cf6e1cd to
d5e8cec
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This patch makes the macOS keychain backend more tolerant when reading
master.key.On Darwin,
lark-cliexpectsmaster.keyto resolve to a base64-encoded 32-byte AES key. In practice, some environments can surface the stored value in a wrapped go-keyring format such as:go-keyring-base64:<...>go-keyring-encoded:<...>When that happens, the current code only attempts a single direct base64 decode, fails to recover the 32-byte key, and silently falls back to generating a new key. That breaks decryption for previously stored secrets and tokens, which then shows up as config/auth failures like:
keychain entry not found: lark-cli/appsecret:<appId>auth statusreportingno_tokeneven though the encrypted token file existsRoot Cause
getMasterKey()currently assumes the value returned from keychain access is always a plain base64 string representing the raw 32-byte master key.That assumption is too strict. If the value is still wrapped in a go-keyring prefix, it needs one extra normalization step before the final base64 decode.
What Changed
decodeMasterKeyValue()ininternal/keychain/keychain_darwin.gogo-keyring-base64:wrapped valuesgo-keyring-encoded:wrapped valuesgetMasterKey()to use the new normalization helperImpact
This is a low-risk compatibility fix for macOS storage reads.
master.keyvalues can be decoded successfully.Validation
Validated logically against the current keychain/file storage flow and added a unit test for the decoding helper.
Note: Go tests were not run locally because the original environment had no Go toolchain.