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 Citrix Sounds the Alarm: Two Critical NetScaler Zero-Days Actively Exploited
Citrix Sounds the Alarm: Two Critical NetScaler Zero-Days Actively Exploited

CVE Research

Citrix Sounds the Alarm: Two Critical NetScaler Zero-Days Actively Exploited

Citrix has released security updates for NetScaler ADC and NetScaler Gateway addressing CVE-2026-88771 and CVE-2026-88772, two critical remote code execution vulnerabilities. Exploits against unmitigated deployments have been observed. CVE-2026-88771 affects all deployments, including default configurations; CVE-2026-88772 applies when DTLS is enabled, including the default state on VPN virtual servers. This article covers impact, affected and fixed versions, how to confirm exposure, and recommended remediation.

Sep 28, 2026

Open CVE-2023-49105: The ownCloud Authentication Flaw That Exposed Sensitive Credentials
CVE-2023-49105: The ownCloud Authentication Flaw That Exposed Sensitive Credentials

CVE Research

CVE-2023-49105: The ownCloud Authentication Flaw That Exposed Sensitive Credentials

Sep 25, 2026

Open Patch Analysis & Exploitation Timeline: RouterOS SSH Attacks Predate Production Fixes in CISA's September 10, 2026 KEV Additions
Patch Analysis & Exploitation Timeline: RouterOS SSH Attacks Predate Production Fixes in CISA's September 10, 2026 KEV Additions

CVE Research

Patch Analysis & Exploitation Timeline: RouterOS SSH Attacks Predate Production Fixes in CISA's September 10, 2026 KEV Additions

Two MikroTik RouterOS CVEs entered CISA KEV seven days after production fixes. Dated reporting places SSH-chain exploitation involving CVE-2026-86060 at least one calendar day before those releases; no comparable start date is established for CVE-2026-67277.

Sep 25, 2026

Open Patch Analysis & Exploitation Timeline: A Day-Old Chrome Bug and an Eight-Month-Old Fortinet Flaw Share the Same KEV Batch
Patch Analysis & Exploitation Timeline: A Day-Old Chrome Bug and an Eight-Month-Old Fortinet Flaw Share the Same KEV Batch

CVE Research

Patch Analysis & Exploitation Timeline: A Day-Old Chrome Bug and an Eight-Month-Old Fortinet Flaw Share the Same KEV Batch

Four vulnerabilities added to CISA’s KEV catalog on September 9, 2026 show widely different timelines between public disclosure and formal exploitation-based prioritization, ranging from one day to 239 days.

Sep 24, 2026