Explore our new Cybersecurity Terms Glossary, explained by our experts.

View the Glossary View the Glossary
PRIVIA

Cybersecurity Terms Glossary

What Is Text4Shell?

Text4Shell (CVE-2022-42889) is a remote code execution flaw in Apache Commons Text, triggered when untrusted input reaches a string interpolator that resolves script, DNS, and URL lookups.

Illustration for the cybersecurity term Text4Shell
Home / Blog / Cybersecurity Terms / What Is Text4Shell?
17 November 2026

What Is Text4Shell?

What Is Text4Shell?

Text4Shell is CVE-2022-42889, a remote code execution vulnerability in Apache Commons Text versions 1.5 through 1.9, published on 13 October 2022 with a CVSS v3.1 score of 9.8. Where an application passes attacker-controlled text to the library’s string interpolator, a crafted value such as ${script:javascript:java.lang.Runtime.getRuntime().exec(...)} causes that code to run on the server.

The nickname arrived within hours and set expectations that the vulnerability never matched. It is worth understanding both the flaw and why the comparison to Log4Shell did not hold, because the difference explains what to look for in your own code.

String Interpolation and Its Default Lookups

Apache Commons Text is a utility library for string manipulation. One of its features, StringSubstitutor, replaces placeholders of the form ${key} with values resolved from a map, from system properties, or from a set of named lookups.

From version 1.5, the default interpolator returned by StringSubstitutor.createInterpolator() included three lookups that reach outside the process:

None of that is a bug on its own; it is a documented feature. The vulnerability is that these lookups were enabled by default, so a developer calling createInterpolator() on user input had no indication that they had created an execution sink.

Why the Impact Was Narrower Than the Score Suggested

Three factors limited real-world exposure:

  1. The vulnerable call is uncommon. Most applications using Commons Text call StringEscapeUtils or WordUtils, which are unaffected. Passing untrusted data into createInterpolator() is an unusual pattern.
  2. The script lookup needs a scripting engine. Nashorn was removed from the JDK in version 15, so on a modern runtime the script prefix fails, leaving the less severe dns and url lookups.
  3. The fix predated the publicity. Commons Text 1.10.0, released on 24 September 2022, disables the script, dns, and url lookups by default. Many teams had already upgraded by the time the advisory circulated.

Log4Shell, by contrast, triggered on any logged string, and logging user input is universal. That is the structural difference: a vulnerable sink everyone uses versus one almost nobody does. Widespread internet-wide exploitation of Text4Shell never materialised, although opportunistic scanning for it started immediately.

Finding Out Whether You Are Affected

Dependency scanning answers the first question and is not sufficient on its own, because the presence of commons-text in the tree does not mean the vulnerable call is reached. Do both:

A software bill of materials produced at build time makes the first step instant for every release you have shipped, which is the real value of maintaining one. Note also that commons-text is a separate artefact from commons-lang3; the older StringSubstitutor in Commons Lang does not include these lookups.

Remediation

Upgrade to Apache Commons Text 1.10.0 or later. If an upgrade has to wait, construct the substitutor explicitly with only the lookups you need rather than using the default interpolator, and validate or reject input containing ${ before it reaches the library.

The broader habit worth taking from this is to treat any interpolation, templating, or expression evaluation feature as an execution sink until proven otherwise. The same pattern produced Spring Cloud Function’s SpEL injection, server-side template injection in Freemarker and Thymeleaf, and expression language flaws in a dozen other frameworks.

Cyber Essentials requires internet-facing software to be patched within 14 days of a critical update, and the practical obstacle is almost always inventory rather than effort. Our Web Application Security Services combine dependency analysis with manual testing of the places where untrusted input meets templating, which is where this class of flaw actually lives.

FAQ – Frequently Asked Questions

Is Text4Shell as Dangerous as Log4Shell?

No, despite a similar CVSS score. Log4Shell triggered whenever an application logged attacker-controlled text, which nearly every Java application does. Text4Shell requires untrusted input to reach a specific interpolator call that few applications use, and the script lookup additionally needs a JDK that still bundles Nashorn. Exposure was a tiny fraction of Log4Shell’s.

Which Versions of Apache Commons Text Are Affected?

Versions 1.5 through 1.9 enable the script, dns, and url lookups by default in the interpolator returned by StringSubstitutor.createInterpolator(). Version 1.10.0, released on 24 September 2022, disables them. Versions before 1.5 do not include those lookups at all. Commons Lang3 contains a different StringSubstitutor that is not affected by this issue.

Does Having commons-text in My Dependency Tree Mean I Am Exploitable?

Not by itself. The library is only dangerous where untrusted input reaches the default interpolator. Scan for the dependency first, then search the code for StringSubstitutor and createInterpolator and trace the data flow into them. Upgrade regardless, since the upgrade is low risk, but do not treat every dependency hit as an incident.

What Should I Do if I Cannot Upgrade Immediately?

Build the substitutor explicitly with StringLookupFactory, supplying only the lookups your application genuinely needs, so the script, dns, and url prefixes are unavailable. As a secondary control, reject or escape input containing the ${ sequence before it reaches the library. Both are stopgaps; schedule the upgrade to 1.10.0 or later as the permanent fix.

Related Terms

You May Be Interested In These

What Is IEC 62443-3-3?

Cybersecurity Terms

17 November 2026

What Is IEC 62443-3-3?

Read More
What Are the CIS Controls?

Cybersecurity Terms

17 November 2026

What Are the CIS Controls?

Read More
What Is IDA Pro?

Cybersecurity Terms

17 November 2026

What Is IDA Pro?

Read More