SecPod

Learn Search

Search across all Learn content

← Back to Security Research
Text4Shell: Critical Code Execution in Apache Common Text Library – Patch Now!

Text4Shell: Critical Code Execution in Apache Common Text Library – Patch Now!

Apache Common Text is used for advance text handling functions such as escaping special characters and the similarity of strings (basis on Cosine, Hamming, Longest Commons Subsequence distance, etc.). The difference between strings, text lookup, etc. A code execution vulnerability( CVE-2022-42889 )i...

Oct 19, 2022By Mohamed Faiz2 min read

Apache Common Text is used for advance text handling functions such as escaping special characters and the similarity of strings (basis on Cosine, Hamming, Longest Commons Subsequence distance, etc.). The difference between strings, text lookup, etc. A code execution vulnerability( CVE-2022-42889 )is in one of the text lookup modules of the Common Text library and identifying as CVE-2022-42889. A reliable vulnerability management tool can detect these.

However, A patch management software is required to patch the vulnerabilities.

Vulnerability(CVE-2022-42889) in Depth:

A module of org.apache.commons.text.lookup.StringLookupFactory Class called StringSubstitutor, used for constructing complex strings, has a flaw.

Example of StringSubstitutor object:

block
StringSubstitutor.createInterpolator().replace("... ${base64Decoder:UHJldmVudCBDeWJlcmF0dGFja3MgdXNpbmcgU2FuZXJOb3cg} ..."));

The above example decodes the base64 encoded value and provides the output “Prevent Cyberattacks using SanerNow.”

Like this, multiple functionalities imposed by StringSubstitutor, as mentioned in the Common Text User Guide.

block
final StringSubstitutor interpolator = StringSubstitutor.createInterpolator();
final String text = interpolator.replace(
    "Base64 Decoder:        ${base64Decoder:SGVsbG9Xb3JsZCE=}\n" +
    "Base64 Encoder:        ${base64Encoder:HelloWorld!}\n" +
    "Java Constant:         ${const:java.awt.event.KeyEvent.VK_ESCAPE}\n" +
    "Date:                  ${date:yyyy-MM-dd}\n" +
    "Environment Variable:  ${env:USERNAME}\n" +
    "DNS:                   ${dns:address|apache.org}\n" +
    "File Content:          ${file:UTF-8:src/test/resources/document.properties}\n" +
    "Java:                  ${java:version}\n" +
    "Script:                ${script:javascript:3 + 4}\n" + 
    "URL Content (HTTP):    ${url:UTF-8:http://www.apache.org}\n" +
    "URL Content (HTTPS):   ${url:UTF-8:https://www.apache.org}\n" +
    "Localhost:             ${localhost:canonical-name}\n" +
    "System Property:       ${sys:user.dir}\n" +
    "URL Decoder:           ${urlDecoder:Hello%20World%21}\n" +
    "URL Encoder:           ${urlEncoder:Hello World!}\n" +
);

Among the above functionalities, URL, Script, and DNS are some of the critical functions. These use cases can allow attackers to contact the C2C server or run commands in the victim server.

DNS:

DNS lookup can allow the hacker to get the private IP address to get details of an internal network.

block
 lookupMap.put("dns", StringLookupFactory.INSTANCE.dnsStringLookup());

 StringLookup variableResolver = StringLookupFactory.INSTANCE.interpolatorStringLookup(lookupMap, null, false);

 new StringSubstitutor(variableResolver).replace("... ${dns:address|sanernow.com} ...");

The above example will provide the internal IP address of sanernow.com

SCRIPT:

Malicious users can run commands in the vulnerable machine using Script functionality.

block
 lookupMap.put("script", StringLookupFactory.INSTANCE.scriptStringLookup());

 StringLookup variableResolver = StringLookupFactory.INSTANCE.interpolatorStringLookup(lookupMap, null, false);
 
 StringLookupFactory.INSTANCE.scriptStringLookup().lookup("javascript:5 - 4");

The above example converts “javascript:5 – 4” to 1.

Is CVE-2022-42889 critical?

The issue is equivalent to Apache’s log4j vulnerability. But, the Common Text module is not in use by most of the developers for input sanitization, as Apache’s logger module is in use. Compromise is possible only if a developer uses the latter module.

Impact:

Successful exploitation of the vulnerability will allow remote attackers to executearbitrary code.

Solution:

  • Update Apache Common Text to 1.10.0

SanerNow VM detects this vulnerability. Use SanerNow and keep your systems updated and secure.

Featured Posts

Open StyleSmuggler: Inside the Unpatched Magento Zero-Day Backdooring Live Stores
StyleSmuggler: Inside the Unpatched Magento Zero-Day Backdooring Live Stores

CVE Research

StyleSmuggler: Inside the Unpatched Magento Zero-Day Backdooring Live Stores

StyleSmuggler, an unpatched Magento and Adobe Commerce flaw letting attackers execute code without authentication via log poisoning, installing a persistent Linux backdoor that has already compromised live stores with no vendor patch available.

Sep 7, 2026

Open CVE-2026-6471: 12-Year-Old PostgreSQL PostGREShell Flaw Enables Server Takeover
CVE-2026-6471: 12-Year-Old PostgreSQL PostGREShell Vulnerability

CVE Research

CVE-2026-6471: 12-Year-Old PostgreSQL PostGREShell Flaw Enables Server Takeover

Sep 7, 2026

Open Root-Level RCE Flaw in Cisco Nexus 9000 Series Switches Exposes Networks to Complete Compromise — CVE-2026-20212
Root-Level RCE Flaw in Cisco Nexus 9000 Series Switches Exposes Networks to Complete Compromise — CVE-2026-20212

CVE Research

Root-Level RCE Flaw in Cisco Nexus 9000 Series Switches Exposes Networks to Complete Compromise — CVE-2026-20212

CVE-2026-20212 is a critical vulnerability in Cisco Nexus 9000 Series Switches that use Silicon One ASICs. It allows an unauthenticated remote attacker to execute code with root privileges by sending crafted input to TCP ports 43210 and 43211, which are reachable in the default Layer 3 VRF. Exploitation can also crash the S1HAL process and force a device reload. This article covers how the vulnerability works, the affected product identifiers, its potential impact, available workarounds, and how to identify fixed software using the Cisco Software Checker.

Sep 4, 2026

Open SonicWall SMA 1000 Under Active Attack: Two Zero-Days Enable SSRF and Remote Code Execution
SonicWall SMA 1000 Under Active Attack: Two Zero-Days Enable SSRF and Remote Code Execution

CVE Research

SonicWall SMA 1000 Under Active Attack: Two Zero-Days Enable SSRF and Remote Code Execution

Sep 3, 2026