CryptoServicesPermission" "exportPrivateKey" clarification/risks

CryptoServicesPermission" "exportPrivateKey" clarification/risks

Hi everyone,

We're working on getting our software to run in FIPS mode, so we're integrating with the Bouncy Castle FIPS modules. We also happen to be running with Java's Security Manager on. As a result, when trying to write to an SSLSocket, we're getting the following:

Now, we can easily grant our code the exportPrivateKey permission. In fact, we've done so in a few other places. However, we are a framework, and have third parties who build software with our code, and we're typically a lot stricter about what permissions we open up in those cases.

The Question

Here’s what I need to know: what are the potential risks of granting this permission? What could an attacker do with it? Is this restricted to pulling the private key out of the BCFIPS key store, or is it used in other places?

Bonus Points

Ideally, we would hide the offending code behind an API and wrap it in a doPrivileged block, removing the need to grant this permission to anyone but our core code. We can't create a custom X509KeyManager implementation, due to restrictions of the JSSE in FIPS mode. We do offer custom socket factories, so we could, in theory, use a custom SSLSocket implementation, although that comes with its own set of complications. If anyone can think of another good place we could hook into to wrap this code in a doPrivileged block, that'd be pretty neat. J