Well, that's why there was something telling all the geniuses about "SCREW EXTENSIONS, CHECK MIME! FILEINFO RLZ!", I prepared several lessons:
- Download the cute php logo that I drew
- Take a look. Pretty nice, isn't it?
- Rename it to what_you_like.php
- Put it through all your awesome mime type / any checkers
- Run it
In conclusion, you should NEVER NEVER rely on the MIME type. Your web server does not care about the MIME type, it determines what to do with EXTENSION , ultimately downvoted @Col. The answer to shrapnel is actually right. Any information provided to you by something that checks MIME is completely irrelevant to your web server when it comes to execution.
EDIT: a not-as-unusual code-as-you-want-it-to be that opens a site for this type of attack:
<?php $mimetype = mime_content_type($_FILES['file']['tmp_name']); if(in_array($mimetype, array('image/jpeg', 'image/gif', 'image/png'))) { move_uploaded_file($_FILES['file']['tmp_name'], '/whatever/something/imagedir/' . $_FILES['file']['name']); echo 'OK'; } else { echo 'Upload a real image, jerk!'; }
cypher Sep 08 2018-11-11T00: 00Z
source share