note 106771 added to function.imagecreatefromjpeg

From: Date: Mon, 05 Dec 2011 17:35:00 +0000
Subject: note 106771 added to function.imagecreatefromjpeg
Groups: php.notes 
Request: Send a blank email to php-notes+get-184907@lists.php.net to get a copy of this message
some lib versions of the GD have a "multiple dot in filename" bug. For example you just put an upload form on your site, and after clicking the submit button you call the next page. There is probably a "move_uploaded_file" and "createimagefromuploaded". The second function fails if in the file ".htaccess.jpg" hasn't the magic bytes identifying a valid jpeg format but the function move_uploaded_file() cuts the last extension, leaving the filename as .htaccess As we well know this file defines access rights.... at least it allows to set 777 access rights in the chosen temp directory, and most programmers don't have the fantasy to change the directory path to something less guesable than "upload" or "file_tmp" - because they only copy&paste code examples. The next file was "i_am_now_root.sh.jpg" and the third one was "replace_index_html_with_my_stuff.sh.jpg". So a simple browser call "http://attacedwebsite.com/upload/replace_index_html_with_my_stuff.sh" succeeds - for gods sake he didn't cheat my upload noticication and I expected the worst by the first filename. Last but not least this security weakness can be worked around by checking multiple dots in a given filename, and of course, single dotted filenames are only pics if there appears a ".jpg" or ".png" or what ever the createimagefromjpeg can do. ---- Server IP: 69.147.83.197 Probable Submitter: 49.0.155.152 ---- Manual Page -- http://www.php.net/manual/en/function.imagecreatefromjpeg.php Edit -- https://master.php.net/note/edit/106771 Del: integrated -- https://master.php.net/note/delete/106771/integrated Del: useless -- https://master.php.net/note/delete/106771/useless Del: bad code -- https://master.php.net/note/delete/106771/bad+code Del: spam -- https://master.php.net/note/delete/106771/spam Del: non-english -- https://master.php.net/note/delete/106771/non-english Del: in docs -- https://master.php.net/note/delete/106771/in+docs Del: other reasons-- https://master.php.net/note/delete/106771 Reject -- https://master.php.net/note/reject/106771 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#184907) next »