|
|
|
Ask HN: The way to encrypt and protect sensitive data in database
|
|
18 points
by flashu
2693 days ago
|
|
Hey! I would like to create a feature in an existing application where users can keep very sensitive data. I need a solution to encrypt and protect data from leakage in case of unauthorized access to the machine(s) and/or application bug which can expose the data. I was thinking about a simple solution to encrypt data using the non-shared key generated per user (to avoid decryption of the whole dataset using one key) and keeping those keys in some kind of vault. But the thing is there must be a place and time when those keys are revealed to decrypt data from database/storage. The app itself is written in PHP, so I came to another idea to use ionCube or Zend Encoder to protect the file with cypher keys, but the question is: is it safe enough? |
|
Did you already perform a threat analysis and a risk assessment?
Who are you defending against? Which are the attack or data breach scenarioes?
Put them in a impact / likelihood matrix and defend against the most serious combinations.
Do you still need to encrypt live data in the db?
If positive, an approach I used in the past was to never perform any operation in the server. Users were storing their private key in the browser (local storage) and decrypt data on the fly in JavaScript (you have to trust the browser js engine bugs.) The server could generate and store data for them using the public keys but nothing more.
If you need server side aggregations you can store in cleartext site parts of the encrypted information. Example: city names give you users per cities, regions states, countries.
Be careful about reidentification using extra information attackers could know about your system and users.