I am using PHP 5.6 on Apache 2.4
I have a form that will collect sensitive information about the user that need to be encrypted. My current solution grabs the sensitive information from the POST and immediately one way asymmetrically encrypt it with a public key before storing it the database. I will be using SSL on the site.
My plan is to retrieve the encrypted version and decrypt locally as the information is needed, and when the data isn't needed further, I am going to delete it entirely.
I am worried that if the server is compromised and a hacker is capable of knowing that the above is going on, there is an opportunity for the hacker to write a script to collect the POST data before I can process and empty it.
Are there any better ways to make sure at no point can someone, via an injected script, access the POST data? Or am I just being extra paranoid?
I am encrypting the sensitive information with RSA 16,384 bit public / private keys. The average size of the information block is closer to 8000 bits, but the 16,384 bit allows for extreme use cases.
Only the public key is on the server, I process the information into a JSON array and then use PHP's
openssl_public_encrypt() function. I then store the encrypted block in MySQL.
This is my worst case scenario
Prior to this project, I would have agreed with the sentiment that if a hacker is on my system, then I have bigger problems. However, a hacker sniffing this information prior to the encryption is exactly the biggest problem I have. It's not CC#s, I am handling that via Stripe and 100% PCI Compliant.
However, I would have equal, if not greater, liability if this information was compromised.
That is why I am going to such extremes as handling decryption locally. I have read the PCI compliance basics, such that sensitive information needs to be encrypted in transit and in storage, but there seems to be a gap during processing even there. If I am wrong there, please point out documentation, so I can better educate myself.