0

I'm building a intranet solution for a company using PHP.

One of their desired functionalities is storing payrolls, absence and personal information. They need this to be accessible for the employee himself/herself and to the management, but this is a tech company - with tech savvy people - so they need it to be impossible to recover from the database without the private key, even with root access to the server

What i'm thinking is using RSA to generate a key pair and store the public key for each person in the database, and then when information is added by a employee they share the data with the desired people using their public key (duplicating the db rows for each person with access). The private key could then be encrypted with AES and stored in the db.

  1. Is this a good solution?
  2. Is it possible to pair this with a hashing function so they can use a password and not the entire key to decrypt?
  3. Any PHP Classes (with examples?) that i can work out from?

Any suggestions and tips are most welcome.

  • 4
    "Impossible to recover from the database even with root access to the server" and "accessible for ...some people..." seem to be mutually exclusive requirements. Which will it be? – a CVn Jun 1 '16 at 13:47
  • 2
    So where do you plan to store the AES key to be used for decrypting the private RSA key? Unless you are willing to require manual attention from a privileged individual, something somewhere has to be stored in plain text. If we assume an adversary who has root access, unless you use at the least a HSM (and it's possible that even a HSM wouldn't really help), that something will be recoverable. – a CVn Jun 1 '16 at 13:54
  • 2
    You have to manage passwords as well, if they forget their password to the PK how would you handle that situation? – Purefan Jun 1 '16 at 14:16
  • 1
    Good point. Any ideas are welcome. – Jørgen Jun 1 '16 at 14:17
  • 2
    I think your requirements are unrealistic. Someone with root access can modify your software and get memory dumps of your app. There's no way to protect against this. Once you remove this requirement, the threat model for your app is relatively standard. – Neil Smithline Jun 1 '16 at 15:00
-1

Why not use a CA and limit authorization by certificate? Then you can harden your server and let the CA handle whether or not a given certificate is valid. You can then use the "management" certificate to sign the "minion" certificates. Then you have strong two-factor authentication if you add a username and password as well.

To limit access to the server, you should require a key to gain access, and store the key on a USB stick (or two) and store them in a dual control location. You could also use this method to store the super-secret private key if you go with your scheme.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.