Goal Reached Thanks to every supporter — we hit 100%!

Goal: 1000 CNY · Raised: 1000 CNY

100.0%

CVE-2022-42889 PoC — Apache Commons Text 代码注入漏洞

Source
Associated Vulnerability
Title:Apache Commons Text 代码注入漏洞 (CVE-2022-42889)
Description:Apache Commons Text是美国阿帕奇(Apache)基金会的一个专注于字符串算法的库。 Apache Commons Text 1.5至1.9版本存在安全漏洞,该漏洞源于默认的Lookup实例集包括可能导致任意代码执行或与远程服务器联系的插值器,可能容易受到远程代码执行或与远程服务器的无意接触的影响。
Description
通过 jvm 启动参数 以及 jps pid进行拦截非法参数
Readme
### cve-2022-42889-intercept

* 低于 Java11版本的需要注意,更高的版本已经取消了`Javascript`解释器
* 本次方案针对 Java8


通过 jvm 启动参数 以及 jps pid进行拦截非法参数


![rce_demo.png](rce_demo.png)





#### quick start


```bash

-----------------------load......
cve-2022-42889 check start
cve-2022-42889 is_deep_match  org.apache.commons.text.StringSubstitutor
md.getReturnType().getActualName() java.lang.String
[cve-2022-42899] class found!: class org.apache.commons.text.StringSubstitutor
(StringSubstitutor replace disabled)
[CVE 2022-42889] StringSubstitutorclass org.apache.commons.text.StringSubstitutor: (sanitized) PoC Output: %_script:javascript:195 + 324_
by arksec.cn
```



### 打开方式


>使用 Attach API 远程加载的 Java agent 不会再先于main方法执行,这取决于另一虚拟机调用 Attach API 的时机。并且,它运行的也不再是premain方法,而是名为agentmain的方法。
 Java 虚拟机并不限制 Java agent 的数量。你可以在 java 命令后附上多个-javaagent参数,或者远程 attach 多个 Java agent,Java 虚拟机会按照定义顺序,或者 attach 的顺序逐个执行这些 Java agent。


* premain
* java 启动参数


```bash

-javaagent:/path/to/dir/CVE-2022-42889-Agent-1.0-SNAPSHOT-jar-with-dependencies.jar

```


* agentmain
* jps (pid注入)
* 执行 `Attach` 的main方法 (先引入 `tools.jar`)




File Snapshot

[4.0K] /data/pocs/d2c6f0938879070c494dd4ee7b77f87503ded5aa ├── [3.6K] pom.xml ├── [310K] rce_demo.png ├── [1.4K] README.md ├── [4.0K] src │   └── [4.0K] main │   └── [4.0K] java │   └── [4.0K] cn │   └── [4.0K] arksec │   └── [4.0K] java │   └── [4.0K] agent │   ├── [2.1K] Agent.java │   ├── [ 286] AgentMain.java │   ├── [ 833] Attach.java │   ├── [4.0K] hooks │   │   └── [7.0K] Cve202242889.java │   └── [ 282] PreMain.java └── [4.0K] target ├── [4.0K] classes │   └── [4.0K] cn │   └── [4.0K] arksec │   └── [4.0K] java │   └── [4.0K] agent │   ├── [2.5K] Agent.class │   ├── [ 569] AgentMain.class │   ├── [1005] Attach.class │   ├── [4.0K] hooks │   │   ├── [2.0K] Cve202242889$1.class │   │   ├── [1.2K] Cve202242889$2.class │   │   ├── [2.4K] Cve202242889$3.class │   │   ├── [1.7K] Cve202242889$4.class │   │   └── [7.9K] Cve202242889.class │   └── [ 561] PreMain.class ├── [ 13K] CVE-2022-42889-Agent-1.0-SNAPSHOT.jar ├── [4.4M] CVE-2022-42889-Agent-1.0-SNAPSHOT-jar-with-dependencies.jar ├── [4.0K] lib │   ├── [3.8M] byte-buddy-1.12.18.jar │   ├── [564K] commons-lang3-3.11.jar │   └── [211K] commons-text-1.9.jar ├── [4.0K] maven-archiver │   └── [ 123] pom.properties └── [4.0K] maven-status └── [4.0K] maven-compiler-plugin ├── [4.0K] compile │   └── [4.0K] default-compile │   ├── [ 377] createdFiles.lst │   └── [ 600] inputFiles.lst └── [4.0K] testCompile └── [4.0K] default-testCompile └── [ 0] inputFiles.lst 23 directories, 26 files
Shenlong Bot has cached this for you
Remarks
    1. It is advised to access via the original source first.
    2. If the original source is unavailable, please email f.jinxu#gmail.com for a local snapshot (replace # with @).
    3. Shenlong has snapshotted the POC code for you. To support long-term maintenance, please consider donating. Thank you for your support.