views:

87

answers:

1

This question is in the specific context of the Java class java.security.KeyStore and its load(InputStream stream, char[] password) method which can accept null values for password to bypass integrity checking.

What are the risks involved with loading and querying a keystore without checking its integrity? The keystore will be queried for the user's private key which will be used to sign a document for non-repudiation. The certificate queried will be further validated against a copy stored in a database at the time the user registered himself and the (supposedly exact same) cert.

A: 

Well the main risk is that anyone who can read the file can also modify it. So someone could replace the file you read with a different keystore that has the same names for the keys but contains a different private key, so you end up signing documents with the wrong private key and none of them will pass verification.

Also, anyone with access to the file gains access to the private key and can sign documents as if they came from your app.

Chochos
"So someone could replace the file you read with a different keystore that has the same names for the keys but contains a different private key"But can the attacker also "spoof" the certs? My app will verify the cert retrieved with the cert uploaded by the user during registration. If the attacker cannot spoof the certs then the private key should be the same, correct?
Chry Cheng
Wait... are you going to be managing user's private keys? So they're not going to be really private? Or are you going to be doing this keystore loading thing in a client app? If the latter is the case then you should let the user set a password for the KeyStore upon creation and then ask for it upon retrieval.
Chochos
No, I won't be managing private keys. Yes, I'll be loading the key store in a client app.
Chry Cheng