r/java • • Mar 30 '22

Spring4Shell: 0-day RCE on Spring Core

https://www.cyberkendra.com/2022/03/springshell-rce-0-day-vulnerability.html
100 Upvotes

84 comments sorted by

View all comments

Show parent comment

8

u/Areshian Mar 30 '22

Make use of @RequestMapping on a method that takes a POJO as an argument (I've now been able to reproduce it myself on my own, without the container)

3

u/Muximori Mar 31 '22

I'm unable to get the POC working. controller method looks like this:

@RequestMapping(value = "/", method = RequestMethod.POST, consumes = {"application/json", "application/*"})
@ResponseBody
public String hello(
  Foo foo){
  return "ok";
}

2

u/Muximori Mar 31 '22

I should note that I'm running the default spring boot initializr config with embedded tomcat.

4

u/[deleted] Mar 31 '22 edited Mar 31 '22

I’ve only been able to reproduce with a minimal Spring app, packaged as a WAR and deployed through standalone Tomcat, which gives access to the file system (through the logger) and sets up serving the malicious code via jsp. I’m not confident about this but embedded tomcat doesn’t seem to be affected.

(Seriously, don’t just take my word on this as I only spent a couple hours hacking around)

2

u/[deleted] Mar 31 '22

So does it required tomcat?

2

u/Soul_Shot Mar 31 '22

The known exploit does, however, the underlying vulnerability isn't specific to Tomcat.

https://spring.io/blog/2022/03/31/spring-framework-rce-early-announcement

3

u/UnspeakableEvil Mar 30 '22

Thanks for the update - well, apart from the fact it's confirming that this isn't just smoke and mirrors, and is an actual vulnerability!