Improve extractVaultFromFile method to handle corrupted LDB file#78
Open
alvarodh5 wants to merge 2 commits intoMetaMask:masterfrom
Open
Improve extractVaultFromFile method to handle corrupted LDB file#78alvarodh5 wants to merge 2 commits intoMetaMask:masterfrom
alvarodh5 wants to merge 2 commits intoMetaMask:masterfrom
Conversation
Contributor
|
Hi @alvarodh5! Thanks for the bug report and fix. Would you mind including a test to ensure that this problem doesn't happen again? We have a file |
Author
|
Hello @mcmire, Thanks for your response! I've made a commit with few modifications:
Let me know if you need any further changes :) |
Phum7895
approved these changes
Sep 23, 2025
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.


Hello everyone,
A few days ago, my MetaMask instance got corrupted, and I lost access to all my wallets. After using file recovery tools, I was able to retrieve a
ldbfile of 11MB from my system.According to the official MetaMask documentation:
However, my recovered file was named
158063.ldb, which, based on both the documentation and the current implementation ofvault-decryptor, was considered irrecoverable.After investigating the MetaMask extension code, particularly this reference:
MetaMask Default Fixture (lines 158-160), I found the following pattern:
When inspecting the backup in a hex editor, I noticed that my
KeyringControllerwas corrupted, however, the rest of the necessary vault data was still intact. This allowed me to manually recover my wallet looking for the following pattern::\"data_b64\",\"iv\":\"iv_b64\",\"keyMetadata\":{\"algorithm\":\"PBKDF2\",\"params\":{\"iterations\":10000}},\"salt\":\"salt_b64\"}"}You can see an example in the following image:
This PR introduces an additional attempt (number 6) in the
extractVaultFromFilemethod to identify only the vault pattern, making the recovery process possible even if theKeyringControllerstructure is malformed.Please note that if the PR is accepted, the
bundle.jsfile should be updated accordingly.