当前位置:WooYun >> 漏洞信息

漏洞概要 关注数(24) 关注此漏洞

缺陷编号:wooyun-2015-0129923

漏洞标题:金蝶协同办公系统 GETSHELL漏洞

相关厂商:金蝶

漏洞作者: applychen

提交时间:2015-07-29 09:10

修复时间:2015-10-28 10:10

公开时间:2015-10-28 10:10

漏洞类型:文件上传导致任意代码执行

危害等级:高

自评Rank:20

漏洞状态:厂商已经确认

漏洞来源: http://www.wooyun.org,如有疑问或需要帮助请联系 [email protected]

Tags标签:

4人收藏 收藏
分享漏洞:


漏洞详情

披露状态:

2015-07-29: 细节已通知厂商并且等待厂商处理中
2015-07-30: 厂商已经确认,细节仅向厂商公开
2015-08-02: 细节向第三方安全合作伙伴开放
2015-09-23: 细节向核心白帽子及相关领域专家公开
2015-10-03: 细节向普通白帽子公开
2015-10-13: 细节向实习白帽子公开
2015-10-28: 细节向公众公开

简要描述:

详细说明:

金蝶OA系统在web.xml中配置了一个servlet Connector,是基于旧版本的fckeditor,存在任意文件上传漏洞,配置如下:

1.png


com.fredck.FCKeditor.connector.ConnectorServlet.class反编译出主要代码如下:

public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{

……
String commandStr = request.getParameter("Command");
String typeStr = request.getParameter("Type");
String currentFolderStr = request.getParameter("CurrentFolder");
String currentPath = baseDir + typeStr + currentFolderStr;
String currentDirPath = getServletContext().getRealPath(currentPath);
……
if (!commandStr.equals("FileUpload")) {
retVal = "203";
} else {
DiskFileUpload upload = new DiskFileUpload();
try {
List items = upload.parseRequest(request);
Map fields = new HashMap();
Iterator iter = items.iterator();
while (iter.hasNext()) {
FileItem item = (FileItem)iter.next();
if (item.isFormField())
fields.put(item.getFieldName(), item.getString());
else
fields.put(item.getFieldName(), item);
}
FileItem uplFile = (FileItem)fields.get("NewFile");
String fileNameLong = uplFile.getName();
fileNameLong = fileNameLong.replace('\\', '/');
String[] pathParts = fileNameLong.split("/");
String fileName = pathParts[(pathParts.length - 1)];
String nameWithoutExt = getNameWithoutExtension(fileName);
String ext = getExtension(fileName);
File pathToSave = new File(currentDirPath, fileName);
int counter = 1;
while (pathToSave.exists()) {
newName = nameWithoutExt + "(" + counter + ")" + "." + ext;
retVal = "201";
pathToSave = new File(currentDirPath, newName);
counter++;
}
uplFile.write(pathToSave);
} catch (Exception ex) {
retVal = "203";
}
}
……
}
private static String getNameWithoutExtension(String fileName)
{
return fileName.substring(0, fileName.lastIndexOf("."));
}
private String getExtension(String fileName)
{
return fileName.substring(fileName.lastIndexOf(".") + 1);
}


当Command参数为FileUpload时进行上传,最终服务器上生成的pathToSave文件名,由上传文件路径获得:

c:\a\b.jsp => b.jsp


可以看到整个过程是没有过滤后缀的。
直接本地构造一个上传页面即可上传:

2.png


得到webshell如下:
http://202.104.120.18:7890/oa/uploadfiles/File/testabc.jsp
金蝶官方协同办公系统测试地址:

http://kdhr.kingdee.com/oa/login/k3oa.do
http://202.104.120.18:7890/oa/


搜索引擎中记录的,有些已经被getshell了:

http://www.baidu.com/s?wd=inurl%3A%2Foa%2Fthemes%20inurl%3Ajsp&pn=0&oq=inurl%3A%2Foa%2Fthemes%20inurl%3Ajsp&tn=baiduhome_pg&ie=utf-8&rsv_idx=2&rsv_pq=fb5f291b0000049f&rsv_t=82d1fPuT2XOZBoyz9U23%2FZ%2Ft1VKbzrvhMO%2F2TBLPypK2rkEqqA7Xt0LZtkQw42tT1RMn


漏洞证明:

同上

修复方案:

取消Connector的映射,改用SimpleUploader

版权声明:转载请注明来源 applychen@乌云


漏洞回应

厂商回应:

危害等级:高

漏洞Rank:15

确认时间:2015-07-30 10:09

厂商回复:

谢谢对金蝶的关注,为我们发现安全漏洞。我们已通知相关部门修复。

最新状态:

暂无