How to encrypt sensitive files in a business application? Is it needed? I'm currently working on a business Java application, and we store sensitive files related to our users. What is the appropriate approach to store them securely?

Is it viable to encrypt/decrypt all the files in the business logic, and then store them in the filesystem? Then what the key could be? If I derive a key from the file uploader's password, other, authorized people won't be able to decrypt the file.

Or it would be better if we would concentrate on the infrastructure's security, because it is not frequent to encrypt files for a business application?
Or it would be better if we would concentrate on the infrastructure's security, because it is not frequent to encrypt files for a business application?


If an attacker gains access to your server he can just steal, modify or delete all kind of data. This is not a desired consequence to suffer if someone breaks your security. Specially if the sensitive data is in plaintext.

For example, in the case you store files, the attacker can modify them to alter their functionality to install malware in the user's computer.


  If I derive a key from the file uploader's password, other, authorized people won't be able to decrypt the file.


In your scheme, every user will have two keys, one for encryption and the other for providing integrity and authentication via MAC. This is done applying a key derivation function to a Master Key. In the case your server get compromised and the user's data gets modified, the legitimate user will notice the modification since tags are not equal.