Menu

#6 Malicious uploads

open
nobody
None
5
2010-03-16
2010-03-16
Anonymous
No

If we set our root path;

PGRFileManagerConfig::$rootPath = '/images';

meaning that the files will be stored in http://www.mysite.com/images which will have the execution rights. So if someone uploads a jpeg file that contains a php script inside and renames it using the file manager he/she can execute this file. So while renaming the file we should check something like;

//check rename to be image extension again
if (!(preg_match('/^.*\.(jpg|gif|jpeg|png|bmp)$/', strtolower($newFilename)) > 0)) die();

or possibly prevent direct access to upload folder using a .htaccess file.

Discussion


Log in to post a comment.