r/java • • 3d ago

Java4Shell is a reason to use Java

https://mccue.dev/pages/11-18-26-java4shell
89 Upvotes

16 comments sorted by

9

u/stefanos-ak 3d 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.

3

u/bowbahdoe 3d ago

(basically that the JVM should have implemented the vulnerable code in Java).

That wasn't the point I wanted to make. Stuff like this either has to be handwritten assembly or else some meta-circular stuff like Graal.

I wanted to say that people making their own code benefit from not needing to audit for things like buffer overflows in the same way as native code does. The worst case scenario isn't as bad (provided the JVM does its job)

And finally, I think the vulnerable code was hand-rolled assembly, and not c/c++.

Correct, and in another thread I call it "C++" just because I'm responding to someone who framed it that way.

"Java" was not vulnerable, OpenJDK was. OpenJ9 was not.

Correct, but in practice thats some inside baseball.

Also making comparisons with other languages at this point is just fuel.

I can always make it better, but there is a legitimate comparison to be made.

1

u/not-just-yeti 2d ago

I wanted to say that people making their own code benefit from not needing to audit for things like buffer overflows in the same way as native code does. The worst case scenario isn't as bad (provided the JVM does its job)

So I think I'm being a bit slow here (coffee hasn't kicked in yet), but are you saying that your point is: "Java is not to blame, keep using it. The problem lies with the JDK JVM authors, who didn't do their job."? (Alternatively, "JDK should publish their exact exposure to native code, so we can all add that to our audit trail"? Or is your main point "JDK's exposure is less than many other ecosystems"?)

5

u/bowbahdoe 2d ago

The 2nd, but more "The JDK gives you more ability to track and manage your exposure."

3

u/stefanos-ak 3d ago

your post makes a very poor job at that :(

the title is java4shell is a reason to use java, and nowhere in the article is there a reason for why this vulnerability is a reason to use Java. the reasons you list are related to Java, not java4shell.

If there is any reason that java4shell is a reason to use Java, it is because Java is decoupled from the JVM, and we have multiple JVMs, and only 1 was affected.

46

u/agentoutlier 3d 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.

3

u/sam123us 2d 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/rafark 1d ago

$language hate is not going away anytime soon and there will always be folks that salivate at the failure of $language.

0

u/CutGroundbreaking305 3d 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 2d 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

u/IncredibleReferencer 3d ago

ctibod.

cant tell if bot or drugs.

9

u/bowbahdoe 3d ago

Neither, today.

-72

u/4r73m190r0s 3d ago

Copium

60

u/Turbots 3d 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 3d 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

u/za3faran_tea 2d ago

Don't let the haters get to you. I enjoy your writings on Java!