Commit a3872c4
authored
fix: Make
Unintentional or not, `endowment:keyring` has 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 the `value`, 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#L77
The Bitcoin Snap used in production specifies `endowment:keyring: {}` in
its manifest.
This PR makes the permission validation explicit in making
`KeyringOrigin` optional, including adding a fallback in
`getKeyringCaveatOrigins`.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Adjusts permission validation and defaults for the security-adjacent
`endowment:keyring` caveats; incorrect optionality or fallback behavior
could inadvertently widen allowed origins if downstream assumes the
caveat is always present.
>
> **Overview**
> Makes `endowment:keyring` permission validation explicitly treat the
`keyringOrigin` caveat as *optional* (matching other keyring caveats),
rather than requiring it to be present.
>
> Updates `getKeyringCaveatOrigins` to **gracefully default** to `{
allowedOrigins: [] }` when the caveat (or caveats list) is missing, and
aligns tests/coverage thresholds with the new behavior.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
5ca964e. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->KeyringOrigin caveat explicitly optional (#3955)1 parent c339e31 commit a3872c4
3 files changed
Lines changed: 9 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
Lines changed: 5 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | 36 | | |
44 | 37 | | |
45 | 38 | | |
| |||
147 | 140 | | |
148 | 141 | | |
149 | 142 | | |
150 | | - | |
151 | | - | |
| 143 | + | |
| 144 | + | |
152 | 145 | | |
153 | 146 | | |
154 | | - | |
| 147 | + | |
155 | 148 | | |
156 | | - | |
| 149 | + | |
157 | 150 | | |
158 | 151 | | |
159 | 152 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | | - | |
149 | | - | |
150 | 148 | | |
151 | 149 | | |
152 | 150 | | |
| |||
155 | 153 | | |
156 | 154 | | |
157 | 155 | | |
158 | | - | |
159 | | - | |
| 156 | + | |
160 | 157 | | |
161 | 158 | | |
162 | 159 | | |
| |||
0 commit comments