Is setting the uploads folder 777 permission secure?

后端 未结 3 1214
情书的邮戳
情书的邮戳 2020-12-19 19:47

I have seen a lot of upload forms hacked, and some had some really good security checks of the file being uploaded (at least I think so), but still somebody managed to uploa

相关标签:
3条回答
  • 2020-12-19 20:06

    Folder permissions is just to make sure your httpd/Apache user can write to that folder. Actually you don't need to chmod 777 for your storage folder. Just make sure to either set owner to root and group to the Apache/httpd user you are running or just simply set the folder owner to your Apache user.

    chmod 774 /upload/folder: writable for owner and group and the others just read.

    PHP: if somehow that folder refers to user document root folder you can disable the PHP engine for that particular virtualhost.

    If that folder is part of your system/application document root folder editing the .htaccess file and using the removeHandler Apache directive might do the trick.

    0 讨论(0)
  • 2020-12-19 20:20

    In general 777 is about as insecure as it gets... that means anybody can read and write to your files.

    HTTP PUT isn't inherently any more secure than HTTP POST if you're allowing the uploaded files to be exceuted on your server.

    Overall, if you are allowing arbitrary files to be executed you need to be doing very good file checking server-side, and using chroot on the server would be wise.

    Permission-wise, I generally set anything web-accessible to 644 owned by the webserver user.

    0 讨论(0)
  • 2020-12-19 20:21

    You don't need and shouldn't have a 777 permission on an upload folder. It should be enough to have it only read and writeable for the user the Webserver is running in (with apache/debian usually www-data). Additionally you should turn off (e.g. via .htaccess) anything you don't want to happen in this folder, like executing PHP scripts (so even if it happens that a user uploads a PHP it can't be executed). HTTP PUT doesn't change your 777 problem, cause the file will still be there after it has been uploaded.

    0 讨论(0)
提交回复
热议问题