I have a Node.js application that reads and writes images from a server. The images are stored in a directory on an Ubuntu operating system. Express static routes serve images from that folder when accessed by mywebsite.com/images/xyz.jpg. Currently, anyone who can log into the server can see what's inside the image folder. I want to protect my users' privacy. How can I encrypt this image folder and still be able to write into and serve files from it?


2 Answers 2


Encryption and access are two different things.

Sure, you could encrypt the contents of that folder. This means viewing those contents in the clear could only be done by someone with the encryption key and by running a decryption algorithm. Making that seamless and performant over the web would be a bit of work.

Or you could just control access to the files in that folder. Ubuntu has a robust file permission system. You don't give everyone that logs into your server root do you?


That is somewhat of an "hard" to solve problem.

As you have written:

Currently, anyone who can log into the server can see what's inside the image folder.

I assume, you don't let everyone on your boxes ;)

So there is a group of people who are allowed (for reasons) to log into your box. But the only reason where someone should be allowed to log into the box, would include, that somebody has sufficient rights to circumvent whatever operational precautions you take (= access rights). At best: nobody should ever have the need to log into your server. Operations should be done via automation. So unless your automation isn't corrupted, the user data should be relatively safe - assuming / depending on how your application is.

What is left is securing/encrypting the content itself.

There are (perhaps) ways to do this, but the question is: would it be worth the effort?

Depending on the level of sensitivity of the user-data: If you mistrust your developers in general, than that is the problem, not how to encrypt data.

My company works for the public sector and as such with personal sensitive data. That has several security implications. One is: that only 2 persons in the whole company have access to such data (which is not encrypted). And even logfile information for developers are stripped down to the absolute minimum (the real logs are manually prepared for and presented to developers).

  • Thanks for the detailed response. Currently I'm the only person working on the project and I'm hoping to grow it. I think I'll heavily protect the root account (maybe even with 2FA) and give myself a lesser account to do administrative things.
    – aaa
    Commented Oct 2, 2016 at 19:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.