Arbitrary Code Execution Affecting org.apache.commons:commons-text package, versions [1.5,1.10.0)


Severity

Recommended
0.0
high
0
10

CVSS assessment made by Snyk's Security Team

    Threat Intelligence

    Exploit Maturity
    Proof of concept
    EPSS
    97.12% (100th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk ID SNYK-JAVA-ORGAPACHECOMMONS-3043138
  • published 13 Oct 2022
  • disclosed 13 Oct 2022
  • credit Alvaro Muñoz

How to fix?

Upgrade org.apache.commons:commons-text to version 1.10.0 or higher.

Overview

Affected versions of this package are vulnerable to Arbitrary Code Execution via the StringSubstitutor interpolator object. Exploiting this vulnerability is possible when untrusted data flows into the StringSubstitutor.replace() or StringSubstitutor.replaceIn() methods.

Due to the nature of these methods as ones that process application data and not user input, a remote attacker would need prior access to a system in the affected environment positioned to supply such data.

Notes

The Nashorn scripting engine that can be used to exploit this vulnerability was available by default in JDKs up to 14.0.2. As of JDK 15, this vulnerability can only be exploited if another scripting engine has been added, such as JEXL.

Vulnerable lookups:

  1. script - executes expressions using the JVM script execution engine (javax.script)

  2. dns - resolves dns records

  3. url - loads values from urls, including from remote servers

PoC

final StringSubstitutor interpolator = StringSubstitutor.createInterpolator();
String out = interpolator.replace("${script:javascript:java.lang.Runtime.getRuntime().exec('touch /tmp/foo')}");
System.out.println(out);

CVSS Scores

version 3.1
Expand this section

Snyk

Recommended
8.1 high
  • Attack Vector (AV)
    Network
  • Attack Complexity (AC)
    High
  • Privileges Required (PR)
    None
  • User Interaction (UI)
    None
  • Scope (S)
    Unchanged
  • Confidentiality (C)
    High
  • Integrity (I)
    High
  • Availability (A)
    High
Expand this section

NVD

9.8 critical
Expand this section

Red Hat

9.8 critical