CVE explainer

Spring4Shell (CVE-2022-22965)

, 3 min read

CVE-2022-22965 is a remote code execution flaw in the Spring Framework, reached through data binding. It arrived four months after Log4Shell and was quickly nicknamed Spring4Shell. It was serious, NVD rates it CVSS 3.1 9.8, but the known exploit needed several conditions to be true at once. Knowing those conditions was the fastest way to triage.

Data binding, briefly

Spring MVC and Spring WebFlux can fill a Java object straight from request parameters. A parameter named name sets the object's name property, and address.city sets city on the nested address. That nesting is the problem. Every Java object has a getClass() method, so a parameter starting with class. walks from your form object into the Java class machinery.

Spring had blocked that path in 2010, after CVE-2010-1622 abused class.classLoader. JDK 9 then added modules, and every class gained a getModule() method. Spring still let a request walk class.module.classLoader, which reached the class loader by a route the old block didn't cover.

How the public exploit worked

On Apache Tomcat, the class loader leads on to Tomcat's own objects, including its access-log valve. Microsoft's write-up of the public exploit describes it changing that valve's settings through request parameters:

  1. Point the access-log directory at the web application's root.
  2. Set the file suffix to .jsp.
  3. Set the log pattern to a small piece of JSP code.
  4. Send a request so the "log line", now a JSP web shell, is written.
  5. Request the new .jsp file and run commands through it.

The conditions

The Spring team's announcement of 31 March 2022 lists what the known exploit needed:

  • JDK 9 or later
  • Apache Tomcat as a standalone Servlet container. Spring also named Payara and GlassFish as affected containers.
  • Packaged as a traditional WAR. Spring Boot's default executable JAR wasn't vulnerable to this exploit.
  • `spring-webmvc` or `spring-webflux` as a dependency
  • Spring Framework 5.3.0 to 5.3.17, 5.2.0 to 5.2.19, or older unsupported versions

Spring also warned that the underlying flaw was more general, and other exploit paths might exist. Failing one condition lowered the priority. It didn't close the issue.

Fixes and workarounds

Fixed in Spring Framework 5.3.18 and 5.2.20, shipped with Spring Boot 2.6.6 and 2.5.12.

If you couldn't upgrade Spring right away, the announcement listed three workarounds:

  • Upgrade Tomcat to 10.0.20, 9.0.62 or 8.5.78, which Spring said closed the attack vector on Tomcat's side.
  • Downgrade to Java 8.
  • Tell WebDataBinder to reject class-related fields:
@InitBinder
public void setAllowedFields(WebDataBinder dataBinder) {
    String[] denylist = new String[]{"class.*", "Class.*", "*.class.*", "*.Class.*"};
    dataBinder.setDisallowedFields(denylist);
}

Exploitation

NVD published the CVE on 1 April 2022. CISA added it to the Known Exploited Vulnerabilities catalogue on 4 April 2022, which means there was evidence of active exploitation within days.

Why it matters beyond Spring

  • Check the conditions before you panic. Spring4Shell and Log4Shell had similar scores but very different blast radii. An inventory that records JDK version, packaging (WAR or JAR) and container per service answers "are we exposed?" in minutes.
  • Framework conveniences are attack surface. Data binding, deserialisation and reflection all turn user input into object graphs. Binding to explicit, allowlisted fields, or to purpose-built request objects, is safer than binding to domain objects.
  • A platform upgrade can reopen an old hole. The Spring block had worked for years. The JDK 9 module system created a route around it. Major runtime upgrades deserve a security re-test, not just a functional one.
  • Fix at more than one layer. Spring, Tomcat and the JDK version each offered a way to break the chain. When one fix has to wait, look for the next layer down.

Sources

Start with a $500 audit.

See exactly where you stand. Actionable findings in a week.

The full report and debrief call. Delivery in 5–7 business days.