Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dangerous file types to avoid in file-sharing website

Tags:

php

upload

I am making a small file-sharing website where users can upload content. Recently somebody uploaded a PHP script that was presumably intended to harm the site. It got me thinking: what file types should I block users from uploading? I have already blocked .exe files. What other file types could cause harm to either my website or its users?

This script can be viewed here.

like image 511
JSW189 Avatar asked Dec 07 '22 19:12

JSW189


1 Answers

Don't store the files where they're directly accessible - only provide access via a script YOU control. Don't store the files using their user-supplied filename - use a filename YOU generate (best option is to store file details in a database, including the original filename, and store the actual file using that db record's primary key field.

With those two, people can upload antyhing they want, and there'll be zero chance of the file being executed/interpreted on your server, because it's never in a position where it CAN be executed/interpreted.

like image 93
Marc B Avatar answered Dec 10 '22 12:12

Marc B