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
We had this discussion at work. Halfway through, the following phrase lept from my mouth:
Because no good thing ever came from the thought: "Hey, I bet we can write a better memory management scheme than the one we've been using for decades."
Years ago I was maintaining a system that had its roots in the DOS days. Real-mode, segmented addressing.
My predecessor had some genuine difficulties with real mode, there were structures he wanted to keep in RAM that were too big for the segments. That was a genuine issue for many systems at the time.
The easiest solution would have been to be a little more flexible about his memory structures. Another choice might have been to license a commercial memory extender. He opted to instead roll his own version of malloc.
I would not consider myself to be qualified to undertake such a project, but he was if anything less qualified.
I only discovered all of this at the end of an 11 hour debugging session. The reason my memory was becoming corrupt was because of bugs in the allocator itself. By the time I was working on this project, the compiler had better support for large memory structures, and I was able to fix it by deleting his malloc and twiddling some compiler flags.
Lo and behold, a zillion other bugs went away. And the whole system got faster, too.
The trouble is, if you're not cautious enough to be given pause by the notion of implementing memory management yourself, you're almost certainly the kind of person who needs that pause the most.
I do indeed remember that :) This is why some teams rigidly enforce, as a coding style rule, that comparisons against literals always have the literal on the left-hand side.
Unfortunately some people try to enforce that sort of thing in languages that aren't C and C++, where you'll actually get type errors because you're trying to put an integer or something where a boolean should go.
Edit: though to be fair, you do see that sort of thing in Java with the whole CONSTANT.equals(variable) thing, but that's just due to Java's handling of the billion dollar mistake.
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?
Normally I'd think like you, but OpenSSL is no stranger to no auditing. We had the Debian entropy clusterfuck, where downstream patches were never tested by anybody for years. And then we had the recent failure to implement the Dual EC DRBG algorithm,which was positive in this case for breaking a potential backdoor , but not encouraging considering it means that there are portions of the codebase that nobody has ever used in the history of the project floating around just waiting to break something important. And now this. The incompetence is simply too far reaching to allow a conclusion of malice. I refuse to believe that a good attacker infiltrating the project could not do better.
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.
If it was sourced it would be a hell of a lot bigger news and he wouldn't be doing that talk at a hacker conference he'd be on tv somwhere.
As he said in the beginning of the talk:
It got me thinking, suppose I have a 1 billion dollar budget and I want to capture as much security as aI can what would I do? [...] Now I'm an NSA agent giving a briefing and I got lost and ended up here.
It's a thought experiment not him being the next Snowden.
The NSA budget for putting flaws in commercial software is $250 millions. Snowden says RSA has accepted 10 millions to do that (they deny it) and Linus Torvalds confirmed he was approached to put some vulnerabilities inside the kernel.
Expect these things to have succeeded. We need audits and the sooner the better.
However, TLS has been considered as imperfect security as certificates have been known to be forgeable by authorities since a long time, so I don't think anyone relied on OpenSSL to hide from governments.
"Oh, Christ. It was obviously a joke, no government agency has ever asked me for a backdoor in Linux," Torvalds told Mashable via email. "Really. Cross my heart and hope to die, really."
Linus Torvalds confirmed he was approached to put some vulnerabilities inside the kernel.
Do you have a source for this? I don't doubt the possibility that he's been approached, but all I can find are blogs who are interpreting what could very well have simply been a joke as a cut-and-dried "confirmation."
"Oh, Christ. It was obviously a joke, no government agency has ever asked me for a backdoor in Linux," Torvalds told Mashable via email. "Really. Cross my heart and hope to die, really."
I'm suspect about anything that claims to know how much the NSA is spending on anything, even when sourced by leaked documents. Their budget is basically a black box. When you consider how ineffective most government agencies are at keeping a budget even when they're supposed to, it seems pretty incredible to think the NSA takes the idea of a budget even a little seriously.
Of course, that was a draft and not assigned an RFC number. The fact that an implementation was made is probably what got them to assign the RFC number. An implementation is "highly desirable" for RFCs seeking such status. See https://tools.ietf.org/html/rfc2026#section-4.1.2 :
Usually, neither implementation nor operational experience is required for the designation of a specification as a Proposed Standard. However, such experience is highly desirable, and will usually represent a strong argument in favor of a Proposed Standard designation.
How come heartbeat messages are not logged at all? If they are network traffic then there could or should br some kind of logging. Can someone explain please
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.
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.
In case someone isn't fluent in C and memory management. If you try to read, write, or copy memory that your process doesn't own then most operating systems will terminate your program to protect the integrity of the memory.
The "hearthbleed" bug was caused by the program being allowed to copy memory which was already freed by the program, since some abstraction layer actually didn't free it, but cached it itself.
That's how i understand it, i might have misunderstood something.
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.
No it wasn't. OpenBSD malloc may be bad, ugly and slow, but computers have been fast enough for more than a decade. It has been for a long time the greater goal to make them more secure ... which is incidentally the goal of OpenBSD.
It is somewhat of a unfunny joke that they did wrap malloc especially because of OpenBSDs mallocs being so slow and thereby undermined the focus on security in that OS. They could have reengineered the code to use less malloc/free (pointed out by Fefe on his blog) ... but anybody who ever looked into OpenSSL code knows that it is ... difficult, to say the least.
Edit: I relied for the italic part on Fefe. Either I misread him from the beginning or he toned down his article on that point.
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.
They are independent, but OpenSSL throws away one while solving the other, that is, it uses a custom memory allocator to "fix" the slow performance of the platform-provided malloc, and in doing that, also bypasses the security checks of the default allocator.
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?
I think the performance argument is also belied by technologies people choose to actually host their Web sites. PHP, C#, Java, RoR... I don't see the people using C and C++ to write Web apps.
I enjoy working in Java-land: Eclipse Code Formatter XML file, in version control, at the root directory of the project tree.
Eclipse + IntelliJ use it identically. Developers can write w/e crazy diarrhea-of-consciousness-formatted code they want: one quick action before checkin, and the entire codebase follows the same code style.
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.
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.
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 cant stand gitub code review comments, they take over the screen. oh did you actually want to see what code was changed? no, no. you read comment now.
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.
Then again, any respectable deliberate backdoor will have plausible deniability built in - in other words, will be disguised as mere everyday sloppiness.
I mean lack of evidence is just as good as evidence right.
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
Alternatively, we can change the code review practices to ensure that the potential for both situations are vastly reduced in a practical manner, without needing to distract ourselves with casting blame about in all directions.
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.
p, s, pl, n2s, s2n, r, bp. All names used in that codebase. It is like the author thinks that using fewer letters in their names results in faster code or something.
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).
Oh, I didn't mean to imply OpenSSL is easy to use- more so that "easy to use" is not something that's generally used with any of those libraries (OpenSSL seems to take it to a whole different level, though).
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
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.
Those people should fire up more servers to handle the load. Handling a thousand requests per second on all but the most powerful hardware is already ridiculous without the SSL overhead. If you have that much traffic and not enough hardware to handle it, you have bigger problems than poorly performing crypto libraries.
If that were true, you could run the code under a typesafe language or vm instead. Then you'd prevent the entire class of vulnerabilities instead of just this instance.
There are other ways to harden a security critical library than to use poor performing allocators. That said, I agree with your greater point -- it would have been wise to test under both the high performance allocator as well as a conservative allocator/analysis - eg valgrind.
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
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.
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.
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/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.
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?
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?