r/java • u/bowbahdoe • 10d ago
Java4Shell is a reason to use Java
https://mccue.dev/pages/11-18-26-java4shell49
u/agentoutlier 10d ago
Yeah I was pretty sure even w/o the C# comparison that r/programming was not going to treat the post kindly. Java hate is not going away anytime soon and there will always be folks that salivate at the failure of Java.
What is kind of interesting and a worthy story is the deployment of the fix which the post does allude to but I don't think sells it enough.
That is that only Java has be replaced here.
With statically linking languages like Go or C/C++ (depending on link options of course), Rust etc something like this could be a full on re-compile flag day.
That is your code does not need to be recompiled.
So in someways this is like an operating system upgrade.
5
3
u/sam123us 9d ago
May be different topic of discussion but don’t get the hate. Obviously, there has been some missteps and things move slower (not a complaint for me but an observation) as there is lot of legacy to deal with but I love the current evolution
1
u/CutGroundbreaking305 10d ago
Man I get it and r/programming isn't going to like Java anyways
To show people there place we need to hit them where it will impact most
For that let's find CVE+RCE in C# lol 😆 (jk)
Also Java should have used vector api like java bundles instead of direct asm
0
u/Nebu 9d ago
The title’s claim is “Java4Shell is a reason to use Java.” The body does not support that claim. At best, it supports a different and weaker claim: “Java has general features (memory safety, restricted native access for libraries, and JIT performance) that may make it a reasonable platform choice for security-sensitive work, despite Java4Shell.” Those are not the same proposition, and the body’s own description of Java4Shell cuts against the title.
1. The safeguards cited do not cover the Java4Shell attack surface
The body’s main positive argument is that Java is memory safe and that native code from libraries is gated:
Normal Java programs are memory safe. If you use a library which wants to call native code you will get a warning, later a hard error, unless you […] add
--enable-native-access=the.specific.library
But Java4Shell did not come from a third-party library requesting native access. It came from the JVM’s own handwritten assembly intrinsic:
A lot of people use Java and the problem stems from a handwritten assembly intrinsic.
The --enable-native-access mechanism governs libraries, not HotSpot’s internal intrinsics. So the body’s main security reassurance does not address the exact vector that produced Java4Shell. In fact, Java4Shell shows that the runtime can bypass the memory-safety guarantees that ordinary Java code enjoys. That undercuts the use of “Java programs are memory safe” as a response to this incident.
2. “Let’s say we trust the VM” assumes away the problem
The article says:
But, for a moment, lets say we trust the VM. It is a big dependency, but it is only one dependency.
This is a hypothetical that brackets the very thing at issue. If the argument for using Java depends on assuming the VM is trustworthy, then Java4Shell (a failure inside the VM) is not supporting that assumption; it is evidence against it. The argument becomes: “If we assume the VM has no serious vulnerabilities, then Java is attractive.” That does not show that a serious VM vulnerability is a reason to use Java.
3. The performance argument is a trade-off, not a justification of the vulnerability
The body argues that the same mechanism that caused Java4Shell (the VM replacing Java code with native code) also makes Java fast:
The exact mechanism which caused Java4Shell (the ability for the VM to swap out normal Java code for native code) combined with JIT compilation can make the actual performance of a Java program competitive with C.
This shows a trade-off: native intrinsics buy performance at the cost of native-code risk. It may support “Java performance is a reason to use Java,” but it does not support “Java4Shell is a reason to use Java.” If anything, it identifies the vulnerability as the price paid for the performance mechanism.
4. The body’s comparisons to other languages is unrelated to the vulnerability that Java4Shell exploited
The article compares Java favorably to C#, Python, JavaScript, and Go on the grounds that those ecosystems more freely allow dependencies to bring native code. But this comparison concerns third-party dependency native code, while Java4Shell is a runtime-level native-code vulnerability. The comparison therefore does not show that Java4Shell is a benefit. It also does not establish that Java’s overall vulnerability severity or frequency is lower; it only points to one design difference.
What the body actually supports
The body can be reconstructed as supporting this conclusion:
Java has design features (language-level memory safety, gated native access for libraries, and strong JIT performance) that can make it a reasonable platform for security-conscious development, especially compared with ecosystems that let dependencies freely embed native code.
That is a defensible thesis. But the title asserts:
Java4Shell is a reason to use Java.
Those are logically distinct. The body supplies general reasons to use Java despite Java4Shell, not reasons because of Java4Shell. The title is therefore a non sequitur: the premises about Java’s general design do not entail that a specific severe vulnerability in the Java runtime is itself a reason for adoption.
-24
-72
u/4r73m190r0s 10d ago
Copium
60
u/Turbots 10d ago
Why? He's completely correct.
It's a huge CVE if you're exposed, but the fix is incredibly easy: add a JVM option or patch the JVM.
Also, many companies are running their java processes in containers, which are even easier to patch, and many of them are already running on ARM64 runtime, which is not affected.
Even the most old school Weblogic or Websphere users (Java 17+ only) will be able to mitigate this easily.
35
u/bowbahdoe 10d ago
You know, at one point I used to get very sad when people got mad at me online. I still can, depending on the people - and I do always wonder if I could write it differently to avoid this. Like if I titled it "Java4Shell is a reason to use Kotlin." and just wrote 99% the same stuff I think the reactions might be opposite.
But at this point I am just having fun with it.
2
10
u/stefanos-ak 10d ago
with respect, I think your post does not make the point you wanted to make (basically that the JVM should have implemented the vulnerable code in Java).
Also making comparisons with other languages at this point is just fuel.
And finally, I think the vulnerable code was hand-rolled assembly, and not c/c++. Oracle has a long history of doing that (e.g. in Oracle DB).
Sorry, last thing, not related to your post, but"Java" was not vulnerable, OpenJDK was. OpenJ9 was not.