Fucking hell. The things that had to come together to make this do what it does and stay hidden for so long blows my mind.
A custom allocator that is written in a way so that it won't crash or show any unusual behavior when allocation bounds are overrun even after many requests.
A custom allocator that favours re-using recently used areas of memory. Which as we've seen, tends to lead it to it expose recently decoded https requests.
Avoidance of third party memory testing measures that test against such flaws under the guise of speed on some platforms.
A Heartbeat feature that actually responds to users that haven't got any sort of authorization.
A Heartbeat feature that has no logging mechanism at all.
A Heartbeat feature that isn't part of the TLS standard and isn't implemented by any other project.
A Heartbeat feature that was submitted in a patch on 2011-12-31 which is before the RFC 6520 it's based on was created. By the same author as the RFC.
Well said. This is why, after years of professional development, I have a healthy fear of anything even remotely complicated.
After spending the late 90's and early 2000's developing and supporting high profile (read: constantly attacked) websites, I developed my "3am rule".
If I couldn't be woken up out of a sound sleep at 3am by a panicked phone call and know what was wrong and how to fix it, the software was poorly designed or written.
A side-effect of this was that I stopped trying to be "smart" and just wrote solid, plain, easy to read code. It's served me well for a very long time.
This should go triple for crypto code. If anybody feels the need to rewrite a memory allocator, it's time to rethink priorities.
A side-effect of this was that I stopped trying to be "smart" and just wrote solid, plain, easy to read code
There's a principle that states that debugging is harder than writing code, so if you write the "smart"est possible code, by definition you aren't smart enough to debug it :)
"Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?" -- Brian Kernighan The Elements of Programming Style
I wish more of my co-workers thought like you. As a programmer, our job should be to manage and reduce complexity whenever possible. Software gets complex plenty fast without adding extra complexity just because it was fun, made you feel smart or was more "optimized".
Nothing here implied intent.. but it also didn't discount it either.
Normally, I would say "Do not ascribe to malice to what could be incompetence." HOWEVER considering that this is probably one of THE most relied on packages.. and this is such a FAR REACHING BUG.. the author better have a damn good explanation.
It is speculation, but the converse is also true "Sufficiently advanced malice can be mistaken as incompetence."
What is the audit process? What is the proper discovery and reporting mechanisms of the people who developed OpenSSL?
submitted in a patch on 2011-12-31 which is before the RFC 6520 it's based on was created. By the same author as the RFC.
To be fair, that's not particularly suspicious. "Hey, I improved the implementation of this protocol I use. We ought to make that a standard so other implementations can add that to the protocol also."
I.e., if RFC-6520 was written by the same author, the patch wasn't based on the RFC. The RFC was based on the patch. Indeed, they're called "requests for comments" for that reason: "Look what I did. What do you think?"
I don't know of any RFC that was written before the first implementation was coded.
Theo de Raadt says the memory allocation and release methods on modern systems would've prevented the "Heartbleed" flaw, but OpenSSL explicitly chose to override these methods because some time ago on some operating systems performance wasn't very good. Also, they didn't test the code without this override, so they couldn't remove it once it wasn't needed any more. Now, a significant portion of Internet servers have to revoke their private keys and regenerate new ones, as well as assume that all user passwords may have been compromised... because the OpenSSL guys "optimized" the code years ago.
You don't get to put quotes around optimized. It was a legitmate optimization at the time. Whether or not it should have been done, or if it could have been done better, is a different debate entirely.
How would these have prevented the heartbleed flaw? In not seeing it. The flaw is caused by trusting an external source to tell you how big of a size argument to pass to memcpy() (and malloc()).
EDIT: OK, they're talking about guard pages. Guard pages would use the MMU to detect when something is reading or writing in a place where it shouldn't be.
Because the memory accessed by that flaw is often memory that was freed before, so there's an opportunity to prevent the program from accessing it since it shouldn't do so.
OpenBSD has protections in place to mitigate this kind of bug. Instead of leaking info it should crash the program. The side effect is slightly slower malloc/free.
OpenSSL developers decided that on some platforms malloc/free is too slow and implemented their own allocators on top of it. This neatly sidesteps the exploit mitigation features.
To be fair, there's no indication that they rolled their own mem management explicitly to avoid security protection nor that the OpenSSL team was even aware of the security benefits of built-in malloc and free. If you've ever spent any time in the OpenSSL codebase I think you'll instead come to the same conclusion as I: it was a hazardous combination of incompetence and hubris.
I can definitely see that for Yahoo!, Google et al. But I wonder how critical the performance would be for the bottom 95% of sites? The bottom 50%?
Where is the threshold where security trumps performance? Certainly I would rather my bank run a more expensive/powerful server than be vulnerable to Heartbeat for two years.
Surely there'd be a market for an extra-fortified, not-as-fast version of SSL?
It is still encrypted, but as others pointed out, your browser doesn't recognize the issuer of their certificate because it was self-signed and not by one of the built-in root certificate authorities.
So long as it's still usable depends on the client. If you have a server which handles a hundred requests a second, is openSSL still usable? What if you want to service a thousand?
Problem is it's a library, people use it in different ways.
The problem is, an SSL library will get called a lot. All your traffic might pass through it. It may in fact not be usable unless it is extremely fast.
The joke is that they've had quite a lot of more bugs than that, but since most of the features are turned off in default install, they haven't had many bugs in default install
Mr. de Raadt is correct. OpenSSL is a nasty piece of software. Just try doing anything with it using the command-line programs and that fact should become immediately obvious: Poor documentation, too many different intermediate file formats, and non-standard and obsolete command syntaxes.
OpenSSL has always struck me as a package written by mathematicians whose second job is programming. I know there are many mathematicians who are excellent programmers, but when programming is an afterthought to the underlying mathematics chances are you will produce poor-quality software
I hate to be so negative about such a useful piece of software. I think that OpenSSL could be refactored/reorganized to produce a really great piece of software. Mainly, they need to revise the command-line options to be modern (use GNU standards), write proper documenation, and as other people have said, improve the code base.
You make it sound like this was OpenSSL's fault. Remember, they didn't invent SSL, they just took the crap that was specified by some stillborn monkeys on meth and tried to implement it as best as they could. ASN.1 is a crappy mess and there's just no way to make it look pretty. At least OpenSSL allows you to do all that crazy stuff that you sometimes need to do all from the comfort of their impressively powerful command line... show me another tool that can just encrypt/decrypt/hash random stuff with every single cryptographic algorithm (combination) known to man, create/sign/verify all kinds of certificates, and provide a really useful SSL-telnet for debugging (even with STARTTLS support!).
Also, even if we were to redo the whole SSL/x509/ASN.1 stack from the ground up, I don't think crypto will ever be "easy". It's just complicated stuff and you need to handle things like serialized certificates and arbitrary-length numbers in your code to make it work. This will never look all that pretty in C.
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. Some other debugging toolkits get them too. To a large extent these come with almost no performance cost. 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.
The code has a comment explaining the custom allocator:
/* On some platforms, malloc() performance is bad ...
Meaning that the exploit mitigation which would have lessened the impact of Heartbleed (no passwords, private keys, OAuth tokens in the bleed... instead a server crash) is not in place.
That's what i'm missing. People are bitching about a custom memory allocator. That may be a defense-in-depth precaution, by using the standard allocator. But it's certainly not a holy thing to use the standard allocator.
The real problem is the actual problem:
reading a value from the client and assuming it is valid
The other problem, reading past the end of a buffer, is a situation endemic to the entire C language (and any language that allows pointers).
Yep looking at that part of the code was a bit of a WTF moment. Also, there's a variable called "payload" where the payload length is stored... what kind of monster chose that name, I don't know.
Maybe. But this is code that entered OpenSSL 2 years ago.
And in any case one doesn't simply go reading the whole code running in systems. Literally by the time you finish there's a dumpload of new code to check. You'd never finish.
But I'd have expected that important stuff like this was more scrutinized by security people. It was found... 2 years later.
But I'd have expected that important stuff like this was more scrutinized by security people. It was found... 2 years later.
And this right here is critical to understand whenever anyone tries to make the argument that open source is safer just because it's open source. The source has to actually be audited by someone with sufficient qualifications.
This guy http://www.robin-seggelmann.de/ wrote it. His motivations were likely because he wrote his PhD thesis on streaming encryption and he thought he was clever. Also, he wrote the TLS Heartbeat RFC.
Haven't we learned a thing or two recently about what can happen if you don't add braces to one line if blocks!? Especially with returns after them... I know it was hurried, but there's really no excuse for that.
I mean, I know the NSA crap that's been floating around makes that a legit possibility, but cases like this really feel like your normal level of sloppiness that's bound to happen in the real world. Nothing and no one is absolutely perfect.
Agreed. This is an Ockham's Razor scenario -- for every NSA backdoor, there are probably thousands of vulnerabilities that simply slip in by pure accident. Probability of such accidents goes up with the complicatedness of the solution, and with the number of lines of code.
Plausible deniability is a thing, ESPECIALLY in this realm.
I am not saying that it was intentional or malicious, but you bet your ass with a security hole this big we shouldn't assume automatically innocence first..
I think you've confused two completely different things; the IOCCC is for making unreadable code. The one about programs that have a secret critical vulnerability is The Underhanded C Contest
I'm pretty sure "payload" is standard networking jargon to refer to the actual data part of a packet (as opposed to the headers etc.), in perfectly legitimate contexts. It's a little odd, in sort of the same way that "hash maps" and "binary search trees" are odd if you think about what those words normally mean, but I don't think that choice of variable name is especially suspicious.
This is C code. We have an unsigned int and a pointer, if you don't say it's the length, it can be very easily mistaken for the location/offset of the payload.
In fact the main part of the fix consists of checking that the actual record is sufficiently long. This would be substantially more evident (that this wasn't being checked) if the variable looked like a length.
There are a number of bad practices making this possible, though. The main one being... bypassing the system malloc (!!) just because it may be slow in some systems.
There's several alternatives, including NSS (used by Firefox & Chrome), cryptlib, polarSSL, and even GnuTLS (I wouldn't suggest migrating to that last one :P). Likely none of them are particularly easy to use (which is a major issue that people tend to overlook...), and probably none that are even slightly widely used are formally verified.
Fedora is actually working to migrate things over to using NSS, and has been for a while. At least as things stand right now, NSS seems like a far better option than OpenSSL (plus, there's less issues with the license).
I once took a look at the NSS code and after a few hours I wanted to shower myself in napalm. I don't know how bad OpenSSL code is, but I would bet my right hand NSS isn't much better.
IMHO it would be a great idea to write a library that puts the encryption keys into a different address space (i.e. a different process) as to make it impossible for any flaw to read it out.
So this may sound naive, but... If a flaw can't read them from a separate process, how can the program itself? Or can you really write it such that the separate process handles all the encryption/decryption in safe(r) manner?
The main program cannot read out the key but it can perform cryptographic operations with it, for instance it can tell the key-process to encrypt or decrypt a piece of data for him. Even though an attacker could still do nasty things in such a model, he could not get the key.
I sit here reading all these articles and all I can think is that I wish I had a better understanding of the inner workings of cryptography so I could make an attempt.
Unfortunately, I don't care much for math. Comp Sci maybe wasn't the smartest idea...
No, zalifer is right that the quote is not by Theo de Raadt. The formatting in that usenet log is terrible (somewhat ironically).
Look at it from the top level, the title tells you that the main text was written by Theo de Raadt. He quotes Mike Small, who quotes nobody, who starts his post with a quote of somebody else. The confusing thing is that this last quote does not have any header indicating who it was quoted from.
Luckily, Theo de Raadt seems to ben in agreement with Mike Small Ted Unangst, so the misattribution does not really change much.
Edit: It's even weirder, and even more ironic. Theo de Raadt was quoting Ted Unangst, without having the proper header above the quote. Still, the quote in the title was not from Theo de Raadt.
There are two types of people who write open source code:
Those who have heard the music of the spheres and write in crystalline prose no mortal can ever understand, and those who think a quadruple indented 15 clause if/else tree is a valid way to deal with complexity.
If mortals can't understand it, it's bad code, although sometimes it's unavoidable. If I've misunderstood and you meant that all open source code is bad then we're in agreement.
I don't know man... once you reach certain levels of complexity sometimes you need to have absurd amounts of the program & goals in your mind to understand the full scope of what's happening.
I'll have times where I slip back out of the zone, look at my own code, and am like "Damn that works well, but I have zero confidence I could write that again".
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." – Brian W. Kernighan
Theo de Raadt & Linus Torvalds - opinionated, blunt, maybe even rude, but absofuckinglutely right about almost every thing they've ever said or written. This is what separates them from the rest of us.
I think it is Dijkstra to whom the aphorism "All significant systems still contain bugs" is most commonly attributed, but I'll bet he was not the first to think of it. Nobody can realistically claim that openssl, much less the internet, is trivial.
So let's bite on the bullet. There are (still) security bugs in the net. We should be alert for them, and swat them when they come to light, but there is a limit to how much breast-beating they are worth. This bug is dead (or at least moribund, until people update their openssl). Next week, another bug!
This is pretty worrying, especially if we consider the fact that the exploit has been out in the wild for a long, long time. I've patched up all my stuff, and wishing everyone else to do the same quickly.
He is right. Anyone who has looked at openssl knows he is right. Even their make system doesn't properly track dependencies to build in parallel. (at least it didn't last time I checked) Many of the algorithms they implement are complicated enough most people assume they are correct (it is hard to audit a section of code for correctness when the algorithm is hard to follow) . This feature he shows however only works for the right allocator. Some people would still be affected but it is more likely the openssl team would find this bug had they not worked around the allocator.
What surprises me by this bug is that a program like OpenSSL isn't that heavily unit tested, I mean the most basic unit test would catch this. It is a programming error and a classic C error too, I don't exactly know how OpenSSL works so forgive me if some of this comes as ignorant but surely this process would be working in its own virtual set of memory, if it did try and access cached memory outside of the virtual set the operating system would complain regardless if it used a bespoke memory allocation routine?
Exactly, and a unit test would have caught the goto fail from Apple.
The problem with these crypto libraries is that their implementations are made to be untestable. The Chrome guys said that exactly the same code path as the goto fail from Apple was not testable in Chrome either.
We need to "dumb down" our crypto until we can at least write unit tests. Complex algorithms or implementations without tests cannot be used.
I'm not defending OpenSSL in general. I don't know enough about it's internals to comment on it.
But caching memory allocated by malloc() is a pretty common technique. It's not an unreasonable thing to do, and it does not automatically make someone an unreasonable developer.
Doing something like that unconditionally is usually better than doing it conditionally. Maybe some platform has a really fast malloc and it's not necessary, but if you have two code paths, then you have two code paths to debug. (In this case apparently they did support both ways, but the one that wasn't used unsurprisingly didn't work.)
But caching memory allocated by malloc() is a pretty common technique. It's not an unreasonable thing to do, and it does not automatically make someone an unreasonable developer.
If someone does this without credentials proving that they've successfully worked in memory management on a real operating system the code gets immediately rejected in review. Clever memory caching is what every malloc does internally, except that the people who wrote malloc hopefully know what they are doing and the average developer doesn't.
There was an excuse to do this on VAX where function call overhead was big, mallocs inefficient, memory small so fragmentation wasn't a problem and heap overflow exploits weren't invented yet.
Malloc is much slower than your freelist? There are options:
You are smarter than whoever wrote it, the glow of your genius outshines the sun, people should bow at your mad skillz.
malloc does those slow things for many reasons that the developers have figured out over decades of debugging and experience. You're disabling important security, debugging, performance and anti-fragmentation features that will bite you when you least expect it leading to undebuggable problems at the worst possible time.
You're in the 0.01% of use cases where a certain use pattern of memory in critically performance sensitive code that just has to use dynamic allocation in the hot path improves things so vastly it is the difference between something working and not working.
You're using an operating system that is shit. Use an external malloc library. You are not the first one to have this problem. One of the dozen popular malloc implementations has surely been ported to your system.
You learned programming in the 80s and are of the opinion that nothing worth knowing has happened since then.
If malloc is slower than my freelist, it's probably because malloc is a very generalized tool and my freelist, or the one I'm using, is much more specialized.
It looks like a quick and easy fix - even if it's just a temporary one - is to add a line or two to set the memory contents to zero immediately before it is released back to the cache. You're not disabling the cache just yet, but you're removing (at least, as I understand it) the cause of this exploit. Or am I misunderstanding the vulnerability?
Some time ago, a vulnerability was revealed in OpenSSL, and I guess there's no programmer who hasn't been talking about it since then. I knew that PVS-Studio could not catch the bug leading to this particular vulnerability, so I saw no reason for writing about OpenSSL. Besides, quite a lot of articles have been published on the subject recently. However, I received a pile of e-mails, people wanting to know if PVS-Studio could detect that bug. So I had to give in and write this article: http://www.viva64.com/en/b/0250/
Remember when that Debian developer "fixed" that OpenSSL Valgrind warning. Yeah. Some people shouldn't be allowed near a C compiler. Actually, can we just stop using C now, please?
C is an extremely versatile and powerful language, the reason they used it over say Java was for performance reasons, as much as people would like C to go away it is here to stay. Also if you read the content in the link you'll realise that this wasn't caused by a design feature in the C language because if the OpenSSL team hadn't rolled their own custom memory allocation function then the operating system would have taken care of this and the bug would have been found ages ago. The problem is that when the OpenSSL's version of free is called it doesn't zero the memory AND it allows you do to a memcpy over your buffer. The regular C library would mitigate both those issues.
Why are we still trusting security software written in C? It's clear that anything written in C or C++ CANNOT EVER BE TRUSTED. Auditing might have caught it, but clearly there isn't the resources to do so and it's no guarantee.
This has been stated 100000000 times, and even in this thread:
They choose to circumvent tooling and standard library calls that have been around for quite sometime that wold have prevented this bug. This was a conscious choice on the part of the OpenSSL dev team and contributor (if he is not actually apart of the team), simply for performance reasons.
C or C++ is not at fault here. If you and everyone else could stop being mindless idiots about a language that'd be great.
I'll prepare for my second round of down votes that were so graciously handed to me yesterday from the illustrious /r/programming subreddit. Something something Rust and Ada.
They choose to circumvent tooling and standard library calls that have been around for quite sometime that wold have prevented this bug.
The trouble is, while all this tooling (ASLR, guard pages, canaries, etc.) is really, really clever and does some amazing things, it's not very efficient. It's all really, really clever precisely because it has to work around weaknesses in C.
Take guard pages for example. In lieu of just knowing the size of an array and doing 1 machine instruction (or maybe 2) to validate that a pointer or offset is within bounds, you have to use the MMU hardware to map THREE pages in memory, one to make sure nobody reads/writes before the desired region, one to make sure they don't write after it, and one dedicated to hold the contents of that allocation and that allocation only. Binding address space to pages with the MMU isn't cheap, either. It takes page table entries and doing extra bindings makes the TLB less efficient so everything runs slower.
And if I want 17 bytes from malloc(), that's not a multiple of the size of a page, so you've got to waste memory. You can't put more than one allocation in a single page if you want guard pages to work. At least not if you want them to protect against this exploit, which only relies on doing out an out-of-bounds read.
Of course, even OpenBSD doesn't actually take guard pages as far as they would need to to protect against this. Look at this presentation, where it says that in OpenBSD:
Each bigger than one page is followed by a guard page --> segmentation fault if overflow. Smaller allocations are randomly placed inside one page.
So for smaller allocations (which this likely is... an exploit heartbeat message is small), OpenBSD punts and doesn't provide the full protection of guard pages, because the cost is just too high. Instead, it randomizes layout, which could actually help an attacker use this exploit because they can just keep retrying and get a variety of different data.
So all these amazing tools exist, and I think it's a much better decision to use them than to not use them if you're using C.
But C doesn't get off the hook here, because all these things are a great big giant band-aid on C. With C, you get two choices: unsafe code or code that is kind of safe because it is covered in costly band-aids.
C is to blame because it only gives you bad choices. As an industry, we can do better. We have the technology. We've had it for 30 or 40 years. We just need to apply it.
You are right to a large extent. I think though, this bug would have been found a lot sooner, regardless of how certain systems choose to implement various safe guards, if they had decided to use sensible standard practices.
I think at the heart of this issue is I really feel like C is just a scapegoat, because I feel like it was really just bad engineering. C certainly had a part to play in this bug, I'm not denying that. But technology can only limit a developer's idiocy to a certain extent. People foaming out the mouth going "this is why we can't use C because of this!" are really missing what actually happened here, in my opinion.
I don't think C is an angel. I think there are certainly languages out there even now that will come to replace it in due time, simply based on merit. But we'll run into other problems, certainly. Recognizing bad engineering decisions is key to moving forward, not scapegoating an entire tool set (somewhat coincidentally C's memory management can certainly fall under the former part of my statement).
You C apologists can keep overflowing buffers, overwriting pointers and indexing arrays out of bounds to your heart's content. But this will not excuse the constant stream of security bugs which would not exist if a sane programming language was used. The OpenBSD feature is just a hacky workaround for a low-level memory model that should have been a long-forgotton artefact of the 1970s.
this bug existed for a long time and every person who was worth a damn knew about it I don't understand why its so hyped up now?You people act like its the end of the world and it hasn't been fixed yet.
Are you claiming that you knew about the heartbleed bug before it was publicly made known a few days ago? Or are you talking about the memory management part?
Umm, no. The current bug has absolutely nothing to do with the BEAST attack. The current one is orders of magnitude worse and has only been known for several days: http://heartbleed.com/
OpenSSL implements nearly every digest and cipher out there, plus means of encoding messages for transport and ways to convert between encodings. All while hopefully being speedy, as well (which was the problem that created the Heartbleed bug).
I don't mean that as an apology for OpenSSL; it's a good reason for why it needs to be more organized than it is. Rather, it should be clear that you're not going to do all that in a 500-line project.
They wrote a custom memory management layer which circumvents some exploit mitigation code...mitigation code that would have caused an immediate crash instead of allowing an exploit like this one.
The defense I've seen is that at the time, performance was so poor on some platforms that the software wouldn't have been usable, thus no encryption there unless they made this faster. And then for simplicity they just made this wrapper the default for everything. And then their tests wouldn't work without this wrapper enabled, so there was resistance to ever switching back to native malloc as the default. It reads like typical industrial disasters, where safety systems were disabled, precautions not taken, lax procedures, and then a huge disaster.
A lot of memory allocation library have security features built-in these days. For example, they can give you a larger piece of memory than you requested, and use the extra space adjacent to what you requested to store random values, which they then check at the time you free the memory. If the random values are no longer the same, it's a good indicator you had a buffer overflow. There are others, too, like guard pages, which is the one they are talking about here.
He's saying openssl could have used these protection measures but chose not to.
He's saying openssl could have used these protection measures but chose not to.
OpenSSL could have used those measures if it did not have its own wrapper around malloc to cache allocated memory (IIUC). By itself, as loonysquash points out, that's not an unreasonable thing to do---there are often circumstances where a general purpose malloc can be outperformed by relatively simple techniques. Further, there's not really any specification of malloc's behavior that says it must or should help catch memory or security errors, so it's not immediately obvious that avoiding calling it has a downside.
In all the coding I've done over the years, pretty quickly I saw that any performance-optimized allocators must turn into direct calls to malloc/free when debugging, so that all the checking features of them could be used to catch bugs (double-free, bounds checking, leak checking).
941
u/AReallyGoodName Apr 09 '14
Fucking hell. The things that had to come together to make this do what it does and stay hidden for so long blows my mind.
A custom allocator that is written in a way so that it won't crash or show any unusual behavior when allocation bounds are overrun even after many requests.
A custom allocator that favours re-using recently used areas of memory. Which as we've seen, tends to lead it to it expose recently decoded https requests.
Avoidance of third party memory testing measures that test against such flaws under the guise of speed on some platforms.
A Heartbeat feature that actually responds to users that haven't got any sort of authorization.
A Heartbeat feature that has no logging mechanism at all.
A Heartbeat feature that isn't part of the TLS standard and isn't implemented by any other project.
A Heartbeat feature that was submitted in a patch on 2011-12-31 which is before the RFC 6520 it's based on was created. By the same author as the RFC.
Code that is extremely obfuscated without reason.
PHK was right
150
u/tenpn Apr 09 '14
Can someone explain that in english?
123
u/sigzero Apr 09 '14
"OpenSSL is not developed by a responsible team."
Wow!
56
u/[deleted] Apr 09 '14
That's insane. If I were writing a SSL library, security takes precedence over performance so long as it's still usable.
42
u/_4p3 Apr 09 '14
"Only two remote holes in the default install, in a heck of a long time!"
So, when will they update this?
56
u/jgotts Apr 09 '14
Mr. de Raadt is correct. OpenSSL is a nasty piece of software. Just try doing anything with it using the command-line programs and that fact should become immediately obvious: Poor documentation, too many different intermediate file formats, and non-standard and obsolete command syntaxes.
OpenSSL has always struck me as a package written by mathematicians whose second job is programming. I know there are many mathematicians who are excellent programmers, but when programming is an afterthought to the underlying mathematics chances are you will produce poor-quality software
I hate to be so negative about such a useful piece of software. I think that OpenSSL could be refactored/reorganized to produce a really great piece of software. Mainly, they need to revise the command-line options to be modern (use GNU standards), write proper documenation, and as other people have said, improve the code base.
130
u/karlthepagan Apr 09 '14
Voodoo optimization: this is slow in one case 10 years ago. So, we will break the library for many years to come!
154
u/muyuu Apr 09 '14
Yep looking at that part of the code was a bit of a WTF moment. Also, there's a variable called "payload" where the payload length is stored... what kind of monster chose that name, I don't know.
84
u/ACTAadACTA Apr 09 '14
There should be an alternative to OpenSSL that is easy to use, formally verified and as small as possible.
I know, I'm a dreamer.
27
u/zalifer Apr 09 '14
The title is incorrect, so far as it suggests that Theo de Raadt said that.
As the formatting in reddit shows, Mike Small wrote the sentence quoted in the title.
75
u/[deleted] Apr 09 '14
There are two types of people who write open source code:
Those who have heard the music of the spheres and write in crystalline prose no mortal can ever understand, and those who think a quadruple indented 15 clause if/else tree is a valid way to deal with complexity.
3
u/bordumb Apr 10 '14
Probably built that way so that the NSA could have a nice backdoor to everything :)
16
u/kevwil Apr 09 '14
Theo de Raadt & Linus Torvalds - opinionated, blunt, maybe even rude, but absofuckinglutely right about almost every thing they've ever said or written. This is what separates them from the rest of us.
4
u/niknej Apr 09 '14
I think it is Dijkstra to whom the aphorism "All significant systems still contain bugs" is most commonly attributed, but I'll bet he was not the first to think of it. Nobody can realistically claim that openssl, much less the internet, is trivial.
So let's bite on the bullet. There are (still) security bugs in the net. We should be alert for them, and swat them when they come to light, but there is a limit to how much breast-beating they are worth. This bug is dead (or at least moribund, until people update their openssl). Next week, another bug!
2
u/skillcode Apr 09 '14
This is pretty worrying, especially if we consider the fact that the exploit has been out in the wild for a long, long time. I've patched up all my stuff, and wishing everyone else to do the same quickly.
2
u/stmfreak Apr 10 '14
Smart developers always seem to think they know better than whoever wrote the old code.
2
u/zvrba Apr 10 '14
Hah, I had a good hunch when I wondered how the damn thing didn't crash on so large (64kB, spanning a few pages) buffer overruns.
2
u/i-node Apr 09 '14
He is right. Anyone who has looked at openssl knows he is right. Even their make system doesn't properly track dependencies to build in parallel. (at least it didn't last time I checked) Many of the algorithms they implement are complicated enough most people assume they are correct (it is hard to audit a section of code for correctness when the algorithm is hard to follow) . This feature he shows however only works for the right allocator. Some people would still be affected but it is more likely the openssl team would find this bug had they not worked around the allocator.
2
u/partyboy690 Apr 09 '14
What surprises me by this bug is that a program like OpenSSL isn't that heavily unit tested, I mean the most basic unit test would catch this. It is a programming error and a classic C error too, I don't exactly know how OpenSSL works so forgive me if some of this comes as ignorant but surely this process would be working in its own virtual set of memory, if it did try and access cached memory outside of the virtual set the operating system would complain regardless if it used a bespoke memory allocation routine?
1
u/looneysquash Apr 09 '14
I'm not defending OpenSSL in general. I don't know enough about it's internals to comment on it.
But caching memory allocated by malloc() is a pretty common technique. It's not an unreasonable thing to do, and it does not automatically make someone an unreasonable developer.
Doing something like that unconditionally is usually better than doing it conditionally. Maybe some platform has a really fast malloc and it's not necessary, but if you have two code paths, then you have two code paths to debug. (In this case apparently they did support both ways, but the one that wasn't used unsurprisingly didn't work.)
1
u/hpzr24w Apr 09 '14
It's the sinister option.
1
u/GeorgeForemanGrillz Apr 10 '14
I agree with Theo here. They have the balls to ask for donations too. Fuck them.
1
u/matholio Apr 10 '14
Most of this is whoosh for me, but enjoyed reading the comments of mature coders talking able the perils if feeling smart.
1
u/SlobberGoat Apr 10 '14
a wooden stake being driven through OpenSSL's heart = HeartBleed
1
u/Andrey_Karpov_N Apr 16 '14
Some time ago, a vulnerability was revealed in OpenSSL, and I guess there's no programmer who hasn't been talking about it since then. I knew that PVS-Studio could not catch the bug leading to this particular vulnerability, so I saw no reason for writing about OpenSSL. Besides, quite a lot of articles have been published on the subject recently. However, I received a pile of e-mails, people wanting to know if PVS-Studio could detect that bug. So I had to give in and write this article: http://www.viva64.com/en/b/0250/
1
u/syncsynchalt Apr 09 '14
This email was a lot more confusing until I stopped parsing "openssl" as "openssh" (due to proximity to TdR).
-2
u/drguildo Apr 09 '14
Remember when that Debian developer "fixed" that OpenSSL Valgrind warning. Yeah. Some people shouldn't be allowed near a C compiler. Actually, can we just stop using C now, please?
-36
u/[deleted] Apr 09 '14
Why are we still trusting security software written in C? It's clear that anything written in C or C++ CANNOT EVER BE TRUSTED. Auditing might have caught it, but clearly there isn't the resources to do so and it's no guarantee.
-26
u/makeswordclouds Apr 09 '14
Here is a word cloud of all of the comments in this thread: http://i.imgur.com/I0EA0Si.png
source ^code | contact ^developer
-9
u/[deleted] Apr 09 '14
this bug existed for a long time and every person who was worth a damn knew about it I don't understand why its so hyped up now?You people act like its the end of the world and it hasn't been fixed yet.
0
u/[deleted] Apr 09 '14
[deleted] — view deleted comment
0
u/[deleted] Apr 09 '14
[deleted] — view deleted comment
3
u/[deleted] Apr 09 '14
[removed] — view removed comment