r/programming • • Apr 09 '14

Theo de Raadt: "OpenSSL has exploit mitigation countermeasures to make sure it's exploitable"

[deleted] — view deleted post

2.0k Upvotes

661 comments sorted by

View all comments

Show parent comment

-7

u/[deleted] Apr 09 '14

And yet you don't understand how this isn't simply a C/C++ issue then? I'm going to give you the benefit of the doubt here, and say you haven't really read much, especially considering you didn't even answer my question.

6

u/[deleted] Apr 09 '14 edited Apr 09 '14

I have yet to actually find a good explanation of what the heartbleed bug was caused by (Google only returns fluff pieces by the media). Do you have a link to the commit diff that fixes the bug?

Edit: According to this article, it was caused by a missing bounds check. Classic vulnerability that very few languages except for C would suffer from (since sane languages would throw an exception in this case).

I still re-iterate that I cannot trust software written in a language that permits egregious programming errors to allow exploits quietly by instead of failing in a predictable manner.

0

u/[deleted] Apr 09 '14

The synopsis is in the very article you are commenting on. You still have not read it apparently. So why are you commenting?

So years ago we added exploit mitigations counter measures to libc malloc and mmap, so that a variety of bugs can be exposed. Such memory accesses will cause an immediate crash, or even a core dump, then the bug can be analyed, and fixed forever.

But around that time OpenSSL adds a wrapper around malloc & free so that the library will cache memory on it's own, and not free it to the protective malloc.

These methodologies have been around for quite some time. OpenSSL decided to circumvent it for optimization purposes. Even though on 99.99% of platforms it doesn't matter.

12

u/[deleted] Apr 09 '14

I have read it, maybe it is you who are not understanding. The "countermeasures" are a workaround for the fact that C does not check array bounds accesses! They are not 100% guaranteed to work in all cases since system memory is returned in pages which might include several malloc()ed blocks of memory within them. Of course the caching was dumb and made the countermeasure less effective, and maybe it would have been caught sooner. But it does not negate the fact that C allows this kind of errant runtime behaviour to fall through without complaint!

-6

u/[deleted] Apr 09 '14

If I write unsafe code in C# and wave my dick around, am I free to blame the language? Because that's what it sounds like is going on here.

11

u/[deleted] Apr 09 '14

All C code is unsafe code. C programming is the art of intellectual dick waving.

-7

u/[deleted] Apr 09 '14

How is it the art of intellectual dick waving?

1

u/artee Apr 09 '14

He does, and is right that this is very much a flat memory model issue (of which C and C++ are by far the most important examples). I challenge you to reproduce any of these problems in Java, Smalltalk, Scheme, .NET (managed) or any functional language (Haskell, whatever you want).

And sure, you get exploitable VM bugs in return, that's true. But those can at least be fixed by just updating the VM and not all programs written against it.

4

u/[deleted] Apr 09 '14

He does, and is right that this is very much a flat memory model issue (of which C and C++ are by far the most important examples). I challenge you to reproduce any of these problems in Java, Smalltalk, Scheme, .NET (managed) or any functional language (Haskell, whatever you want).

Rust and ATS are memory safe without requiring a different memory model than C and C++. Their version of memory safety also includes preventing all data races. A garbage collector is not required for safety.

And sure, you get exploitable VM bugs in return, that's true. But those can at least be fixed by just updating the VM and not all programs written against it.

It's not possible to write a secure TLS implementation in these languages due to side channels.

-2

u/[deleted] Apr 09 '14

If I used unsafe code in Rust, can I still blame the language? If I made a conscious choice to use that unsafe code for performance reasons, and then got fucked for it, am I still allowed to blame the language?

Because that's exactly what is happening here.

It's not possible to write a secure TLS implementation in these languages due to side channels.

Here we go again, with your hypotheticals that have no basis in reality. I already gave you what you asked for yesterday and then you decided to nitpick my examples while not answering any of my concerns or questions

6

u/[deleted] Apr 09 '14

If I used unsafe code in Rust, can I still blame the language? If I made a conscious choice to use that unsafe code for performance reasons, and then got fucked for it, am I still allowed to blame the language?

C does not draw any bounds between safe and unsafe code, it's all unsafe. It's not capable of abstracting resource handling and buffer management to the point where it's not possible for the high-level code to get it wrong. It has no destructors, checked reference lifetimes, etc.

There is no way to opt-in to a safe subset of C, even expensive static analysers only catch a fraction of these bugs.

Here we go again, with your hypotheticals that have no basis in reality. I already gave you what you asked for yesterday and then you decided to nitpick my examples while not answering any of my concerns or questions

It's well known why writing most cryptographic algorithms in languages using a VM is infeasible without side channels... it's not a hypothetical.

-5

u/[deleted] Apr 09 '14

Being able to do and consciously deciding to circumvent default tooling are not comparable circumstances.

The OpenSSL developer/contributor made a bad decision and now people are trying to blame the language. Moronic.

As I have stated elsewhere, this is the equivalent of me using unsafe C# code for performance reasons and then blaming C# for letting me do it.

I highly doubt shaurz has written C/C++ code professionally, because for C/C++ developers, the nature of this issue is fairly obvious.

4

u/[deleted] Apr 09 '14

This specific exploit circumvention for malloc and free is present on OpenBSD, but not on FreeBSD, Linux (with glibc, bionic or musl), Windows or OS X. Zero/junk fill is an opt-in feature of jemalloc, but I don't know of any projects using it in production. Firefox and FreeBSD use jemalloc but do not enable zero/junk fill as it has a high cost and is considered a debugging feature. It would not have prevented this from working elsewhere, only on OpenBSD where they are willing to sacrifice some allocator performance for security.