Explore our new Cybersecurity Terms Glossary, explained by our experts.
Cybersecurity Terms Glossary
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.

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.
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:
script, which evaluates an expression through the Java Scripting API, giving arbitrary code execution on a JDK that bundles Nashorn (JDK 8 through 14);dns, which resolves a hostname and can be used to confirm exploitability or exfiltrate data through DNS;url, which fetches a remote resource, enabling server-side request forgery.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.
Three factors limited real-world exposure:
StringEscapeUtils or WordUtils, which are unaffected. Passing untrusted data into createInterpolator() is an unusual pattern.script prefix fails, leaving the less severe dns and url lookups.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.
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:
mvn dependency:tree or gradle dependencies) and record every version of org.apache.commons:commons-text, including transitive ones pulled in by frameworks.StringSubstitutor, createInterpolator, and StringLookupFactory, then trace whether any argument originates from a request parameter, header, uploaded file, message queue, or database field that users control.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.
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.
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.
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.
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.
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.
You May Be Interested In These
We use a few cookies that are needed to make this website work, and they are always on. We would also like to set analytics cookies, to see which pages are useful; functional cookies, so that our live chat works; and advertising cookies, to measure our campaigns. We will not set any of those until you say yes, and you can change your mind at any time from the Cookie Settings link in the footer.
Choose the cookies you are happy for us to use. Strictly necessary cookies are always on; everything else is off until you turn it on.
These cookies keep the website working: they hold your security checks, your form submissions and the choice you make here. The site cannot run without them, so they are always on.
These let our live chat open and remember your conversation, and let the newsletter sign-up work. Switch them off and the chat window will not appear.
These tell us which pages are read and how people find us, so that we can improve the site. The reports are about groups of visitors, never about you personally.
These let us measure our advertising and show you our adverts on other websites, such as LinkedIn, Google and Meta. Switch them off and you will still see adverts, but they will be less relevant.