Hacker News new | past | comments | ask | show | jobs | submit
So the recent RCE wave seems to be people finding more single byte overflows and such, but reporting them as RCEs because AI can do the tedious grunt work of finding the rest of the vulnerability chain.

If any single byte overflow can be converted into an RCE with minimal human effort then we have no choice but to prove the whole software stack is memory safe.

It's important to note that Java, like Rust, is generally seen as a memory safe language. But it has bits of assembly, just like Rust has unsafe blocks, to handle some operations. Hence the Java2shell recent vulnerability. Granted Rust may have less need for them and more facilities to audit them, but it is not by itself a panacea that will fix all memory issues. In essence, there is no software stack that is fully memory safe, it is more a matter of restricting the memory unsafe parts in fewer, more scrutinized, better contained sections.
Because safe Rust is so constrained, Rust relies on unsafe much more than Java, and their need for intrinsics is about the same (although Java lets you turn off individual intrinsics at runtime).
Tons of production Rust systems use very little unsafe. I've been writing production Rust since 2015, and in that time, I wrote maybe 30 lines of unsafe production code. (Most of it in Tokio primitives.)

Now, in web-facing systems, the biggest concern is the low-level crypto libraries, which need to be written in assembly to avoid timing attacks. These (and related libraries) have seen multiple security advisories in the past year, some related to unsafe (I think?) and some related to logic errors. But overall, those advisories have mostly been lower priority, or affected mostly niche use cases.

If you only have a small amount of unsafe code, then it's possible to audit it more aggressively. And there's only a limited amount of space for bugs. So what I would expect for Rust is a trickle of security bugs, many of them niche or low severity, that slows down with time.

Do you use core abstractions like Vec, String, Box, Arc, and Mutex? If so, those are built using unsafe code internally.
Do you run on CPUs based on the von Neumann architecture?

If so, those are built on unsafe operations internally.

Safety is a lot more complicated than "whether it is in an unsafe block of code in Rust". If you insist that an unsafe primitive can not be handled well enough to become "safe" by some definition of safe then you collapse the entire programming language hierarchy into "everything is completely unsafe". Which may, from a certain point of view, be true, but isn't a particularly useful classification scheme.

Arrays in Java (a loose equivalent of `Vec`) is a runtime primitive and implemented in a memory-unsafe language. References (loose equivalent of `Box` and `Arc`) as well. Java's `synchronized` (a loose equivalent to `Mutex`) as well. Those are not good counterexamples.
Unsafe rust is still safer than normal C.
Lets compare what's inside this Ruby bug, a C function rb_str_casemap which is 40-50 lines of C fiddling with pointers and calling into macros that presumably are familiar to Ruby developers but opaque to an outside viewer. Is it fixed? I guess so but I can't see very well to be sure, it was counting stuff before and now it is being more careful, I hope it's correct this time.

... against str::to_uppercase the Rust function which has a single line of unsafe code, with a two line rationale provided to explain why it's OK to do this. As a subject matter expert I agree with the rationale. LGTM.

Edited: We're talking about uppercase, they're basically mirrors, but we should choose the uppercase function.

This sub-thread in the conversation is about Java, so comparisons to Ruby aren't what's relevant. Here's part of the relevant GP comment.

> It's important to note that Java, like Rust, is generally seen as a memory safe language. But it has bits of assembly, just like Rust has unsafe blocks, to handle some operations.

And according to sources like CISA and the NSA [1], Java is considered memory safe. Furthermore, Rust has been found to have some memory safety issues as well [2]. I think the point to get across is that yes, Rust can help eliminate a very large set of memory safety bugs, but it's prone to issues that other generally considered memory safe languages also have: at some point to do useful work there are going to be unsafe operations. The surface area might be much smaller, so you're likely better off using a memory safe language if you can help it, but it's not a panacea for having layers of security, especially since it means any issue found is likely to affect a large swath of code written in the language because it's in a load bearing area of the language ecosystem.

[1]: https://www.nsa.gov/Press-Room/Press-Releases-Statements/Pre...

[2]: https://www.microsoft.com/en-us/security/blog/2026/11/09/for...

Java's String::toUpperCase appears to be quite a lot more complicated than the Rust but it is at least all Java and thus without careful inspection I can assume it's memory safe.
I didn't say there's a lot of unsafe (by whatever measure you consider that to be). I said there's a lot more than in Java.
The JVM is written in an unsafe language. That's where these unsafe calls occur. Clients of these APIs have no control there. Java code itself is safe.
> That's where these unsafe calls occur.

No, it's not. A relatively common case for unsafe in Rust is in data structures. The data structures in the Java runtime are all written in Java and has almost no use of unsafe (there might be a few, but not becsause of language limitation, but because of initialisation order).

As for the JVM, much of it is a compiler. It doesn't matter what language it's written in, as it generates machine code. Indeed, the vulnerability disclosed yesterday was in a compiler intrinsic, but those are just as common in Rust.

Other than that, the other big piece in the JVM is memory management, and it does, indeed, use C and C++ for memory management, but Rust also uses C (the various implementations of malloc/free in whatever runtime the Rust program is using; BTW, some popular malloc/free implementations are almost as big as Java's most complicated GC).

As for native C/C++ libraries (outside the JVM itself), Java programs do use some, but generally not more than Rust programs.

Not accurate. Most datastructures that use unsafe in Rust are primitives; `Box`, `Vec`, `Rc`/`Arc`, `HashMap` and `BTreeMap`. Of those, only the equivalent to `HashMap` and `BTreeMap` are written in Java, and they can be written in safe Rust as well if you're willing to give up some of the performance (e.g. always initializing - thing that happens in Java as well). More complex data structures (e.g. graphs) can and often are implemented without unsafe at all.
loading story #50566723
> BTW, some popular malloc/free implementations are almost as big as Java's most complicated GC

I'm pretty sure that's incorrect by a wide margin, and that all non-nop GCs java has are as large as at least some popular allocators.

loading story #50566699
Not all JVM implementations, there are multi-circular implementations in Java, starting with JikesRVM almost 20 years ago already, whose work with the MMtk memory allocator was later inspired a Rust version thereof.
>which need to be written in assembly to avoid timing attacks

Assembly provides no timing guarantees. You will want something higher level built on top of assembly that can guarantee it for a specific processor.

You don’t think there’s some intrinsic code in llvm that would be generating assembly that doesn’t match Rust’s safety rules?
We know LLVM has miscompilation bugs. Sometimes it is practical for Rust to fix those bugs and so it carries patches for LLVM, but in some cases LLVM IR semantics are just incoherent nonsense. An example of the former (Rust carries patches): LLVM got confused about discriminants when Rust uses niches, when the niche bit pattern used was usually right next to the legitimate values for a type the bug in LLVM caused little notice, it could corrupt data but probably not. However Rust changed which bit patterns to prefer here, so e.g. None for Option<char> went from 0x0011_0000 to the bit pattern 0xFFFF_FFFF and now that same LLVM bug caused crashes as values which had previously been very slightly wrong were instead hugely wrong.

For an example of the latter (LLVM is just nonsense): LLVM still today has a bug found years ago where pointer provenance (a legitimate but hard to think about idea for optimising compilers) accidentally leaks into integers, and so LLVM can end up with two integers a, b which it believes are not equal and yet a - b == 0. Boom.

Take a peek into the Rust stdlib method implementations. The lang is built on a house of "unsafe".
So is the JVM, and?
loading story #50579292
Rust is as vulnerable as the Java issue l, if you use simd you're in the same boat.
Actually, Rust can have fully safe SIMD (Java too, but it's still in preview AFAIK).
That's just not correct
loading story #50560463
we have like a million lines of rust in production right now and zero unsafe.
is there a java runtime not written a memory unsafe language? because if so, by your own standards java is entirely unsafe
> Because safe Rust is so constrained, Rust relies on unsafe much more than Java, and their need for intrinsics is about the same (although Java lets you turn off individual intrinsics at runtime).

This is silly. Rust also has tooling for dealing with unsafe - tools for proving unsafe code, tools for verifying unsafe code, tools for fuzzing it, etc.

Java, and other languages like it, often drop into unsafe code where it's far weirder and less supported because they have to because the languages are too slow to do the work they want to do.

And obviously you have all of the complexity of a massive, JIT'd runtime written in C++.

loading story #50562295
OP didn’t say anything about Rust, by the way. This post comes off as being defensive about a point nobody made.
…it was a metaphor to agree with the OP’s point.

Not everyone on the web is looking to start an argument; some people use literary devices to reinforce their point. If anyone is defensive about a point nobody made, it’s you.

Yeah, "memory safe" goes out the window if you prefer to implement parts in assembly. This is where portable SIMD (e.g. the Java vuln was from SIMD), which is abstracted & safe but not necessarily as performant as it could be, is becoming a more reasonable trade off.

Of course I'm not sure how much it counts to be "using a memory safe language" when you have to call put to unsafe code anyways. I.e. just because the library you'd like to use is C but the rest of your project is Rust doesn't mean you're really using a me ory safe language, it means you're sometimes using one. We have a long way to go before environments allow using memory safety fully I think.

loading story #50571127
loading story #50579274
loading story #50560228
loading story #50559293
loading story #50561384
loading story #50558531
I like your comment since it points out that we need to enforce the memory situation—but it doesn’t prescribe Rust is the only solution.
loading story #50574766
loading story #50571136
From my understanding it's only a single byte overflow if your payload only contains a single ß.
loading story #50560698
From the pseudocode it's always a single byte. Desyncing before the end of the buffer is fine. Desyncing at the very end causes the single byte overflow.
loading story #50568101
This is bad news for C/C++
loading story #50558852
This is bad news for computer industry. See the recent Java4Shell.
because the assembly for the base64 decoding was handwritten, the paren't comment is still valid
loading story #50558442
Good news for the computer industry employees though.
loading story #50558537
loading story #50558157
I don’t think it’s a single byte at least not in this case, you’d put your shell code into a string and then use enough double S to push it where it needs to go. I’m assuming each double S pushes one more byte.
loading story #50559435