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

Encrypt key backups during PIN creation / changes #186

gurnec opened this Issue Dec 10, 2014 · 5 comments


None yet
3 participants

gurnec commented Dec 10, 2014

The "Update mobile environment score" issue at the repo got me thinking about this one.... The proposed environment score reads:

mobiles are usually easier to steal or lose...using a strong passphrase...can make it harder to steal your bitcoin

The current passphrase/PIN feature doesn't encrypt the key-backup-protobuf files in the private data store. Although this isn't a problem (at the moment AFAIK) from a malware point of view, from a stolen or lost mobile point of view it seems more dangerous.

I really don't know just how dangerous this is (it would relate to the market share of rootable mobiles I suppose), but IMHO it should be addressed before it becomes a problem....


This comment has been minimized.


schildbach commented Dec 10, 2014

Yes, I think it's time to rethink the internal backups. There are two kinds of them:

  • The key-backup-protobuf is used for automatic restoring in case your wallet-protobuf is damaged (e.g. sudden power loss). I think we should keep that and refresh that backup after each wallet encrypt/decrypt operation.
  • The key-backup-protobuf.<day> files are made so in case you need to restore a wallet from the filesystem there are multiple copies. Just like filesystem root sectors are duplicated several times to increase the likelyhood you can recover them. Unfortunately, this can also help thieves. I've never heard someone successfully undelete files from Android devices. I think we should just stop writing these backup files and remove those that were already written.

What do you think?

Note: none of these internal backups survive an app uninstall, and of course they also don't help if you loose your phone. A manual backup is crucial!


This comment has been minimized.

gurnec commented Dec 11, 2014

I think that keeping a single internal backup, in addition to the existing (excellent) do-a-backup nag, is a good compromise.

Regarding deleting the existing .<day> backups, I'm not aware of any perfectly safe way to do this. I think the situation is something like this:

android < 4.3 android >= 4.3
delete unsafe pretty safe?
overwrite ?????? pretty safe?

Android 4.3 implemented TRIM, which should make it pretty safe no matter how you delete old files. Prior to 4.3, simply deleting a file is unsafe; the data partition is ext4 from which deleted files can be recovered (given root). The ??? box is also theoretically unsafe, but I have no idea to what degree.

In short: overwriting seems better, but I really don't know what I'm talking about (it's all far outside my trade), so you should take all of this with a grain of salt (or twenty).

Regardless of how it's implemented, I think it'd be a very nice improvement.


This comment has been minimized.


schildbach commented Jan 1, 2015

Since version 4.14, there are no key-backup-protobuf.<day> files any more and the key-backup-protobuf file is refreshed with each set or change PIN operation.

@schildbach schildbach closed this Jan 1, 2015


This comment has been minimized.

gurnec commented Jan 1, 2015

Great improvements, thanks!


This comment has been minimized.

opies32765 commented May 17, 2017


I have an issue i need help with on btcrecover...can i send you a message to see if you can help me figure it out ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment