-
-
Notifications
You must be signed in to change notification settings - Fork 224
fix: remove metadata for unsupported keyrings #5725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
if (this.#keyringsMetadata.length > this.#keyrings.length) { | ||
// There was already a metadata entry for the keyring, so | ||
// we need to remove it | ||
this.#keyringsMetadata.splice(this.#keyrings.length, 1); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The downside of this solution is that if we consider the following scenario:
- There is some metadata for a keyring
- The keyring fails to restore, for any reason, and metadata will be removed
- The keyring is then supported again
The keyring will then have a different ID, compared to what it had initially. Unfortunately, to avoid this, we'd have to store the metadata along with its keyring in the vault directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have no mechanism today for moving a keyring from "unsupported" to "supported", to my knowledge. If and when we implement this, we can perhaps treat it like a new keyring and generate new metadata on-the-spot.
That should work OK.
Any other state relying on the metadata would get cleared when it was first moved to unsupported, that is one downside that would not avoid. But I think that's acceptable. Making a keyring unsupported must inevitably impact state that depends on that keyring.
If we remove the metadata, there's no way to get it back yeah? What's the purpose of adding the keyring to unsupportedKeyrings? Should we consider adding unsupportedKeyringsMetadata? |
@v-goyal Correct, if we remove metadata we won't get it back (that's the downside I was describing here). Unfortunately, we can't apply the same strategy we use for the unsupported keyrings because metadata is stored in the state directly instead of the vault, so removing them from the state would mean immediately persisting the new array of metadata. With keyrings, we don't need to worry about that because even if we skip one of them in the state (because unsupported), it'll still be kept in the vault unchanged and retried at the next unlock. A solution to do that with metadata would probably be to save them in the vault along with the keyring itself - that would save us a lot of headaches, but it's a more complex solution that would also require a strategy to migrate the existing metadata for users that already have it in the state |
@metamaskbot publish-preview |
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions.
|
Explanation
When the user vault is decrypted and there is an attempt to restore an unsupported/deprecated/faulty keyring there's no mechanism to remove related metadata, which leads to a situation where no further action can be made on the controller, because checks for keyrings and metadata length will fail.
We can remove the related metadata object when the keyring restore fails.
References
Changelog
Checklist