store/keychain: fix macOS GetAll secrets#47
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes the macOS GetAll implementation by removing the default ReturnData flag to allow bulk queries, introducing a helper for per-item data retrieval, and refactoring CRUD methods to add validation and separate data fetching.
- Remove
SetReturnData(true)fromnewKeychainItemand addgetItemWithDatafor fetching the secret’s data. - Refactor
Get,Delete,GetAll, andSaveto validate IDs, use string-based constructors, and fetch data correctly. - Update
GetAllto parse account IDs and callgetItemWithDataper item, avoiding per-item prompts during bulk lookup.
Comments suppressed due to low confidence (1)
store/keychain/keychain_darwin.go:109
- [nitpick] The variable name
iis ambiguous in this context; consider renaming it to something likeitemResultordataResultfor clarity.
i, err := getItemWithData(id.String(), k)
bbb70b9 to
55fcde2
Compare
joe0BAB
reviewed
Jun 26, 2025
joe0BAB
approved these changes
Jun 26, 2025
Collaborator
joe0BAB
left a comment
There was a problem hiding this comment.
LGTM! (just small non-blocking nit)
This patch fixes the macOS GetAll function. It explicitly removes the `ReturnData` attribute from the `newKeychainItem` function which was preventing the use of `MatchLimitAll` attribute. According to the Apple documentation https://developer.apple.com/documentation/security/secitemcopymatching(_:_:)#Discussion you cannot use the `ReturnData` with `MatchLimiteAll` attribute - due to how the Apple keychain works with item data retrieval. It prompts the user per item retrieved. In cases where many items can exist under the application service group and service name it will prompt the user for each one. The macOS keychain items are stored with `AccessibleAfterFirstUnlock` and an item can be marked as "don't ask again". In this case the user would only be required to unlock the item once. Thinking of the future consequences for this - in the case of the secrets engine querying for many items from the keychain, macOS users might become overwhelmed with many prompts. Reading the documentation it seems like some of our only options would be to lower the security requirements of items. Perhaps by omitting the user presence requirement with an `AccessibleAfterFirstUnlock`. https://developer.apple.com/documentation/security/secaccesscontrolcreatewithflags(_:_:_:_:) Once the binary implementing this library is signed, it would also reduce the number of prompts a user is shown. Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
55fcde2 to
5f74bfe
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.
Related #53
This patch fixes the macOS GetAll function. It explicitly removes the
ReturnDataattribute from thenewKeychainItemfunction which was preventing the use ofMatchLimitAllattribute.According to the Apple documentation
https://developer.apple.com/documentation/security/secitemcopymatching(_:_:)#Discussion you cannot use the
ReturnDatawithMatchLimiteAllattribute - due to how the Apple keychain works with item data retrieval. It prompts the user per item retrieved. In cases where many items can exist under the application service group and service name it will prompt the user for each one.The macOS keychain items are stored with
AccessibleAfterFirstUnlockand an item can be marked as "don't ask again". In this case the user would only be required to unlock the item once.Thinking of the future consequences for this - in the case of the secrets engine querying for many items from the keychain, macOS users might become overwhelmed with many prompts.
Reading the documentation it seems like some of our only options would be to lower the security requirements of items. Perhaps by omitting the user presence requirement with an
AccessibleAfterFirstUnlock. https://developer.apple.com/documentation/security/secaccesscontrolcreatewithflags(_:_:_:_:)Once the binary implementing this library is signed, it would also reduce the number of prompts a user is shown.