###0x01 影响范围


###0x02 漏洞分析
EduSoho 5.1.4 在/src/Topxia/WebBundle/Controller/SearchController.php处存在SQL注入漏洞。下载源代码,定位发现src/Topxia/WebBundle/Controller/SearchController.php 36行的categoryIds参数存在注入:
```
<?php
namespace Topxia\WebBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
use Topxia\Common\Paginator;
use Topxia\Common\ArrayToolkit;
class SearchController extends BaseController
{
public function indexAction(Request $request)
{
$courses = $paginator = null;
$code = 'Vip';
$currentUser = $this->getCurrentUser();
$keywords = $request->query->get('q');
$keywords=trim($keywords);
$vip = $this->getAppService()->findInstallApp($code);
$isShowVipSearch = $vip && version_compare($vip['version'], "1.0.7", ">=");
$currentUserVipLevel = "";
$vipLevelIds = "";
if($isShowVipSearch){
$currentUserVip = $this->getVipService()->getMemberByUserId($currentUser['id']);
$currentUserVipLevel = $this->getLevelService()->getLevel($currentUserVip['levelId']);
$vipLevels = $this->getLevelService()->findAllLevelsLessThanSeq($currentUserVipLevel['seq']);
$vipLevelIds = ArrayToolkit::column($vipLevels, "id");
}
$parentId = 0;
$categories = $this->getCategoryService()->findAllCategoriesByParentId($parentId);
$categoryIds=array();
for($i=0;$i<count($categories);$i++){
$id = $categories[$i]['id'];
$name = $categories[$i]['name'];
$categoryIds[$id] = $name;
}
$categoryId = $request->query->get('categoryIds');
$coursesTypeChoices = $request->query->get('coursesTypeChoices');
if (!$keywords) {
goto response;
}
if($coursesTypeChoices == 'vipCourses'){
$conditions = array(
'status' => 'published',
'title' => $keywords,
'categoryId' => $categoryId,
'vipLevelIds' => $vipLevelIds
);
}elseif($coursesTypeChoices == 'liveCourses'){
$conditions = array(
'status' => 'published',
'title' => $keywords,
'categoryId' => $categoryId,
'type' => 'live'
);
}else{
$conditions = array(
'status' => 'published',
'title' => $keywords,
'categoryId' => $categoryId
);
}
$paginator = new Paginator(
$this->get('request'),
$this->getCourseService()->searchCourseCount($conditions)
, 10
);
$courses = $this->getCourseService()->searchCourses(
$conditions,
'latest',
$paginator->getOffsetCount(),
$paginator->getPerPageCount()
);
response:
return $this->render('TopxiaWebBundle:Search:index.html.twig', array(
'courses' => $courses,
'paginator' => $paginator,
'keywords' => $keywords,
'isShowVipSearch' => $isShowVipSearch,
'currentUserVipLevel' => $currentUserVipLevel,
'categoryIds' => $categoryIds,
'coursesTypeChoices' => $coursesTypeChoices
));
}
...
```
本来打算回溯到具体的SQL查询,但发现是用了Symfony框架加上code审计能力有限....AdminBundle貌似后台也在调:

###0x03漏洞证明
###3.1本地测试

##3.2官网demo.edusoho.com
```
web server operating system: Linux Ubuntu
web application technology: Nginx, PHP 5.5.9
back-end DBMS: MySQL >= 5.0.0
database management system users [1]:
[*] 'demoedusohouser'@'localhost'
available databases [2]:
[*] `demo.edusoho.com`
[*] information_schema
```
###0x04修复方案
对参数进行过滤。
暂无评论