I am writing a server application on node js. Operating system is Linux.
I receive filename as a plain string, so it can be hacked. Then I concatenate the filename string and path string like this:
filepath = '/home/www/upload/' + filename;
I want to protect an upload script from writing to anywhere except upload folder [or it's subfolders : optional], using my application logic, not Linux.
My current naive solution is blocking filenames which have ..
substring. I don't care if someone has filename with two dots.
Sure, when it comes to security, I have to ask the audience for advice: can anything go wrong?