by ajross · 1mo ago · 0 comments
> When I think about "we're very fucked" CVE10s on the Internet, I think of the following vulnerabilities:
Which is IMHO a really good list. It's also, I think, important to note that every single one of the four items is not at all a memory safety bug. They're all logic, at various levels of an interpretation stack.
I think a lot of folks with their heads down in the security world might have expected the opposite. As is often the case in engineering, the smartest people end up obsessing over solving the less important parts of the problem.
(And sure, there are escape hatches - like Python has "recv_into" that could be used to implement heartbleed if you are really inclined to - but this would not be a realistic python program. In python, even with buffer reuse, you'd be using memoryview or similar that can't have a heartbleed problem)
TBH this would have happened if they used the same approach in any language, and wouldn't have happened if they used a different approach in C.
They wrote their own allocator. That's the problem. If they didn't use their own allocator valgrind or sanitisers would have caught this.
If they used this approach in any other language, like Java or C#, heartbleed would still have happened.
Every language has a preferred way to deal with things. In C, it's raw pointers, which are very error prone. Other languages have something better. For example, if you were to implement custom allocator in C#, would you return raw pointer? Or maybe base array + offset pair? Of course not, you'd choose a Span or Memory, and those are not prone to buffer overruns.
I repeat the claim: This isn't where you should be spending your tokens and it's not the hole through which the apocalypse will arrive. People fighting over Rust will be the first to fall when the auth-exploiting robots arrive.
Edit to address the specific example: OpenSSL would never have been written in .NET in the first place, being very performance/hardware sensitive (there's a bunch of platform assembly in TLS implementations) and by its nature designed to be needed by all/almost-all software on a system. The argument everyone would reach for here would be Rust. But in Rust, the same logic that led to the custom allocator would probably produce an unsafe-based equivalent (which is true for almost all heavily optimized rust, sort of a dirty secret).
That's irrelevant - had they used the same approach in C#, heartbleed would still have happened. The language here makes no difference because the error is in the approach they chose which bypassed any ability for tooling or language features (such as found in C# and similar) to prevent reuse of deallocated memory.
(I'm not cosigning the analysis in this blog post. I think "I haven't seen a PoC I could get working" is not the evidence this author seems to think it is.)
[1] My favorite example in this kind of argument just because it's so obviously understood and non-technical. All the pedantry in the world wouldn't have fixed that, it was the combination of a bunch of correctly implemented and useful features.
One of the exceptions (with regards to web facing attack surface in a memory unsafe language) is that people still use OpenSSL, which has a terrible history of memory unsafety, including the cited heartbleed.