Generally, if an encrypted filesystem/file is mounted it's contents become accessible to all users who have access to the folder (and root). I think the most feasible solution for your problem is:
- Use LUKS to create an encrypted filesystem
- Mount at boot time (or when you start the HTTP daemon)
- Do not put the key to the container on the box (it's a nuisance to enter the password every time, but a commonly made mistake)
- Change the directory permissions to 700
- Change the ownership to the webserver user (commonly
www-data
)
This will disallow anyone on the system (except www-data and root) to access the files.
If you really want to go for maximum security, you could script something like:
- When accessing the webpage, ask for the encrypted container password
- Mount the encrypted container
- Retrieve the necessary files
- Unmount the container
Keep in mind that mounting/unmounting is a very expensive operation, so your webpage would get really slow.
So what are you going to do? – mtak – 2014-06-19T14:32:35.413
thanks so much for this. i have questions about mounting. i should preface this by saying i'm on a red hat machine were this sensitive data is stored. the web application is stored under tomcat on another machine. so a request goes into tomcat and tomcat pings the directory on the redhat machine where the sensitive data is stored. the query is executed and the response is given. how would mounting work in this case? when you say 'do no put the key to the container on the box', what do you mean exactly? where should the key be stored?
you've added some much needed clarity. – milesmiles55 – 2014-06-19T14:45:06.710
You would have to call shell scripts from your Java app which do the actual mounting. If I say 'do not put the key on the box', I mean the password for the encrypted filesystem shouldn't be on the server (ie. it should come from the person accessing the data). – mtak – 2014-06-20T07:33:15.257