Handle cases where Manifest.db's reported size doesn't match#26
Open
malicious wants to merge 4 commits intoavibrazil:masterfrom
Open
Handle cases where Manifest.db's reported size doesn't match#26malicious wants to merge 4 commits intoavibrazil:masterfrom
malicious wants to merge 4 commits intoavibrazil:masterfrom
Conversation
- AES padding is up to 16 bytes, so this is the "normal" case - if the original file more than 16 bytes greater, leave it alone (and remove some extra padding that gets added during encryption) - if the original file is _smaller_ than the recorded size, avoid `truncate`, which extends it automatically
Author
|
Anecdotally, this happened for only 30 of 3800 files while reviewing one iOS backup. |
Author
|
https://gist.github.com/malicious/cd2a17f1ace34d27a8c710892721b28d |
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.
I noticed the discrepancies while trying to create a re-encrypted backup, based on files decrypted with MVT. I haven't seen any pattern for when Manifest.db sizes are wrong, or even whether those sizes are reliable; the end-of-file AES padding seems to be the most reliable source of information.
At any rate, these changes at least guarantee consistency with the original encrypted backup. Overall logic:
truncate, which will extend the size automatically (and turn the AES padding into part of the file)This was tested by using
pip install -e .on a local checkout, withmvt-ios decryptand then a custom script to re-encrypt backups. Systems used were macOS 10.15-12 Python 3.8-3.10, and backups were for iOS 14.7-15.7.