Vulnerabilities In Apache Commons-Text 1.10.0
The Apache Commons-Text library's XML, properties, and file interpolators did not validate file paths or block external entities, allowing path traversal and XXE attacks. An attacker who controls input to the string substitutor could read arbitrary files or exfiltrate data.
In October 2022 a vulnerability in Apache Commons-Text was reported (CVE-2022-42889) dubbed "Text4Shell". This vulnerability, while less prevalent, acted somewhat similar to log4shell which used interpolators to perform string lookups on user defined input that resulted in code execution.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The library's lookup functions accepted file paths and XML input without validation, allowing path traversal and external entity processing.
What the attacker needed
Application uses Apache Commons-Text; user input passed to StringSubstitutor; no input sanitisation
The fix
The library should validate that file paths are canonical and within an allowed directory, and disable doctype declarations in XML parsing; the Apache Commons-Text team did not consider these security vulnerabilities and did not fix them.
How it was found
- Identify that the application uses Apache Commons-Text with user-controlled input passed to StringSubstitutor.replace().
- Craft an input using the xml, properties, or file lookup with a path traversal sequence to point to a local file.
- Submit the input to the application, which processes it through the vulnerable lookup.
- Observe the contents of the targeted file returned in the application's response or error message.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Apache Commons-Text is a helper library for Java programs that fills in placeholders like ${...} in text. The researcher found that some placeholders could be tricked into reading files from anywhere on the computer, or even fetching secret files and sending them to an attacker. This only matters if a program passes untrusted user input into the library without cleaning it first.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.