fix: Make KeyringOrigin caveat explicitly optional#3955
Merged
FrederikBolding merged 3 commits intomainfrom Apr 14, 2026
Merged
fix: Make KeyringOrigin caveat explicitly optional#3955FrederikBolding merged 3 commits intomainfrom
KeyringOrigin caveat explicitly optional#3955FrederikBolding merged 3 commits intomainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3955 +/- ##
==========================================
+ Coverage 98.56% 99.14% +0.57%
==========================================
Files 428 346 -82
Lines 12348 9314 -3034
Branches 1939 1539 -400
==========================================
- Hits 12171 9234 -2937
+ Misses 177 80 -97 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Mrtenz
approved these changes
Apr 14, 2026
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.
Unintentional or not,
endowment:keyringhas since its implementation allowed no caveats to be passed until 79e8b90. This was caused by the caveat mapper constructing the caveat with an empty object as thevalue, which is valid according to our validation: https://github.com/MetaMask/snaps-skunkworks/blob/fb/keyring-origins-optional/packages/snaps-utils/src/json-rpc.ts#L77The Bitcoin Snap used in production specifies
endowment:keyring: {}in its manifest.This PR makes the permission validation explicit in making
KeyringOriginoptional, including adding a fallback ingetKeyringCaveatOrigins.Note
Medium Risk
Adjusts permission validation and defaults for the security-adjacent
endowment:keyringcaveats; incorrect optionality or fallback behavior could inadvertently widen allowed origins if downstream assumes the caveat is always present.Overview
Makes
endowment:keyringpermission validation explicitly treat thekeyringOrigincaveat as optional (matching other keyring caveats), rather than requiring it to be present.Updates
getKeyringCaveatOriginsto gracefully default to{ allowedOrigins: [] }when the caveat (or caveats list) is missing, and aligns tests/coverage thresholds with the new behavior.Reviewed by Cursor Bugbot for commit 5ca964e. Bugbot is set up for automated code reviews on this repo. Configure here.