On a website I give users option to upload files (and later download it).
I uploaded a hack.php
file and was surprised that I was able to execute it by just typing in the url in the browser.
My permissions on the file a very strict. I don't want users to execute scripts that they upload. This is the relevant ls -la
output:
-rwxr----- user apache hack.php
If I tighten permissions for the uploaded file to be:
-rwx------ user apache hack.php
Than the user can't download the file, because apache can't read it.
The whole situation seem bizarre to me. I have given hack.php
no executable permissions, yet I can still execute without any troubles. What am I missing here?
In short, the main goal is to disable execution of any file of any sort that is uploaded to the server.