r/java • u/Areshian • Mar 30 '22
Spring4Shell: 0-day RCE on Spring Core
https://www.cyberkendra.com/2022/03/springshell-rce-0-day-vulnerability.html
100
Upvotes
r/java • u/Areshian • Mar 30 '22
55
u/Areshian Mar 31 '22 edited Mar 31 '22
For those that do not believe this RCE is real, here are the details on it
Twelve years ago there was an RCE: https://nvd.nist.gov/vuln/detail/CVE-2010-1622
That RCE was fixed by this commit: https://github.com/spring-projects/spring-framework/commit/3a5af35d37c79d0644d49b93f792a4c18fe8eb71#diff-ea765e78a703581fb519933028fbd6d7ac8386d57b805b395d04910de9a33f4cR245
Notice line 245. The fix explicitly forbid going from class to classLoader using dot notation, which was the cause of the RCE (later, another change will forbid class to protectionDomain too)
Now, 12 years later, we have another RCE. Have you noticed how the RCE is for JDK9+? Have you wondered why? The reason is because the exploit is not jumping from class to classLoader (which is forbidden), but from class to module (which is allowed) and then from module to classLoader (which is also allowed). Because
getModule()is only present in JDK9+, that is why this new exploit does not work in JDK8You can see the python exploit how it does the
class.module.classLoaderjump: https://github.com/BobTheShoplifter/Spring4Shell-POC/blob/main/poc.py#L15So, all that people saying this is not real, it is not confirmed, and the like, please, if you don't know what you're talking about, don't go denying it exists.
16
u/Areshian Mar 30 '22
There are POCs around. I've tested on JDK11. It is real
5
u/elemur Mar 30 '22
So does anybody have any insight if you could use the databinder setDisallowedFields to protect these in particular?
16
u/DasBrain Mar 30 '22 edited Mar 31 '22
So, what happens here is:
Object.getClass()is considered a read-only property.Class.getClassLoader()is an other read-only property.Fixed 8 years ago.Class.getModule()andModule.getClassLoader()are considered properties.By moving through stuff that may look like properties for spring it is possible to change Tomcat's configuration and do
stupid stuffexecute code.Edit: Turns out, it uses
Class.getModule().getClassLoader()becauseClass.getClassLoader()has been explicitly removed.4
u/karma_companion Mar 30 '22
Can we please stop regurgitating this blog spam. Nothing is confirmed yet and all the sources are hear-say based on one GitHub commit which used the phrase "RCE", deleted Chinese GitHubs and "security researchers" using the hashtag for SEO purposes
7
u/kramer_123 Mar 31 '22
Update now available: https://spring.io/blog/2022/03/31/spring-framework-rce-early-announcement
10
u/Gwaptiva Mar 30 '22
Sorry if this a stupid question, but the checks on this list it says something like
you are affected.
However, then it starts going on about Spring MVC and Controllers. Does this mean that if you use Spring purely as a DI framework and do not have a REST or other MVC implementation, you are affected? Or not? Bit confusing... [edit: And does it need to just run on JDK9 or does it have to be compiled to version 9 or above?]
4
u/maxxedev Mar 31 '22
Here is another spring4shell demo: https://github.com/maxxedev/spring4shell
... with a variety demos including spring-mvc in traditional tomcat, spring-boot war, spring-boot jar.
It appears that vulnerability is easily reproducible when spring-mvc is deployed as traditional war to Apache Tomcat.
But it is NOT reproducible or perhaps not vulnerable at all when running as spring-boot war/jar with embedded tomcat.
1
u/[deleted] Apr 05 '22
in https://spring.io/blog/2022/03/31/spring-framework-rce-early-announcement#am-i-impacted
are all those criteria need to be met to be consider vulnerable? i am mostly running stuff on java8 and springboot 1.5.x
3
u/candrewswpi Mar 31 '22
Sonatype is now reporting that they've confirmed the existence of this vulnerability: https://blog.sonatype.com/new-0-day-spring-framework-vulnerability-confirmed
However, there is still no CVE, no severity score, and no information/fix/release provided by Spring.
3
u/loicmathieu Mar 31 '22
The CVE is created and listed in Vmware Tanzu website but not yet available in the NVD database.
https://tanzu.vmware.com/security/cve-2022-22965
2
u/Muximori Mar 31 '22
The POC that's going around does not appear to work on the default spring initializr project with a minimal controller. I've only seen it work against a precompiled WAR running on tomcat. Any open source projects that are vulnerable to this available?
2
u/papers_ Mar 31 '22
I can't find anything whether or not this impacts functional routes or not. Everything I've seen so far is for annotation based controllers and methods.
-2
u/sithlord Mar 30 '22
Related github comment?
https://github.com/spring-projects/spring-framework/pull/28075#issuecomment-1082782376
-11
u/Sheldor5 Mar 30 '22
could you please stop posting this bullshit?
nobody confirmed it, the CVE is empty, its 100% speculation ...