Skip to content
RCE Write-up Advanced

Anatomy Of spring4shell Cve 2022 22965

The patch for an older Spring parameter-binding flaw only blocked the classLoader property by name, so a new path through the JDK 9 module system reached the same Tomcat class loader. An attacker could overwrite Tomcat access-log settings and write a JSP file into the web root, leading to remote code execution.

Yani Follow

Published on infosecwriteups.com

On March 29, 2022, a critical remote code execution vulnerability was disclosed in Spring Framework, a very popular open-source framework for Java. This vulnerability was designated as CVE-2022–22965, and it stems from the patch to fix another remote code execution in 2010 which was assigned as CVE-2010–1622.

Yani, on infosecwriteups.com

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

Likely the earlier fix used a name-based blacklist that only denied the classLoader property, so a different property path (class.module.classLoader) still reached the Tomcat class loader and its writable settings.

Impact

An attacker could write a JSP file into the web root and achieve remote code execution, but only where Tomcat is the servlet container and the application runs on JDK 9 or later.

What the attacker needed

Apache Tomcat as the servlet container; JDK 9 or later; Spring parameter binding in use; No authentication stated in the text

The fix

It was fixed in Spring Framework 5.3.18 and 5.2.20 by replacing the blacklist with a whitelist that only allows safe Class properties.

How it was found

  1. Send a request whose parameters bind to the Tomcat access-log valve settings through the class loader path.
  2. Set the log pattern to the web shell code and the suffix to a JSP extension.
  3. Set the log directory to the web application root and choose a file prefix.
  4. Clear the date format so the log file name does not rotate.
  5. Request the resulting JSP file so the server executes the code.

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.

Spring automatically copies values from a web request into fields of Java objects. The old fix blocked one specific field name, but a new route through Java's module system reached the same dangerous object. By changing Tomcat's log file settings, an attacker could make the server write a file containing their own code, which the server would then run.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

More by Yani

View all

4 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.