Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Protecting data on ubuntu server, access via PHP

Posted on 2012-04-04
5
Medium Priority
?
395 Views
Last Modified: 2012-04-16
I have an ubuntu server which is running Apache and a special PHP webpage I wrote.

The PHP page allows a user to authenticate and access a special secret "document" that belongs only to them. Each user has their own secret document, and I have a back-end system for configuring the access control lists, user accounts etc. The server uses a properly signed SSL certificate, and the PHP itself is well written.

On the back-end, the documents themselves are stored in a folder on my server which is not web accessible, e.g. in /usr/share/secretstuff/[accountid]/somefile.txt. PHP currently gains access to the file via file_get_contents() and displays it to the user.

My concern is that the files are just sitting on the hard drive in plain text. I've set the chmod and chown accordingly so only www-data has access, but I'm acutely aware that ANY script running on my apache server can access these files if they know where to look.

I'm also concerned that if the server were compromised (either physically or over the network), the files are totally open.

What are some ways I can protect these files and make it so the files are accessible ONLY through authenticated access from my PHP page?

Ideally, how can I protect the server so that a knowledegable person who knows the system inside and out who has somehow gained root access to the machine, or gained physical access to the machine (e.g. removed the hard drive), still cannot access the files?
0
Comment
Question by:Frosty555
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 2000 total points
ID: 37808688
I don't believe that can be done.  If I get root access, I can change anything on your system.  Your only other alternative that I know of is to encrypt the files and make sure the proper user has the only copy of the key.
0
 
LVL 31

Author Comment

by:Frosty555
ID: 37809335
I should include also, that it is important that any backups that get made of the server are just as well protected as the server itself....

I was thinking encryption would be the ideal way to do this. Each user logs in using a password that only they know so I imagine I could use that password, hash it / digest it somehow, and use that as the encryption key?

The problem is that some users have access to more than one document, and an administrator needs access to all of them, so the encryption becomes a bit messy. I don't know how to do encryption with multiple keys. I know that public/private encryption is designed to help with this situation but I don't understand it well enough to get a clear picture of what a proper implementation of it would look like (nevermind the actual coding of that implementation in PHP)

This feels like the sort of problem that has already been solved by the technology used in SSL.
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 37809398
SSL is used to encrypt transmissions over the network, not files on a server.  You might want that also.  Security always makes things more difficult, it is supposed to!  You need strong encryption and a plan.  Do a search for "Linux file encryption" http://www.google.com/search?q=Linux+file+encryption , there are a lot of resources available.
0
 
LVL 31

Author Comment

by:Frosty555
ID: 37814698
Okay, so what would be the right way to do this then? If I encrypt the files with a passphrase, that passphrase has to exist somewhere on the server, which defeats the purpose of the original encryption? Is there a better way to protect the encryption key?
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 37814736
No, the passphrase will be encrypted into the file in such a way that the encryption software will know how to handle it.  On my web sites with logins, the passwords are not found anywhere in plain text and you are welcome to spend the years it will take to break the MD5 hash to get in.  There is no reason to think that the people who wrote the encryption software did not think of this.

There is no Perfect answer.  Encryption and security is always a matter of how difficult do you want to make it.  Generally the answer is, more difficult than the people want to deal with that would otherwise steal the info.  The average computer user won't try very hard.  If some government with super-computers wants to break in, they may have the resources to do it.

Don't over think this.  People smarter than you and me have already solved this problem many times.  Make a list of your needs and find some software that will provide them.
0

Featured Post

Ready for your healthcare security check-up?

In the past few years, healthcare organizations have become a prime target for advanced attacks. Does your organization have what it needs to defend itself? Schedule your healthcare security check-up today and download our free Healthcare Security Resource Kit today!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you thought ransomware was bad, think again! Doxware has the potential to be even more damaging.
Worried about if Apple can protect your documents, photos, and everything else that gets stored in iCloud? Read on to find out what Apple really uses to make things secure.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question