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

> Attackers can execute arbitrary code or trigger SSRF by exploiting insecure default interpolators in Apache Commons Text when processing untrusted input.

- **Severity:** Critical 9.8 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 13 Oct 2022
- **Updated:** 20 Nov 2024
- **Also known as:** CLEANSTART-2026-ML52514, DEBIAN-CVE-2022-42889, GHSA-599f-7c49-w659, RHSA-2023:1524, ROOT-APP-MAVEN-CVE-2022-42889, UBUNTU-CVE-2022-42889, openSUSE-SU-2024:12409-1

## What is CVE-2022-42889?

CVE-2022-42889 is a critical code injection vulnerability in Apache Commons Text, published on 13 Oct 2022. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official 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.

Weakness: CWE-94 (Improper Control of Generation of Code)

## Which versions are affected by CVE-2022-42889?

4 open source packages ship an affected version, including org.apache.commons:commons-text and com.guicedee.services:commons-text. It affects 3 products.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `org.apache.commons:commons-text` | Maven | From 1.5 | 1.10.0 |
| `org.apache.commons:commons-text` | Maven | From 1.5 | 1.10.0 |
| `com.guicedee.services:commons-text` | Maven | All versions to 1.2.2.1-jre17 | None |
| `com.guicedee.services:commons-text` | Maven | All versions to 1.2.2.1-jre17 | None |
| `jenkins-2-plugins` | Red Hat:openshift:4.9::el8 | All versions | 0:4.9.1680069756-1.el8 |
| `apache-commons-text` | openSUSE:Tumbleweed | All versions | 1.10.0-1.1 |

Products: Apache Commons Text, Juniper Security Threat Response Manager, Netapp Bluexp.

## How do I fix CVE-2022-42889?

Upgrade org.apache.commons:commons-text to 1.10.0 or later.

## Is CVE-2022-42889 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2022-42889 exists.

Public exploit code:

- Dockerized POC for CVE-2022-42889 Text4Shell (github_poc): https://github.com/karthikuj/cve-2022-42889-text4shell-docker
- Apache commons text - CVE-2022-42889 Text4Shell proof of concept exploit. (github_poc): https://github.com/kljunowsky/CVE-2022-42889-text4shell
- cve-2022-42889 Text4Shell CVE-2022-42889 affects Apache Commons Text versions 1.5 through 1.9. It has been patched as of Commons Text version 1.10.  (github_poc): https://github.com/ClickCyber/cve-2022-42889
- Proof of Concept for the Apache commons-text vulnerability CVE-2022-42889. (github_poc): https://github.com/SeanWrightSec/CVE-2022-42889-PoC
- CVE-2022-42889 aka Text4Shell research & PoC (github_poc): https://github.com/cxzero/CVE-2022-42889-text4shell
- text4shell(CVE-2022-42889) BurpSuite Scanner (github_poc): https://github.com/f0ng/text4shellburpscanner

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2022-42889 and fix it if it is affected.

What it is: CVE-2022-42889 is a critical code injection vulnerability in Apache Commons Text, published on 13 Oct 2022. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2022-42889 exists.

Affected packages and fixed versions:
- org.apache.commons:commons-text (Maven): affected from 1.5; fixed in 1.10.0
- org.apache.commons:commons-text (Maven): affected from 1.5; fixed in 1.10.0
- com.guicedee.services:commons-text (Maven): affected all versions up to 1.2.2.1-jre17; no fix listed
- com.guicedee.services:commons-text (Maven): affected all versions up to 1.2.2.1-jre17; no fix listed

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2022-42889/ (Markdown: https://insights.sbomify.com/CVE-2022-42889/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2022-42889
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2022-42889
- OSV: https://osv.dev/vulnerability/CVE-2022-42889

---
From sbomify Insights: https://insights.sbomify.com/CVE-2022-42889/
Summaries are generated and may contain mistakes; the official description above is the record.
