There is a lot of bad information out there about this issue. What I have gathered so far, is that this is actually a real problem, but it may not affect most configurations. This[0] seems to be the original vulnerability analysis, and this is the example vulnerable app[1]. The main issue seems to be, that since java 9, WebDataBinder can be abused to access the classloader via the "class.module.classloader", you migh…
> output an arbitrary JSP file So i appreciate that this is only an example of a gadget, and there are others that could be invoked in the same way, but ... > to the webapp root directory This is only possible if the application is running from an exploded WAR. That can happen if the developer deploys an exploded WAR - normal in development, extremely strange in production - or if the application server explodes the…
Spring Core on JDK9 is vulnerable to remote code execution
61–70 of 73 posts
Re: Spring Core on JDK9 is vulnerable to remote code execution
#62Earlier quoted context omitted.
JDK9+ is important because Spring already prevents access to `class.classloader`, but it can be worked around thanks to modules (i.e. `class.module.classloader` works).
Yes but there may be some other Gadget vulnerabilities in all those fields too. Also, you might be able to make an app OOM by setting big string values somewhere in there. It boggles my mind why this field is accessible at all and wasn't blocked in CVE-2010-1622.
Re: Spring Core on JDK9 is vulnerable to remote code execution
#63Fortunately very few companies of any size use jdk9+
Unfortunately you're wrong. While some companies haven't yet made the leap from 8 to 11, most have. You'll find that Java 8 support is being deprecated if not outright removed across the JVM ecosystem.
Re: Spring Core on JDK9 is vulnerable to remote code execution
#64Earlier quoted context omitted.
I'll ask my engineers to post the one he wrote. He did put more details into the article, so go check that. Here is a repo with a POC though: https://github.com/TheGejr/SpringShell
That’s not really a POC though. That’s not a Spring Application I can run and reproduce on. That’s just a py script.
Re: Spring Core on JDK9 is vulnerable to remote code execution
#65Earlier quoted context omitted.
LunaSec founder here. I can understand the suspicion. It's the right mindset to have when looking at CVEs, in general, because 99% of them are overblown. The first title I wrote for the blog post was "There is no vuln" but I was wrong. Only after I spent a few hours digging did my gut change my mind. In this case I wrote the post to discuss 2 different vulns. One was a confirmed RCE with a CVE and the other was a WIP…
The exploit PoC that is doing the rounds works on full tomcat, not embedded tomcat, so if your example vulnerable application is using embedded tomcat that exploit won't work on it without being tweaked. I've looked at it today as well, for most of the day. Embedded tomcat doesn't have a webapps directory, whereas the full version of tomcat does, so the PoC writes the webshell to webapps/ /tomcatwar.jsp and that is s…
Re: Spring Core on JDK9 is vulnerable to remote code execution
#66Earlier quoted context omitted.
JDK9+ is important because Spring already prevents access to `class.classloader`, but it can be worked around thanks to modules (i.e. `class.module.classloader` works).
Yes but there may be some other Gadget vulnerabilities in all those fields too. Also, you might be able to make an app OOM by setting big string values somewhere in there. It boggles my mind why this field is accessible at all and wasn't blocked in CVE-2010-1622.
Re: Spring Core on JDK9 is vulnerable to remote code execution
#67Earlier quoted context omitted.
> The main benefit is updating the webapps w/o restarting the server, itself. I've never had this work properly in the long term, to be honest. Restarts with the Jenkins plugin would randomly freeze and fail or there would be memory leaks after too many restarts, or weird errors about it not being possible to properly clear up the resources from previously exploded/extracted .war archives. Though i might have just be…
There are many things that must go right. Threads being the primary one - don't start threads, pretty much anything that can start threads (outside the webapp) have to guard for the CCL and the thread group at the very least. The entire app must have a clear start/stop lifecycle correctly implemented. Static registrations in non-webapp services must be removed, and/or those services must use weak references. The list…
Modern Java webservers (even 'enterprise' containers like JBoss etc) start up so quickly now there's not much to gain by not restarting them.
Re: Spring Core on JDK9 is vulnerable to remote code execution
#68Earlier quoted context omitted.
There are many things that must go right. Threads being the primary one - don't start threads, pretty much anything that can start threads (outside the webapp) have to guard for the CCL and the thread group at the very least. The entire app must have a clear start/stop lifecycle correctly implemented. Static registrations in non-webapp services must be removed, and/or those services must use weak references. The list…
While this is possible, it takes ages for an application to gracefully shutdown so any time you save not having to start up a new server is lost. And then you still have classloader, memory and thread leaks since you can't really prove they are absent unless you have 100% test coverage + load testing on every possible code path. Modern Java webservers (even 'enterprise' containers like JBoss etc) start up so quickly…
Those are trivially proven and diagnosed with memory dumps or even "jmap -histo"(incl. where the leak started). Zero test coverage for that needed. Some bugs were even in JDK where it'd start a new thread in a threadpool and copy all the CCL/Threadgroup/ACL and any inheritable thread local.
Re: Spring Core on JDK9 is vulnerable to remote code execution
#69Earlier quoted context omitted.
Any kind of writable reflection facility, and any kind of eval() should be added to the set of "unsafe" features.
At some point, mvc frameworks have to do some magic to dynamically load classes. This should be done at runtime, but can’t imagine it’s an easy problem to solve.
The solution is to explicitly specify every class that can be instantiated at compile time. Similar to how modern deserialization frameworks work. No code should be written that allows content from the network to explicitly specify arbitrary code to load and execute. E.g having a packet say and feeding the string “MyView” into some classloader, or dlsym, or whatever is asking for trouble. Feeding it into
switch (view.class) {
case “MyView”: return new MyView() … }
Results in a much less powerful primitiveRe: Spring Core on JDK9 is vulnerable to remote code execution
#70Earlier quoted context omitted.
At some point, mvc frameworks have to do some magic to dynamically load classes. This should be done at runtime, but can’t imagine it’s an easy problem to solve.
Not my field, but how can this be so? We had MVC in 1990 written in C or C++.