How to prevent every malicious file upload on my server? (check file type)?

前端 未结 6 1209
半阙折子戏
半阙折子戏 2021-01-05 14:46

my proble is to avoid that users upload some malicious file on my web-server. Im working on linux environment (debian).

Actually the uploads are handled via php by t

6条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-05 15:12

    There is a way, in php, python, or whatelse can a unix system run easly, to check the truly type of a file?

    No.

    You can create a file called, say, “something.pdf” that is a perfectly valid PDF document but still contains signature strings like “”. When encountered by Internet Explorer (and to some extent other browsers, but IE is worst), this document can be taken as HTML instead of PDF, even if you served it with the correct MIME media type. Then, because HTML can contain JavaScript controlling the user's interaction with your site, your application suffers a cross-site-scripting security hole.

    Content-sniffing is a security disaster. See this post for some general workarounds: Stop people uploading malicious PHP files via forms

提交回复
热议问题