• XSS.stack #1 – первый литературный журнал от юзеров форума

GLPI 9.X modifications plugin \| insecure file upload/code exec |/

mngl

HDD-drive
Пользователь
Регистрация
08.06.2021
Сообщения
22
Реакции
12
GLPI is a IT service manger used in companys, gov and education organizations, its a very interesting target and have tons of vulnerabilities, but none interesting code exec in relevant versions, with the exception of CVE-2020-11060 witch is very interesting (worth reading), but for some reason i could not reliably replicate .

After some hours of auditing the source code, i of course, could not find anything, just a few hours wouldn't break it, so i turned my attention to the glpi plugins that have way smaller code bases, and admins for some reason tend to just trust them, i found some bugs in multiple of then. Im going to show a insecure file upload i found that with the assistance of other vulnerabilities lead to php code exec.


The plugin is Modifications and it is used to modify the login page, home and menu bar for GLPI 9.X, and they have a very bad implementation of uploading files on upfile.php and uplogo.php.

After a bypassable getimagesize :
PHP:
$info = getimagesize($_FILES['photo']['tmp_name']);
...
...
elseif($info === false) {  
                $valid_file = false;                      
               die("Unable to determine image type of uploaded file");
            }
Instead of moving it from the _tmp directory to /pics/bg with the proper name, they choose trust the real file name without any checks to change directorys and then rename it:
PHP:
if($valid_file)
            {
                //move it to where we want it to be
                $currentdir = getcwd();
                $target = '../../pics/bg/' . basename($_FILES['photo']['name']);
                //$target = $currentdir .'/uploads/' . basename($_FILES['photo']['name']);
                move_uploaded_file($_FILES['photo']['tmp_name'], $target);
                //move_uploaded_file($_FILES['photo']['tmp_name'], 'uploads'.$new_file_name);
                rename('../../pics/bg/'.basename($_FILES['photo']['name']), '../../pics/bg/back.jpg');
                $message = 'Congratulations!  Your file was accepted.';
                header('Location: ../../plugins/mod/config.php ');
                //echo $message;
            }
So we can activate a php code inside a image, that drops your shell or do whatever, in the time frame between move_uploaded_file($_FILES['photo']['tmp_name'], $target); and rename('../../pics/bg/'.basename($_FILES['photo']['name']), '../../pics/bg/back.jpg');calls
That can be done by making multiple files uploads in a row and, at the same time, trying to access /pics/bg/uploaded_file.php, eventually you will hit the time frame.

Here is a simple python implementation :

. To exploit it you have to have access to a admin account, there are multiples xss to archive it.
. The better the connection you have faster it will work, but you can archive it routing on slow networks such tor and proxy chains, and it will only take a few minutes to exploit, although it will make tons of requests that a good admin or a waf could spot you.

I also have a much faster c++ implementation using libcurl and support for multiple targets.
If for some reason you have any questions fell free to pm.
 


Напишите ответ...
  • Вставить:
Прикрепить файлы
Верх