Hi guys,
I have a site in development which allows the user to upload a document to the website to be stored on the server. I want to make sure these files are secure and not available to be viewed by persons who are not served a link to do so - e.g. I want to prevent people fishing around to find them for example. How can I best achieve this? Is keeping the files on the server a security risk that is not fixable? I need the area on the server to have access privileges to allow people to upload files of course so it cant be a locked down folder which no access...
Any thoughts?
Cheers
dubbs.
[ed. note: dubbs last edited this post 10 years, 11 months ago.]
Bob - does your FileUpload addon ensure security when users upload files? Or is it just best to avoid file uploading for fear of hackers uploading malicious scripts/files to attack the server etc?
Does anyone have any thoughts on this?
-
☆ A M B ☆
- 24,524 Posts
There are ways to determine the type of the file besides the extension, such as checking its mime type. This can be done in Javascript upon file selection, or in PHP after the file has been uploaded. However, allowing users to upload files will always be a security problem, as there are ways to get around this with specially-crated files.
You can prevent further access to those files by using a server directive to deny all access from the web, then serve them with a streaming function, thus the access would be to the streaming script (a snippet in a resource, or a static resource) and not to the file itself.
Some thoughts and ideas.
1) Dropbox integration require some work but takes care of the issue.
2) .htaccess rules can restrict direct access to files.
3) Above root means no way of retrieving the file via URL
https://forums.modx.com/thread/86939/media-resource-basepath-web-root-setting#dis-post-532842
4) check referer snippet
http://en.itchiweb.com/labs/modx-labs/check-referer-en/
Here is what I have been using:
http://modx.com/extras/package/dropbox
This will make Dropbox a mediasource. There are not much code to retrive the files on the front-end.
I can provide some simple code if you go this route.