Apache Solr模板注入远程代码执行漏洞
目录
Apache Solr 模板注入远程代码执行漏洞
Apache Solr
是美国阿帕奇(Apache)软件基金会的一款基于 Lucene(一款全文搜索引擎)的搜索服务器。Apache Velocity
是一个提供 HTML
页面模板、email
模板和通用开源代码生成器模板的模板引擎。在 Apache Solr
的多个版本中,Apache Solr
的 VelocityResponseWriter
功能的配置参数可通过 HTTP
请求指定,导致用户可通过设置特定参数后,通过注入任意 Velocity
模板造成任意命令执行。
影响范围
5.0.0 <= Apache Solr <= 8.3.1
环境搭建
可用 vulhub
的 solr
环境进行复现
|
|
将 contrib/velocity/lib
中以 velocity
开头的 jar
包复制到 server/solr-webapp/webapp/WEB-INF/lib/
下:
重启 solr
服务。
漏洞复现
在满足以上环境条件的情况下,利用此漏洞分两步骤。先通过一个 HTTP
请求将 params.resource.loader.enabled
这个关键的参数设置 true
,这样就能允许任意的模板代码从用户的 HTTP
请求中指定。然后再通过指定任意 Velocity
模板代码执行任意命令。由于 Solr
默认未开启认证,在这种情况下,此漏洞利用不需要登录凭据。
|
|
执行 id
命令的返回结果:
修复建议
- 升级到
Apache Solr 8.4