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

Goal: 1000 CNY · Raised: 1000 CNY

100.0%

CVE-2022-42889 PoC — Apache Commons Text prior to 1.10.0 allows RCE when applied to untrusted input due to insecure interpolation defaults

Source
Associated Vulnerability
Title:Apache Commons Text prior to 1.10.0 allows RCE when applied to untrusted input due to insecure interpolation defaults (CVE-2022-42889)
Description:Apache Commons Text performs variable interpolation, allowing properties to be dynamically evaluated and expanded. The standard format for interpolation is "${prefix:name}", where "prefix" is used to locate an instance of org.apache.commons.text.lookup.StringLookup that performs the interpolation. Starting with version 1.5 and continuing through 1.9, the set of default Lookup instances included interpolators that could result in arbitrary code execution or contact with remote servers. These lookups are: - "script" - execute expressions using the JVM script execution engine (javax.script) - "dns" - resolve dns records - "url" - load values from urls, including from remote servers Applications using the interpolation defaults in the affected versions may be vulnerable to remote code execution or unintentional contact with remote servers if untrusted configuration values are used. Users are recommended to upgrade to Apache Commons Text 1.10.0, which disables the problematic interpolators by default.
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. Local POC snapshots are reserved for subscribers — if the original source is unavailable, the local mirror is part of the paid plan.
    3. Mirroring, verifying, and maintaining this POC archive takes ongoing effort, so local snapshots are a paid feature. Your subscription keeps the archive online — thank you for the support. View subscription plans →