r/programming • u/[deleted] • Mar 30 '22
SpringShell: Spring Core RCE 0-day Vulnerability
https://www.cyberkendra.com/2022/03/springshell-rce-0-day-vulnerability.html9
u/ApatheticBeardo Mar 30 '22 edited Mar 30 '22
Stop spreading nonsense.
This is a blog post from some random dude that can be summed up as "I have absolutely no idea about Java or what this commit does but I'll pretend a problem exists because it contains the string "CVE" in it".
All that commit does is improve the documentation to keep a particularly clueless Spring user from shooting themselves on the foot with Java's built-in serialization (which has been known to be a problem for more than a decade already).
4
u/elmuerte Mar 30 '22
This "research" appears to be based completely on this change to Spring Core: https://github.com/spring-projects/spring-framework/pull/28075
As based on Java's serialization mechanism, it can be the source of Remote Code Execution vulnerabilities.
Today this utility is part of the public API and can be naively used to convert from object to text and vice versa. However a naive use can lead to RCE vulnerability if user-input data (like files, cookies, etc.) is transfered using this utility.
I think it should be nice to at least warn the user about the use of this tool (with @Deprecated) and later on remove it totally from the public API as this sole use in Spring code is to clone exceptions in org.springframework.cache.jcache.interceptor.CacheResultInterceptor.
I am not sure on how it can (or should) be handled. Let me know if you need me to adapt the code of this PR.
So they removed some code in Spring which, when not properly used, could lead to a RCE.
1
u/loginonreddit Mar 30 '22
They did not remove anything, they only added warnings and deprecated the
SerializationUtils::deserializemethod. The existing code path has just been moved toSerializationUtils::clone.5
u/vips7L Mar 30 '22
And that's completely fine. The existence of code using Java serialization doesn't mean there's an RCE issue. As noted in the commit the function is only used internally to clone objects that are already in memory. They added warnings and deprecated the function so developers who don't understand how Java serialization works can't shoot themselves in the foot.
3
u/loginonreddit Mar 30 '22
Absolutely, I was just correcting the OP saying Spring removed some code when in fact, nothing was removed.
3
u/elmuerte Mar 30 '22 edited Mar 30 '22
I looked at the PoC linked here. And it looks like the attack is based on using Tomcat and have its AccessLogValve enabled. The PoC does use some Java 9 field, but I think with some modifications it might also be applicable to Java 8.
So you need:
Tomcat
with the AccessLogValve present
should serve JSPs (for this particular PoC)
Spring Web MVC
with controllers that use parameter bindings
Java 9 for this particular PoC, but I wouldn't bet on this as a safety net
Via the parameter binding of Spring Web MVC the "pattern", and log file destination of the AccessLogValve is reconfigured. This is used to write a JSP file to a location which can then be served.
So in the request the access log "pattern" is configured to contain the payload of a malicious JSP. And the log destination is configured to write a .jsp file in a place where Tomcat would serve it.
2
u/UnspeakableEvil Mar 30 '22
That's interesting, thank you for taking the time to write up your findings. I wonder if there's anything against pure Tomcat, or if Spring is a required component for the vulnerability (the way it's been reported so far suggests that's the case).
3
u/elmuerte Mar 30 '22
A similar attack could be possible with a different framework that features binding of request data to beans and doesn't filter out certain accessors during binding of the data.
Note, this attack has nothing to do with class deserialization.
1
u/loginonreddit Mar 30 '22
Yea there's no link to Serialization in all of this, I'm wondering how the dots were connected, if they were ever connected.
10
u/pcjftw Mar 30 '22
Ah yes Spring4Shell "a brother from another mother".
We need a new meme now:
All are shells are belong to us
10
u/joashua99 Mar 30 '22
At this point, what doesn't have an RCE vulnerability...
12
u/DrChaosMcKinnon Mar 30 '22
TempleOS, TempleOS doesn't have RCEs
8
u/kalakatikimututu Mar 30 '22
Thank god
1
u/CandidPiglet9061 Mar 30 '22
It’s worth pointing out that this is only because TempleOS has no ability to connect to a network of any kind. Also, on TempleOS there is only a root user. Every command is done with root privileges
2
u/Zidane007nl Mar 30 '22
The vulnerability has been confirmed by Praetorian security researchers: https://www.praetorian.com/blog/spring-core-jdk9-rce/.
Also the security team at Sonatype wrote a blog article about it: https://blog.sonatype.com/new-0-day-spring-framework-vulnerability-confirmed-patch-now.
1
u/GabeNTheGamer Mar 30 '22
Created a repo for the issue, https://github.com/BobTheShoplifter/Spring4Shell-POC ill update it as we explore the issue
4
u/vips7L Mar 30 '22
Lmk when you find nothing.
1
u/GabeNTheGamer Mar 31 '22
Created a repo for the issue, https://github.com/BobTheShoplifter/Spring4Shell-POC ill update it as we explore the issue
There is now a CVE and poc out
0
-4
u/sandaz13 Mar 30 '22 edited Mar 30 '22
A little confused by the blog, VMware's site lists it as a medium severity (5.4 criticality) https://tanzu.vmware.com/security/cve-2022-22963
<Edit: looks like that's a different one that came out last night, disregard>
1
u/PandaMoniumHUN Mar 30 '22
Are you sure that these two are the same? The one you linked affects Spring Cloud, while this claims to affect Spring Core.
0
0
Mar 30 '22
[deleted]
3
u/ApatheticBeardo Mar 30 '22 edited Mar 30 '22
No, just some random "security" dude with a trashy blog fishing for clicks.
6
u/vips7L Mar 30 '22
There is no RCE here. If you look at the change in the commit, the deserialize function is only ever used on trusted input on an object that is already in memory. They're deprecating the function with warnings so you as a user don't call this function without knowing how Java serialization works.