Sulla scia di Log4Shell e Spring4Shell, è stata scoperta da poco Text4Shell, la nuova remote command execution che impatta la libreria Apache Commons Text e permette di eseguire codice arbitrario.
Text4Shell, nuova RCE nella libreria Apache Commons Text
Tempo di lettura stimato: 6 min
Alvaro Munoz, noto ricercatore di sicurezza informatica, ha recentemente scoperto una nuova vulnerabilità nella libreria Apache Commons Text che permette di eseguire codice arbitrario, classificata con la CVE-2022-42889 e soprannominata comunemente Text4Shell (vista la similitudine con le precedenti Log4Shell e Spring4Shell).

GHSL-2022-018: Arbitrary Code Execution in Apache Commons Text - CVE-2022-42889
The StringSubstitutor default interpolators may lead to unsafe script evaluation and arbitrary code execution

La vulnerabilità ha ottenuto uno score di 9,8 (su un massimo di 10 - scopri come calcolare la gravità di una vulnerabilità informatica) e consente di eseguire codice arbitrario, ma nonostante ciò la probabilità che venga exploitata, se messa a paragone con Log4Shell, è molto più bassa. Ciò è dovuto al fatto che è molto più raro che venga parsato tramite questa libreria dell'input passato direttamente dall'utente.
"The vulnerable
La stesso team di security dell'Apache foundation conferma quanto già stato detto (ref):
“This issue is different from Log4Shell (CVE-2021-44228) because in Log4Shell, string interpolation was possible from the log message body, which commonly contains untrusted input. In the Apache Common Text issue, the relevant method is explicitly intended and clearly documented to perform string interpolation, so it is much less likely that applications would inadvertently pass in untrusted input without proper validation”.
Le versioni di Apache Common Text impattate dal bug vanno dalla 1.5 alla 1.9, per cui per rimediare la vulnerabilità è sufficiente aggiornare la libreria alla versione 1.10, già rilasciata assieme alla responsible disclosure di Alvaro.
Per il dettaglio tecnico della falla, Alvaro dice:
“The Apache Commons Text code appears to be based on the Log4j code, as both of them enable interpolation of multiple Lookup sources. Log4j enabled JNDI lookups [while] Apache Commons Text and Apache Commons Configuration allows script lookups. [...] The
Dai PoC creati ad hoc per testare questa CVE si può evincere effettivamente la similitudine tra Log4Shell e Text4Shell:"The vulnerable
StringSubstitutor
(ref) interpolator is considerably less widely used than the vulnerable string substitution in Log4j and the nature of such an interpolator means that getting crafted input to the vulnerable object is less likely than merely interacting with such a crafted string as in Log4Shell” spiegano i ricercatori di Rapid7 all'interno del loro articolo (CVE-2022-42889: Keep Calm and Stop Saying "4Shell") riguardo tale vulnerabilità. Fare hype attorno a queste falle è controproducente, non serve a nulla, se non a creare caos e inutili allarmismi. La natura stessa della vulnerabilità mostra come, a differenza di Log4Shell, è raro che un'applicazione utilizzi il componente vulnerabile di Commons Text per elaborare input non attendibili e potenzialmente dannosi.La stesso team di security dell'Apache foundation conferma quanto già stato detto (ref):
“This issue is different from Log4Shell (CVE-2021-44228) because in Log4Shell, string interpolation was possible from the log message body, which commonly contains untrusted input. In the Apache Common Text issue, the relevant method is explicitly intended and clearly documented to perform string interpolation, so it is much less likely that applications would inadvertently pass in untrusted input without proper validation”.
Le versioni di Apache Common Text impattate dal bug vanno dalla 1.5 alla 1.9, per cui per rimediare la vulnerabilità è sufficiente aggiornare la libreria alla versione 1.10, già rilasciata assieme alla responsible disclosure di Alvaro.
Per il dettaglio tecnico della falla, Alvaro dice:
“The Apache Commons Text code appears to be based on the Log4j code, as both of them enable interpolation of multiple Lookup sources. Log4j enabled JNDI lookups [while] Apache Commons Text and Apache Commons Configuration allows script lookups. [...] The
StringSubstitutor
when used with the default interpolators (StringSubstitutor.createInterpolator()
) will perform string lookups that may lead to arbitrary code execution. [...] In particular, if untrusted data flows into the StringSubstitutor.replace()
or StringSubstitutor.replaceIn()
methods, an attacker will be able to use the ScriptStringLookup
to trigger arbitrary code execution.”
Gli sviluppatori del progetto Apache inoltre aggiungono (ref):
“These lookups are: – “script” – execute expressions using the JVM script execution engine (j
avax.script
) – “dns” – resolve dns records – “url” – load values from urls, including from remote servers Applications using the interpolation defaults in the affected versions may be vulnerable to remote code execution or unintentional contact with remote servers if untrusted configuration values are used".Ulteriori risorse
- GHSL-2022-018: Arbitrary Code Execution in Apache Commons Text - CVE-2022-42889
- Text4Shell, a remote code execution bug in Apache Commons Text library
- Apache Commons Text RCE: Resemblance to Log4Shell but exposure risk is ‘much lower’
- CVE-2022-42889: Keep Calm and Stop Saying "4Shell"
- CVE-2022-42889 (NVD)
- CVE-2022-42889 (MITRE)
- Dockerized POC for CVE-2022-42889 Text4Shell
Made with ❤ for Inforge