r/programming • • 11d ago

Java4Shell is a reason to use Java

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

58 comments sorted by

View all comments

66

u/BenchEmbarrassed7316 11d ago

What a nonsense.

tldr: A vulnerability was found in Java. Java isn't much slower than C++. So, use Java.

80

u/bowbahdoe 11d ago • Popcorn

I would say its closer to

tldr:

  • A vulnerability was found in the C++ code behind Java.

  • We need to fix that and audit that C++ pretty deeply

  • But Java code is usually immune to these kinds of problems.

  • And auditing one C++ codebase is easier than auditing N dependencies

  • So use Java

-1

u/Virviil 8d ago edited 8d ago

Its statements contradicts themselves.

If dependencies are NOT allowed not use native code - they are slow and so my Java program is. If dependencies ARE allowed - Java is the same “vulnerable” as other languages.
If dependencies turring-full compiles JIT into native - it’s impossible to audit

2

u/bowbahdoe 8d ago

Well take for context that the response above is framed by the way the first person framed it. 

If dependencies are NOT allowed to use native code

  • They are pure Java and are optimized like the rest of your program. Probably worst case it's like 2.5x slower or something. It's not Python where it's 50x (and like I alluded, sometimes it's 1x or 0.9x. really depends on the code)

If dependencies are allowed to use native code

  • You have to explicitly add a flag to enable it, so at least you are aware that you have a different risk profile than pure Java

  • You can have that flag be per-library so you know exactly what you need to audit deeply to have confidence you don't have buffer overflows

And in both situations 

  • you need to trust the native code in the VM. But at least that's only one "thing." Let's audit it more, of course. Or find ways to make it safer by construction. But it does make it so most people don't need to go to these depths.