Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Keystore - can a user key be retrieved by root if he setuid to that user?

Since Android 4.3, Android has its own keystore where I can store keys and use them later for encryption/decryption.

It is said here and here that each key can only be retrieved by its owner and not even root can get it.

My question is: Couldn't I write a program that would switch my uid to the owner of the key, retrieve it, and then use it to decrypt data I shouldn't have access to?

Edit: Added citation to keystore doc.

like image 383
Ido Avatar asked Mar 13 '14 12:03

Ido


People also ask

How does the Android keystore work?

The Android Keystore system lets you store cryptographic keys in a container to make it more difficult to extract from the device. Once keys are in the keystore, they can be used for cryptographic operations with the key material remaining non-exportable.

Where do Android stores secure keys?

A public/private key RSA pair is generated, which is stored in the Android device's keystore and protected usually by the device PIN. An AES-based symmetric key is also generated, which is used to encrypt and decrypt the secrets.

What is key alias in keystore?

A key alias is a label for specific key within a keystore. Key aliases are created using your third-party certificate management tool.

Can I use same keystore for multiple apps?

So yes, you can use the same keystore to sign multiple apks, without a problem. You can also use the same alias (each alias is a certificate) to sign multiple apks, and it will work.


1 Answers

It is true that normally a key can only be retrieved by the user that stored it.

See e.g.: http://nelenkov.blogspot.se/2011/11/using-ics-keychain-api.html

If a device is rooted, the keys still cannot be retrieved unless the attacker also has the password.

If the attacker has rooted the device and has the password or the device is unlocked, it's game over.

like image 193
Marek Pola Avatar answered Nov 15 '22 19:11

Marek Pola