Improve extractVaultFromFile method to handle corrupted LDB file #78
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.