[Galaxy S Plus I9001 Android Development] Deviant Ollam:
awesome handling of encrypted /data partition, but do backups compromise security?

I've done some searching on this (including searching this whole thread for the term "encrypted" with no results, which is odd because the other night i could have sworn that i saw someone post on XDA about TWRP and encrypted backups, but i guess it must have been elsewhere) and figure it's time to turn to the experts about something that is concerning me.

TWRP is my new favorite recovery tool. someone showed it to me at the DerbyCon conference last year and i was really impressed, then when i went home and actually tried using it i was beyond impressed.

now, after i have enabled encryption support on one of my phones... i am supremely impressed. the fact that TWRP can effortlessly identify an encrypted partition, accept user input for the password, then immediately refresh its whole drive and partition list... that's just wonderful. so simple a bit of functionality that many devs might have overlooked.

here is my concern, however: given that TWRP uses the decryption key in order to treat the /data partition as normal clear information (which is great that it operates transparently, allowing file manager access, etc) does this mean that the resultant backup files are lacking any such protection?

scenario:

1. enable encryption on an android device. all that Android supports right now is /data which is unfortunate... but we'll take what we can get

2. boot to recovery for a backup. TWRP awesomely identifies said drive and prompts for password

3. within TWRP the /data drive just appears as another typical storage partition

4. if you run a full backup then /system gets backed up (in the clear) and of course /data does, too (with TWRP seeing it virtually no differently than /system ... the crypto doesn't matter)

5. MY MAIN CONCERN: the resultant .win files -- specifically data.ext4.win -- are really just tarballs. and when i poked around a bit, it appeared that this is a TAR package of the unencrypted data. thus, if a user leaves their TWRP backup on the microSD card (which i think most of us do... in order to allow emergency restores if our phone suddenly goes nuts or if we do something stupid) then any attacker who physically compromises or steals the phone gets full access to our /data directory just as easily.

6. am i wrong about any of these assumptions?

when i was googling about TWRP and encrypted drives (trying to find out if it would support them) i think i can recall seeing a thread somewhere wherein a user was talking about TWRP itself being able to perform an "encrypted backup" but i don't see that option on my version.

i am running TWRP 2.3.3.1 on my Galaxy S III (T-Mobile, T999)

did this functionality (a checkbox option for "encrypt backup" much like the current "compress backup") once exist but was then removed? the person asking about this in the thread that i recall was saying how their backups were totally failing upon restore... so maybe that's why this feature isn't present now? ;)

i also, just as an experiment, tried NOT entering the crypto password when TWRP started up. i wondered if maybe keeping /data encrypted would cause the backup process just to do some kind of DD command and image the whole drive, encryption and all. (clearly, i'm not a unix guy)

ah well, it does not. it just fails when the backup process attempts to start.

So, what of it? any suggestions for those of us who want a secure way of backing things up? other than...

1. use TWRP to make a full backup

2. move that backup off the device, in a safe and encrypted place (TrueCrypt container or on a computer that has WDE enabled)

3. use TWRP to make another backup, omitting /data in the process

4. keep this secondary, non-complete, backup around in order to restore in certain instances of your phone becoming borked.

Alternate version of the above process?? ...

1. use TWRP to make a full backup

2. move the data.ext4.win and data.ext4.win.md5 files off the device, to a safe and encrypted place

3. will TWRP still understand this backup in such a form? there is no separate file with metadata saying "this was originally performed inclusive of the data dir" right?

4. to restore some of the phone in a tight spot... just restore this backup (which lacks /data tarball now)

5. to restore the phone completely if you're really borked... copy the data.ext4.win and data.ext4.win.md5 back to the microSD card and then run a restore process

... would that work?