Upload class | is_allowed_filetype() - possible bug and security issue |
[eluser]Unknown[/eluser]
I think i found a bug and a possible security problem with file uploading. I am sorry if somebody already mentioned this problem but I didn't have much time - quick search was futile and I think this could be a serious problem (if I'm right) This is the scenario: Code: $config['allowed_types'] = 'txt'; This configuration allowed me to upload some_file.php!!! This was possible cause php file I managed to upload was text/plain (mime). When you look into is_allowed_filetype() method: Code: function is_allowed_filetype() You can see that there is NO file_ext checking! I suggest following solution which gives us the ability to check both file extension and MIME type: Code: function is_allowed_filetype() Another solution for this problem I found here. That is the replacement for Upload class that checks only file extension! I would suggest that if you want to keep MIME checking in Upload class, you provide us with a switch. Something like: Code: $config['mime_check'] = FALSE; This mime_check should be applied to following methods - is_image() - is_allowed_filetype() Cheers! Edit: Changed erroneous code |
Messages In This Thread |
Upload class | is_allowed_filetype() - possible bug and security issue - by El Forum - 08-28-2008, 06:00 PM
Upload class | is_allowed_filetype() - possible bug and security issue - by El Forum - 12-24-2008, 06:33 AM
Upload class | is_allowed_filetype() - possible bug and security issue - by El Forum - 09-26-2009, 06:21 PM
Upload class | is_allowed_filetype() - possible bug and security issue - by El Forum - 09-28-2009, 03:17 PM
|