Text4Shell RCE
CVE-2022-42889 is an interpolation flaw in Apache Commons Text, versions 1.5 through 1.9. The StringSubstitutor interpolator resolves lookups written as ${prefix:name}, and the script, dns, and url prefixes do far more than substitute text. When attacker input reaches StringSubstitutor.replace(), a crafted ${script:...} value runs arbitrary code.
Find the request field that ends up in the interpolator and send a script lookup that executes a command. The engine depends on the JDK: Nashorn on older JDKs, JEXL on JDK 15 and newer.
${script:javascript:java.lang.Runtime.getRuntime().exec('...')}
How to reach it
Run the challenge locally with its docker-compose. The flagger sidecar writes your per-run flag into the container before it starts. The service speaks HTTP on port 8080.
Run this challenge
Spin it up locally with Docker. The flagger sidecar fetches a per-run flag into a shared volume, then the challenge container boots and reads it.
services:
flagger:
image: matejbasic/rootcause-flagger:1.0
environment:
ROOTCAUSE_API_URL: https://root-cause-api.matejbasic.com
ROOTCAUSE_API_KEY: ${ROOTCAUSE_API_KEY}
ROOTCAUSE_CHALLENGE: text4shell
FLAG_PATH: /flag/flag.txt
volumes:
- flag:/flag
challenge:
image: matejbasic/cve-2022-42889:1.0
depends_on:
flagger:
condition: service_completed_successfully
environment:
FLAG_PATH: /flag/flag.txt
volumes:
- flag:/flag
ports:
- "8080:8080"
volumes:
flag:
rootcause start text4shellThe rootcause CLI does all of this in one command. Running a challenge needs your API key, which you generate in your profile.