Skip to content


The Spring4Shell (CVE-2022-22965) critical severity vulnerability in Spring Framework allows remote code execution (RCE). At time of writing, it can be exploited only in very specific scenarios. However, Spring have made a patch available (Spring Framework version 5.3.18 and 5.2.20) and I strongly advise you to take them, even if you’re not running the exploitable setup.

How it works

LunaSec has published an excellent analysis of the vulnerability. It works by exploiting a @ModelAttribute annotated parameter of an MVC Controller:

public class HelloController {

    public String greetingSubmit(@ModelAttribute Greeting greeting, Model model) {
        return "hello";


Query parameters passed to /greeting are used to create the instance of the Greeting POJO using bean introspection. Unfortunately, Spring’s introspection mechanism can access not only the values exposed by the POJO getters and setters but values of the superclass (Object) including (get)Class. If we can access the Class object, we can traverse to the ClassLoader and cause some damage.

Exploiting Spring4Shell

LunaSec has published a proof of concept based on work by reznok. It’s a very simple Spring Boot application built with Maven and deployed into a vulnerable Tomcat 9 using Docker. They’ve even packaged the attack as a nice Python script.

The attack script just sends a GET request to the vulnerable application with some wacky looking parameters:!%3D-1)%7B%20out.println(new%20String(b))%3B%20%7D%20%25%7Bsuffix%7Di

This creates a new JSP on the server that executes the value of its cmd parameter. The result is very nasty:

shell.jsp?cmd=ls /

Am I vulnerable?

The reznok proof of concept specifically requires the following to be exploitable:

  • Unpatched Spring Framework (version 5.3.17 / 5.2.19 or anything older)
  • spring-mvc or spring-webflux
  • JDK 9 or higher
  • The application is deployed as a war in a standalone (unpatched) Tomcat.

However, new exploit methods may be discovered for this vulnerability so you should upgrade Spring Framework to a patched version (5.3.18 or 5.2.20) as soon as possible. There is also a patch in the latest Tomcat releases (10.0.20, 9.0.62 or 8.5.78) which you should also take if that’s how you deploy your apps.

Currently, no exploit has been discovered when deploying a Spring Boot executable JAR. Again though, it’s possible an exploit may be discovered later and it’s always good practice to keep on top of all security patches.

Published inSecuritySpring Boot

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *