Slashdot Mirror


Theo De Raadt's Small Rant On OpenSSL

New submitter raides (881987) writes "Theo De Raadt has been on a better roll as of late. Since his rant about FreeBSD playing catch up, he has something to say about OpenSSL. It is worth the 5 second read because it is how a few thousand of us feel about the whole thing and the stupidity that caused this panic." Update: 04/10 15:20 GMT by U L : Reader badger.foo pointed out Ted Unangst (the Ted in the mailing list post) wrote two posts on the issue: "heartbleed vs malloc.conf and "analysis of openssl freelist reuse" for those seeking more detail.

77 of 301 comments (clear)

  1. "It's Not a Tumor" - Oh Wait, It Is by alphatel · · Score: 4, Interesting

    This could get a lot more ugly...

    Once upon a time, SSL certificates were signed against a single root certificate, each SSL cert issuer had a single root certificate authority for each of its product lines. Now all corps issue an SSL certificate that is signed against and INTERMEDIATE certificate, which in turn is signed against the root certificate.

    What happens if a provider's server has this exploit and the intermediate certificate is compromised? EVERY certificate signed against that intermediate must be revoked. Or put another way, the ENTIRE PRODUCT LINE must be tossed into the garbage and all certs reissued.

    So if Verisign or Thawte discover new their intermediate certificate MIGHT have been exploited, would they say anything? The servers implementing those certs are in the hands of a select few - it would be easy to hide the possibility they might have been compromised.

    --
    When the foot seeks the place of the head, the line is crossed. Know your place. Keep your place. Be a shoe.
    1. Re:"It's Not a Tumor" - Oh Wait, It Is by putaro · · Score: 5, Insightful

      If your intermediate certificate's signing keys are on the internet facing web servers you're doing it wrong. That intermediate signing key should be treated with the same level of security you would treat a root key with.

    2. Re:"It's Not a Tumor" - Oh Wait, It Is by Anonymous Coward · · Score: 5, Informative

      It is good practice to sign against an intermediate certificate. That way if it is compromised you can reject it and issue a new intermediate certificate signed by your root certificate. You can push the new certificates as updates since they would be validated against the root certificate.

      You need to read up on authenticating the entire chain of certificates.

    3. Re:"It's Not a Tumor" - Oh Wait, It Is by Bill,+Shooter+of+Bul · · Score: 2

      I don't understand what you are trying to imply by contrasting the old way without intermediate vs the new way with intermediate certs. Surely, its better with the intermediates as the root cert that signs it should be and can be used less often and stored in cold storage somewhere.

      --
      Well.. maybe. Or Maybe not. But Definitely not sort of.
    4. Re:"It's Not a Tumor" - Oh Wait, It Is by Anonymous Coward · · Score: 5, Informative

      I don't get what you're saying, and I think that's probably because you don't know what you're talking about. Having certificate chains is only a plus, the flat structure was crap. Here's how it works:

      I have a root certificate that's universally trusted. It is used *only* to sign intermediate certificates. Having the public cert in the public is fine since it only contains the public key part of the asymmetric public/private key pair. The private key, sits on a server which is physically isolated from the world. By that, I mean that the root certificate and private keys are literally on servers with *no* network connections. When you want to generate a new intermediate certificate, you put the CSR on a USB stick, plug it in, and sign it from that machine. In this way you never have to worry about external threats potentially gaining access to your private key (internal are an ever constant threat, and you put in good safeguards to prevent against that).

      Now that you have a chained hierarchy, you can use different intermediates to sign different end user certificates. Remember that both the root and intermediate have their own certificate revocation lists: the root can revoke intermediates (which means anything signed by them is null and void) and intermediates can revoke server or subordinate intermediate certs.

      As a result of my chained hierarchy, if an intermediate is compromised, I can revoke it, without revoking every single end user / server certificate out there. This gives me finer grained control.

      Now, I said that the root isn't even connected to the internet. The intermediate ideally is not either. Ideally the user / server signing intermediate is behind a set of firewalls, and *pulls* signing requests from frontends, that it then processes and posts the resulting signed certs to. That way if you compromise the front end, you have to the compromise the firewall (which ideally is blocking all inbound connection requests / unconnected sockets / anything that is not communication required for the intermediate server(s) to send pulls to the frontends) in order to get to the intermediate.

      Your flat view of the world is draconian, wrong, uneducated, and probably hurts everyone who reads it by making them a little less educated.

    5. Re:"It's Not a Tumor" - Oh Wait, It Is by Krojack · · Score: 3, Interesting

      As we all know, most high level hacks these days come from an internal computer getting infected with something.

    6. Re:"It's Not a Tumor" - Oh Wait, It Is by DarkOx · · Score: 4, Informative

      Far more important is that if the intermediate certificate is compromised, you as the CA have ability to act. You know from your records who your customers are. What you need to do is:

      1) Fix the glitch
      2) Get the media that stores the trusted root certs private key out of the vault
      3) Issue new intermediate certificates
      4) return the root certs private key to vault
      5) Start contacting your certificate customers and issuing them new certs, revoking the old ones along the way as customers reported they have switched, or if there *is* indication of a compromised cert, revoke immediately.
      6). Revoke the old intermediate certificates as soon as 5 is complete.

      If were signing client certificates directly with the trusted root like they once did you (as the CA) would be screwed royally. You would need to somehow get every client device to update their trusted roots. Or you'd have upset customers crying about how their reissued certs are untrusted by 3/4ths of the clients out there that nobody bothers to update and nobody who understands these things manages directly..

      --
      Repeal the 17th Amendment TODAY! Also Please Read http://www.gnu.org/philosophy/right-to-read.html
  2. When comments... by darkain · · Score: 2

    When Slashdot comments become full front page stories? This was already posted a few times as comments in the last OpenSSL post.

    1. Re:When comments... by Anonymous Coward · · Score: 5, Insightful

      Theo De Raadt is a noteworthy personality, same as Linus Torvalds or Bill Gates. Their comments on important matters are important.

    2. Re:When comments... by MightyMartian · · Score: 5, Insightful

      As much as Theo can be an utter and insufferable prick, on this score he's right. This was an insanely trivial error which has exposed who knows how many systems to potential breaches. Right now I'm starting up a full audit of our systems. We use OpenVPN for our interoffice WAN, as well as for clients; many of them Windows, iOS and Android clients, not to mention reviewing all our *nix clients running SSH daemons. We're only a relatively small operation, and it's still a monumental pain in the ass.

      --
      The world's burning. Moped Jesus spotted on I50. Details at 11.
    3. Re:When comments... by Anonymous Coward · · Score: 4, Interesting

      As much as Theo can be an utter and insufferable prick, on this score he's right.

      Actually, most of the time he's right; it's just the prick bit that is the problem. What's worrying about this is that he sounds completely reasonable. He didn't even call the Open SSL developers any names or anything and everything in the post was reasonable. I hope he isn't sick or something.

    4. Re:When comments... by MightyMartian · · Score: 3, Funny

      Don't worry. I've more than made up for Theo's unusual calmness this morning, and have called them names that would make the gods blanch.

      --
      The world's burning. Moped Jesus spotted on I50. Details at 11.
    5. Re:When comments... by lgw · · Score: 2

      He didn't even call the Open SSL developers any names or anything and everything in the post was reasonable. I hope he isn't sick or something.

      "OpenSSL is not developed by a responsible team."

      Theo the Raanter is fine. Personal abuse and profanity is just noise. This was a truly cutting comment.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    6. Re:When comments... by fahrbot-bot · · Score: 5, Funny

      Theo De Raadt makes comments about Linux being for losers. Linus Torvalds makes comments about OpenBSD users being masturbating monkeys. You usually have to take some of their comments with a grain of salt.

      He said, prophesying a future Ubuntu release name.

      --
      It must have been something you assimilated. . . .
    7. Re:When comments... by lgw · · Score: 2

      Indeed. The harshest insults don't need any emotion or colorful language, they're simply, obviously, true.

      --
      Socialism: a lie told by totalitarians and believed by fools.
  3. Summary for the lazy ones by Anonymous Coward · · Score: 5, Informative

    Years ago the BSD guys added safeguards to malloc and mmap, but they were disabled for all platforms in OpenSSL only because they caused performance problems on some platforms. He finishes by saying that OpenSSL is not developed by a responsible team.

  4. More commentary from OpenBSD's Ted Unangst by badger.foo · · Score: 5, Informative
    OpenBSD developer Ted Unangst (mentioned in the article) has gone into the code a bit more in two articles, both very well worth reading:

    heartbleed vs malloc.conf

    and

    analysis of openssl freelist reuse. Short articles with a lot of good information.

    --
    -- That grumpy BSD guy - http://bsdly.blogspot.com/
  5. Summary. by jythie · · Score: 4, Insightful

    So as far as I can tell, his rant is essentially that people should not use custom allocators and instead rely on the general purpose one built into libc because they can add system wide tools there.

    I can see the argument for most cases, that is kinda the point of a general purpose allocator, but encryption (esp if you are doing lots of it) really strikes me as a case where you can really benefit from having explicit control over the behavior. I have worked on a number of applications where custom allocators had significant (user facing, not just benchmarks) impacts on performance. Ironically it also meant we were able to do better checking then the general exploit detection kits since we could bake more specific knowledge into the validator.

    1. Re:Summary. by mr_mischief · · Score: 5, Insightful

      That's all true and correct. When you do that, though, you need to do at least as good a job as what you're circumventing. In this case OpenSSL didn't.

    2. Re:Summary. by jythie · · Score: 2, Insightful

      True, they did not, but I would put that at the level of mistake rather then being unreasonable.

    3. Re:Summary. by akpoff · · Score: 5, Insightful

      Theo's point isn't that OpenBSD users would have been safe. It's that had OpenSSL crashed on OpenBSD (or any OS with similar mitigation in place) it would have surfaced the bug much sooner...perhaps before a worldwide release. Once found it would have been fixed and merged upstream to benefit all users.

      This is really a specific case of the larger point behind avoiding monoculture, whether OS or hardware. OpenBSD continues to support older architectures in part because it forces them to work through issues that benefit other platforms, especially the one most of us use daily: x86.

    4. Re:Summary. by Anonymous Coward · · Score: 5, Insightful

      but if your explicit reason for overriding the kernel is to do something as-good-or-better than the kernel, and you fail to achieve that (let alone validate that you've achieved it), that's a rather spectacular failure. mistakes are common, sure. but this is sort of like saying the seatbelts that came with your car suck (they very well might), so you replace them with something "better", that ends up being little more than a piece of string that you daintily lay across your lap. kind of "unreasonable", no...?

    5. Re:Summary. by bluefoxlucid · · Score: 2

      How is he spot on?

      A specific security feature of malloc() available as an optional security enhancement on OpenBSD has the ability to crash the program in the event of an exploit of this particular bug.

      This feature isn't available on most of the installations of software using SSL, and wouldn't be triggered by OpenSSL unless it was exploited.

      Therefor, if OpenSSL had correctly used malloc() to take advantage of this feature, the situation would be--in reality--no different, except we could say that theoretically the attacks on servers running OpenBSD wouldn't work.

      The reason nobody would have caught it is simple: you'd have to intentionally fuzz the TLS heartbeat feature looking for exploits. You'd only do that when searching for exploits, you'd be analyzing responses, and you'd catch it anyway. It almost certainly would have been caught exactly as fast; and even if it was caught sooner, the impact would be "oh shit everybody in the world change your SSL keys"--i.e. the current situation.

    6. Re:Summary. by bluefoxlucid · · Score: 2

      The heartbleed bug works by the user sending a payload which OpenSSL analyzes and determines to be of a length, like strlen(). Then it calls malloc() to allocate a buffer for that length, and copies that length in. 1 byte payload, malloc(1). Then it looks at the heartbeat handshake, which says, "Oh yeah, my payload is 64KB". Then it allocates a 64KB buffer and does a memcpy() of 64KB from that 1 byte buffer into the 64KB buffer.

      Do you see the problem here? The server looks at the actual data and malloc()s something the size of the data. The client says, "The data is this big," and the server copies something the size the client dictates from where it allocated the data. Problem: what if the data is actually smaller?

      Also, for good measure: The entire bug occurs between an allocation and a free. There actually isn't a free/realloc bug involved. Here, I'll show you.

      This is the vulnerable code. Start on line 3963.

      Line 3974 starts the problem. Variable (p) is an array of bytes; the first 2 bytes are an unsigned int. n2s(p, payload) is essentially (payload = (unsigned int)(*p);). The (payload) value is an unsigned int carrying the length of the payload.

      Line 3991 is your buffer allocation. And it looks like I'm wrong: it allocates a short buffer, which it writes outside of. This was not mentioned on the analysis I read. So a canary should catch this on free() when actively exploited, but not in non-exploit operation.

      Line 3997 is the good part: it copies however many bytes you asked for from the SSL Heartbeat request into the payload buffer. That could be 64kb of shit, and the payload is 1 byte long.

      Line 4002 sends the copied bytes back to the client. This is where the exploit succeeds.

      Line 4009 is where the free() happens. If your glibc has canaries, it crashes here on exploit; this call works normally if you're not being exploited. It also works normally if your payload is short (although other errors may occur elsewhere).

      Even so, it crashes IF AND ONLY IF it's being exploited, and only AFTER exploit returns data, and ONLY on write-bounds-checking allocators that look for a dead canary (which you'll actually know after the first exploit--on a forking process like Apache--and can supply with further exploits, so you can rapidly mine with one crash). If you're not testing it by asking for a bigger payload than you supply, you won't ever get this crash.

      This isn't a double-free() issue. It's a bounds check issue.

    7. Re:Summary. by Lisandro · · Score: 2

      Think it this way. Using the current memory management implementation on OpenSSL adding a test case for the exploit would not have triggered any issues. At all. Using a regular malloc() on any half-decent *nix system would've immediately triggered an alert when run through Valgrind or similar.

      Reusing memory with a freelist on a sensitive library like OpenSSL is a problem waiting to happen.

  6. Why OpenSSL is so popular? by sinij · · Score: 5, Interesting

    Why OpenSSL is so popular? It has FIPS-certified module, and this becomes important for selling your product to the government.

    So what could be done to prevent something like this from happening in the future? People will keep writing bad code, this is unavoidable, but what automated tests could be run to make sure to avoid the worst of it? Someone with direct development experience please educate the rest of us.

    1. Re:Why OpenSSL is so popular? by swillden · · Score: 4, Insightful

      People will keep writing bad code, this is unavoidable, but what automated tests could be run to make sure to avoid the worst of it?

      Automated testing for security problems doesn't really work. Oh, you can do fuzzing, but that's hit and miss, and general unit testing can catch a few things, but not much. Mostly, security code just requires very careful implementation and code review. Eyeballs -- smart, experienced eyeballs.

      OpenSSL has terrified me for years. The code is very hard to read and understand, which is exactly the opposite of what's desired for easy review and validation of its security properties. It needs to be cleaned up and made as simple, straightforward and accessible as possible, or replaced with something else that is simple, straightforward and accessible. My theory on why it is the way it is -- and it's far from unusual in the crypto library world -- is that cryptographers tend not to be good software engineers, and software engineers tend not to have the cryptography skills needed.

      I spend some (not very much, lately) of my time working on an open source crypto library called Keyczar that tries to address one part of this problem, by providing well-engineered crypto APIs that are easy to use and hard to misuse. That effort focuses on applying good engineering to the boundary between library and application code, which is another source of rampant problems, but Keyczar uses existing crypto libs to provide the actual implementations of the primitives (the C++ implementation uses openssl, actually). I've long wished we could find crypto libs that were well-engineered, both internally and in their APIs.

      --
      Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
    2. Re:Why OpenSSL is so popular? by Bill_the_Engineer · · Score: 2

      Why OpenSSL is so popular? It has FIPS-certified module, and this becomes important for selling your product to the government.

      FIPS certification is for a specific compiled version of OpenSSL and is not a blanket certification. The only way you are FIPS compliant is if you document that your product uses the exact same compiled version of OpenSSL or you submit your version of OpenSSL to be certified.

      --
      These comments are my own and do not necessarily reflect the views or opinions of my employer or colleagues...
    3. Re:Why OpenSSL is so popular? by frank_adrian314159 · · Score: 4, Insightful

      First, make sure that code that must be secure is transparent. That means little (or no) optimizations, standard calls to OS functions, and clearly structured. It's clear that the OpenSSL developers made their code more opaque than was prudent and the many eyes of open source land could not see through the murk. Yes, clearer code would mean that it ran more slowly and some folks would need to run a few more servers, but the security problem might have been uncovered sooner (or not have happened) if someone hadn't thought that performance was a reason to make the code more complex.

      Second, formal independent review would have helped. Most code (especially in volunteer-based open source projects) is only vetted by people directly on the development team. Any piece of software as ubiquitous and critical to the operation of today's internet as OpenSSL cannot have verification and validation mainly by its own developers. For software like this, where security is critical, you should have external review. Start an independent project that vets these things, folks.

      Third, understand the limits of testing vs. design. More unit tests would not have caught this. Simple designs lead to simple and correct implementations. Complex designs (or no designs) lead to seas of unit tests that simply tells you the ways that the code happens not to be broken at the moment. Code like that in OpenSSL ideally should be simple enough to be formally proved correct.

      I think we've known about why these sorts of things happen ever since I entered he field thirty years ago. We have ways to prevent them, but they usually take time, money, or lowered performance. That they are still happening because of performance zealotry, bad process, and "teh web-speed is everything" mentality is a black mark on our profession.

      --
      That is all.
    4. Re:Why OpenSSL is so popular? by MarcoAtWork · · Score: 4, Insightful

      it is a generally well regarded and vetted package that supports a fairly rich set of cryptography tasks out of the box.

      I would see that as a drawback for using it in webservers: if I am writing something internet-facing I want to use the smallest and simplest possible library that does the job, maybe it would be time to fork openssl into openssl-core / openssl-extras and have openssl-core have only the most minimal set of functionality related to securing connections and that's it? I would honestly also only support a few platforms for -core to simplify the code analysis even more (the more ifdefs, the more possible issues)

      --
      -- the cake is a lie
    5. Re:Why OpenSSL is so popular? by Daniel_Staal · · Score: 3, Insightful

      In this case though, general unit testing should have caught the bug: There's an option at compile time which, if used, caused the affected versions of OpenSSL to crash. (Because it disables the bug, and OpenSSL was relying on it in one location...) So, good unit testing would have helped.

      Basically, unit testing should be able to tell you if you've implemented the algorithm competently. It doesn't say if the algorithm is any good, just that your version of it works to the spec.

      --
      'Sensible' is a curse word.
    6. Re:Why OpenSSL is so popular? by EvanED · · Score: 2

      Not exactly crypto, but an amusing article on producing a way to compute the entire shuffle of a deck of cards in online poker based on those that were visible: How We Learned To Cheat At Online Poker

      Crypto is harder than card shuffling. :-)

    7. Re:Why OpenSSL is so popular? by Daniel_Staal · · Score: 2

      Point taken. Still, not having unit tests doesn't help...

      --
      'Sensible' is a curse word.
    8. Re:Why OpenSSL is so popular? by Poisonous+Drool · · Score: 2

      OpenSSL has terrified me for years. The code is very hard to read and understand

      I would like to second this thought. For such an important piece of code, OpenSSL is overly complex. That, by itself, is a bug.

  7. Hindsight is 20/20 by slyborg · · Score: 4, Insightful

    So, it's always great fun bashing "obvious" bugs, especially when they have such an impact, but let it be noted that thousands of implementers used openssl to build systems taking the package at face value despite these now "obvious" deficiencies in development process. If you were that concerned about security, they would have done what Google did, and audit the code. There are of course many practical reasons why people can't do that, but regardless, the blame arrow here points both ways.

    1. Re:Hindsight is 20/20 by DMUTPeregrine · · Score: 4, Insightful

      OpenSSL's code is a mess. Go, read it.

      Now that you're back from your stay in the sanitarium, would you like to consider that rewriting it might be a better choice than auditing? Yes?

      Let's just make sure Nyarlathotep isn't on the dev team this time...

      --
      Not a sentence!
  8. Re:5 second read? by ObsessiveMathsFreak · · Score: 5, Funny

    How the hell can you read 298 words in 5 seconds?

    The trick is not to read TFA in the first place. Also, you must be new here.

    --
    May the Maths Be with you!
  9. Bug Looks Deliberate by Anonymous Coward · · Score: 5, Interesting

    That code is almost a text book example of material that is submitted to the Underhanded C contest...

    http://en.wikipedia.org/wiki/Underhanded_C_Contest

  10. Re:So what is an alternative to OpenSSL? by mr_mischief · · Score: 4, Interesting

    GnuTLS, which recently people were being told to avoid in favor of OpenSSL. You see, there was this bug...

  11. Re:How about ... by EmagGeek · · Score: 2

    He's just trying to be a bigger dick than Linus..

  12. Re:not developed by a responsible team? by tsalmark · · Score: 5, Insightful

    My understanding is Theo said: Developers on a security product made a conscious decision to turn off last line of defence security for all platforms in the interest of performance on some systems. That does not sound like and unfortunate error to me, it sounds outright irresponsible.

  13. Re:Who is Theo De Raadt? by dingen · · Score: 2

    Because who in the world has ever heard of OpenSSH, right?

    --
    Pretty good is actually pretty bad.
  14. Really? by oneandoneis2 · · Score: 2, Interesting

    "it is how a few thousand of us feel about the whole thing"

    Then maybe you thousands should stop complaining and start contributing to the project, which is so under-resourced problems like this are pretty much inevitable.

    --
    So.. it has come to this
  15. Re:not developed by a responsible team? by squiggleslash · · Score: 4, Insightful

    He said that, but is that what happened? Were OpenSSL's developers aware that malloc()/free() have special security concerns that OpenBSD's developers had specifically addressed (I assume that's what meant by "a conscious decision to turn off last-line-of-defense-security")

    I understand Theo's point, to a certain degree I kinda understand it, but I'm more inclined to feel the problem is with OpenSSL's developers clearly not understanding the security concerns about malloc(). That is, if they were aware that OpenBSD's malloc() contained code to ensure against data leakage, it would seem to me to be highly probable they would have implemented the same deal in OpenSSL given, you know, their entire point is security. The fact they didn't makes me think they didn't know OpenBSD's malloc() had these measures in the first place.

    Should they have done? And how should they have known? Genuine question, and finger pointing would be inappropriate right now: how do we make sure that certain security strategies and issues are as well known as, say, stack pointer issues are today.

    --
    You are not alone. This is not normal. None of this is normal.
  16. Re:Who is Theo De Raadt? by TCM · · Score: 4, Insightful

    If you've never heard of him, you're not part of any important "tech community". Period.

    --
    Of course it runs NetBSD. BTC: 1NT7QvbetmANwaMzhpVL6
  17. Wow by Kazoo+the+Clown · · Score: 2

    That's pretty scathing. I'd hate to be THOSE guys...

  18. Unfortunately, this analysis seems to be spot-on by gweihir · · Score: 5, Insightful

    In addition, the mitigation countermeasures also prevent memory debuggers like Valgrind from finding the problem (Valgrind find use-before-init for malloc'ed blocks, but not if there is a wrapper in between that re-uses blocks), and may also neutralize code-security scanners like Fortify.

    I have to admit that while my original intuition was "screwup", this looks more and more like some parts of the OpenSSL team have been compromised and did things that make this kind of bug far more likely. Like their own insecure memory allocation. Like not requiring time-of-use boundary checks or having any secure coding guidelines in the first place. Like documenting everything badly so potential reviewers get turned away. Like not having working review for patched or a working fuzz-testing set-up (which would have found bug this easily).

    After all, the NSA does not have to sabotage FOSS crypto software. They just have to make sure the quality is low enough. The bugs they can exploit will follow. And the current mess is just a plain classic. Do enough things wrong and eventually stuff breaks spectacularly.

    --
    Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
  19. Re:not developed by a responsible team? by EvanED · · Score: 3, Informative

    Were OpenSSL's developers aware that malloc()/free() have special security concerns that OpenBSD's developers had specifically addressed (I assume that's what meant by "a conscious decision to turn off last-line-of-defense-security")

    My impression is OpenBSD's hardened allocator is relatively common knowledge and definitely should be among people writing security software. And that's not even remotely the only such allocator out there that does that sort of thing too, though it's probably the most well-known from the industrial side.

  20. His rant could apply to almost any large project by PhrostyMcByte · · Score: 3, Insightful

    A lot of large performance-sensitive projects implement custom allocators in the form of arenas and freelists. Lots of platforms have a fast malloc implementation these days, but none of them will be as fast as this for the simple reason that the program knows more about its memory usage patterns than any general-purpose allocator ever could.

    Not to say I can't understand Theo's point of view -- if he wants maximum security, then a program which bypasses one of his layers in the name of performance might not be the best for him.

    On the flip side, the standards have no notion of such security layers and I feel it is perfectly reasonable for a team to not throw away performance in the interests of some platform-specific behavior. This was a bug, pure and simple. There's nothing wrong with using custom allocators. To say that "OpenSSL is not developed by a responsible team" is simply nonsense.

  21. De Raadt is wrong by stephc · · Score: 2, Interesting

    This is not a problem with OpenSSL, or the C Language or the Malloc implementation, this is a problem because everyone is relying on the same black box they do not understand. Because this is "standard" and common practice to use it. The only long term defense against this kind of vulnerability is software (and hardware?) diversity. Software built on custom SSL implementations may have even worse vulnerabilities, but nobody will discover them, and even if they do, it won't affect everyone on this planet. When I read Theo De Raadt, I fear his "solution" may only worsen the problem. We can't have all our secrets protected by the exact same door, no matter how strong the door is, once it's broken...

    1. Re:De Raadt is wrong by JDG1980 · · Score: 2

      This is not a problem with OpenSSL, or the C Language or the Malloc implementation, this is a problem because everyone is relying on the same black box they do not understand.

      That's a cop-out. Any kind of advanced economy needs division of labor. This is no less true of the IT industry than anywhere else. The people building the "black box" need to know what they're doing and it needs to work. Period.

  22. Whinging & Complaining by Big+Hairy+Ian · · Score: 2

    is not helping!! What would be useful is a list of popular services affected by this issue the BBC is at least making a start here http://www.bbc.co.uk/news/tech...

    --

    Build a Man a Fire, and He'll Be Warm for a Day. Set a Man on Fire, and He'll Be Warm for the Rest of His Life.

  23. Re:not developed by a responsible team? by Eunuchswear · · Score: 4, Informative

    That is, if they were aware that OpenBSD's malloc() contained code to ensure against data leakage, it would seem to me to be highly probable they would have implemented the same deal in OpenSSL given, you know, their entire point is security. The fact they didn't makes me think they didn't know OpenBSD's malloc() had these measures in the first place.

    Not just OpenBSD's malloc(). glibc can do the same thing if you set MALLOC_PERTURB.

    --
    Watch this Heartland Institute video
  24. Re:not developed by a responsible team? by Anonymous Coward · · Score: 3, Informative

    De Raadt wrote "OpenSSL is not developed by a responsible team".

    On the contrary, I believe it was developed by a responsible team, that unfortunately made an error.

    Most everyone have made errors, even if most go unnoticed and are essentially harmless. This one appears different, but I don't think it justifies De Raadt's moronic comment.

    Not so sure they're responsible.

    Did you read this?

    This bug would have been utterly trivial to detect when introduced had the OpenSSL developers bothered testing with a normal malloc (not even a security focused malloc, just one that frees memory every now and again). Instead, it lay dormant for years until I went looking for a way to disable their Heartbleed accelerating custom allocator.

    Building exploit mitigations isn’t easy. It’s difficult because the attackers are relentlessly clever. And it’s aggravating because there’s so much shitty software that doesn’t run properly even when it’s not under attack, meaning that many mitigations cannot be fully enabled. But it’s absolutely infuriating when developers of security sensitive software are actively thwarting those efforts by using the world’s most exploitable allocation policy and then not even testing that one can disable it.

    The OpenSSL team doesn't fully test their product.

    That's pretty much as good an example of incompetence that you can probably find.

  25. Re:His rant could apply to almost any large projec by JDG1980 · · Score: 3, Insightful

    A lot of large performance-sensitive projects implement custom allocators in the form of arenas and freelists. Lots of platforms have a fast malloc implementation these days, but none of them will be as fast as this for the simple reason that the program knows more about its memory usage patterns than any general-purpose allocator ever could.

    This is security software. You don't sacrifice the library's core functionality to make it run a bit faster on the old Celeron 300 running Windows 98.

  26. Re:not developed by a responsible team? by Eunuchswear · · Score: 5, Informative

    Oh, and read this: http://www.tedunangst.com/flak/post/analysis-of-openssl-freelist-reuse

    In effect at some points OpenSSL does:


            free (rec); ...
            rec = malloc (...);

    and assumes that rec is the same.

    Eeew,

    --
    Watch this Heartland Institute video
  27. Natural Born Cancer by VortexCortex · · Score: 5, Insightful

    Well, what you are pointing out is that a CA is a single point of failure -- Something actual security conscious engineers avoid like the plague. What you may not realize is that collectively the entire CA system is compromised by ANY ONE of those single points of failure because any CA can create a cert for ANY domain without the domain owner's permission. See also: The Diginotar Debacle.

    The thing is, nobody actually checks the the cert chain, AND there's really no way to do so. How do I know if my email provider switched from Verisign to DigiCert? I don't, and there's no way to find out that's not susceptible to the same MITM attack.

    So, let's take a step back for a second. Symmetric stream ciphers need a key. If you have a password as the key then you need to transmit that key back and forth without anyone knowing what it is. You have to transmit the secret, and that's where Public Key Crypto comes in, however it doesn't authenticate the identity of the endpoints, that's what the CA system is supposed to do. Don't you see? All this CA PKI system is just moving the problem of sharing a secret from being the password, to being which cert the endpoint is using -- That becomes the essential "secret" you need to know, and it's far less entropy than a passphrase!

    At this time I would like to point out that if we ONLY used public key crypto between an client and server to establish a shared secret upon account creation, then we could use a minor tweak to the existing HTTP Auth Hashed Message Authentication Code (HMAC) proof of knowledge protocol (whereby one endpoint provides a nonce, then the nonce is HMAC'd with the passphrase and the unique-per-session resultant hash provides proof that the endpoints know the same secret without revealing it) to secure all the connections quite simply: Server and client exchange Nonces & available protocols for negotiation, the nonces are concatenated and HMAC'd with the shared secret stored at both ends, then fed to your key-stretching / key expansion system AND THAT KEYS THE SYMMETRIC STREAM CIPHER SIMULTANEOUSLY AT BOTH ENDS so the connection proceeds immediately with the efficient symmetric encryption without any PKI CA system required.

    PKI doesn't really authenticate the endpoint, it just obfuscates the fact that it doesn't by going through the motions and pretending to do so. It's a security theater. SSL/TLS and PKI are essentially the Emperor's New Secure Clothes. At least with the shared secret model I mention above, there's just that one-time small window of PK crypto for secret exchange at worst (failing to intercept account creation means no MITM) and at best you would actually have the CHANCE to go exchange your secret key out of band -- Visit your bank in person and exchange the passphrase, etc. then NO MITM could intercept the data. HTTP Auth asks for the password in a native browser dialog BEFORE showing you any page to login (and it could remember the PW in a list, or even generate them via hashing the domain name with a master PW and some salt so you could have one password for the entire Internet). That's how ALL security should work, it ALL relies on a shared secret, so you want the MOST entropic keyspace not the least entropic selection (which CA did they use). If you're typing a password into a form field on a web page, it's ALREADY game over.

    Do this: Check the root certs in your browser. For Firefox > Preferences > Advanced > Certificates > View. See that CNNIC one? What about the Hong Kong Post? Those are Known bad actors that your country is probably at cyber war with, and THEY ARE TRUSTED ROOTS IN YOUR FUCKING BROWSER?! Not to mention all the other Russian ones or Turkish, etc. ones that are on the USA's official "enemy" list. Now, ANY of those can pretend to be whatever domain's CA they want, and if your traffic bounces through their neck of the woods they can MITM you and you'll be n

  28. Re:not developed by a responsible team? by squiggleslash · · Score: 4, Interesting

    Ouch. Serious ouch. Thank you. That suggests that the situation is considerably worse than De Raadt said.

    --
    You are not alone. This is not normal. None of this is normal.
  29. Re:Who is Theo De Raadt? by KingOfBLASH · · Score: 3, Informative

    Theo De Raadt is the king of tinfoil hats, and behind OpenBSD -- a version of BSD designed to be as secure as possible.

  30. Re:not developed by a responsible team? by mrchaotica · · Score: 4, Insightful

    Should they have done? And how should they have known? Genuine question, and finger pointing would be inappropriate right now: how do we make sure that certain security strategies and issues are as well known as, say, stack pointer issues are today.

    Hell yes they should have known, because the people responsible for one of the most important security applications in the entire world damn well ought to be experts!

    --

    "[Regarding the 'cloud,'] ownership was what made America different than Russia." -- Woz

  31. Re:not developed by a responsible team? by Anonymuous+Coward · · Score: 3, Interesting

    This bug would have been utterly trivial to detect when introduced had the OpenSSL developers bothered testing with a normal malloc (not even a security

    This is simply not true, stop spinning it.

    Even if OpenSSL is using system's malloc, with all its mitigation features, the bug still works. The attacker just has to be more careful, lest he should read freed() and unmapped memory, and so cause a crash and (supposedly) leave some kind of meaningful trail.

  32. Feeding Allo(g)ators by Anonymous Coward · · Score: 3, Interesting

    Allocators in this case make no significant difference with regards to severity of the problem.

    What is or is not in process free list makes no difference when you can arbitrarily request any block of memory you please.. only slightly effects chance of success when it becomes necessary to shoot in the dark. Lets not forget most OS provided optimized allocators keep freed memory in their heaps for some time as well and may still not throw anything when referenced.

    Looking at code for this bug I am amazed any of this garbage was accepted in the first place. There is no effort at all to minimize chance of error with redundant + 3's and 1 + 2's sprinkled everywhere complete with unchecked allocation for good measure.

    buffer = OPENSSL_malloc(1 + 2 + payload + padding);
     
    r = dtls1_write_bytes(s, TLS1_RT_HEARTBEAT, buffer, 3 + payload + padding);

    Suppose I should be glad 1 + 2 = 3 today and they have not used signed integers when dealing with lengths.

    unsigned int payload;
    unsigned int padding = 16; /* Use minimum padding */

    ... oh dear god ...

    int dtls1_write_bytes(SSL *s, int type, const void *buf, int len)

    Well at least they learned their lesson and have stopped sprinkling redundant and error prone type + length + padding garbage everywhere... see..

    + buffer = OPENSSL_malloc(write_length);
     
    - buffer, 3 + payload + padding,
    + buffer, write_length,

    and here ..

    + if (1 + 2 + 16 > s->s3->rrec.length)+ return 0; /* silently discard */
     
    + if (1 + 2 + payload + 16 > s->s3->rrec.length)+ return 0; /* silently discard per RFC 6520 sec. 4 */
     
    + if (1 + 2 + 16 > s->s3->rrec.length)+ return 0; /* silently discard */
     
    + if (1 + 2 + payload + 16 > s->s3->rrec.length)+ return 0; /* silently discard per RFC 6520 sec. 4 */

    ... oh well .. Looks like plenty of low hanging fruit to be had for anyone with a little spare time.

  33. Re:His rant could apply to almost any large projec by phantomfive · · Score: 3, Informative

    To say that "OpenSSL is not developed by a responsible team" is simply nonsense.

    Unless you look at the code, and notice they are using unvalidated data for......anything. That's a rookie mistake.

    --
    "First they came for the slanderers and i said nothing."
  34. The chilling thing about Ted Unangst's analysis by OmniGeek · · Score: 5, Interesting

    As I read his analysis, OpenSSL relies on releasing a buffer, reallocating it, and getting the PREVIOUS contents of that buffer back -- or else it will abort the connection. (Search for the string "On line 1059, we find a call to ssl3_release_read_buffer after we have read the header, which will free the current buffer." in his article referenced by the parent post).

    Now, IMO, this goes way beyond sloppy. Releasing a buffer before you're done with it, and relying on a wacky LIFO reallocation scheme giving you back that very same buffer so you can process it, is either 1) an utterly incompetent coding blunder that just happened to work when combined with an utterly terrible, insecure custom allocation scheme, or 2) specifically designed to ensure that this insecure combination is widely deployed to provide a custom-made back door, as it works only with the leaky custom allocator.

    If 1), then I must agree with Theo that the OpenSSL team were indeed irresponsible, since at least one of these two cooperating blunders ought to have shown up in a decent security audit of the code, and any decent set of security-oriented coding standards would forbid them both.

    If 2), then it was deliberate, and the tinfoil-hat crowd is right for once.

    --

    "My strength is as the strength of ten men, for I am wired to the eyeballs on espresso."
  35. Re:His rant could apply to almost any large projec by neaorin · · Score: 2

    Also, they didn't need to use OpenBSD's stuff - any standard malloc would have caused OpenSSL to abort the connection in this case, as Ted shows in his blog post.

  36. Re:Rev Numbers by ZombieBraintrust · · Score: 2

    I think that might scare people from upgrading. Going from 7.10322 to to 8 is scarier than going from 7.10322 to 7.10322g It suggests that upgrading will break things.

  37. car analogy by spatley · · Score: 2

    mod parent up

  38. the RFC is horrible by DrProton · · Score: 4, Interesting

    Let's not miss the opportunity to point a finger of blame at the RFC, which says " to make the extension as versatile as possible, an arbitrary payload and a random padding is preferred, ". https://tools.ietf.org/html/rf... Arbitrary payload and a random padding for a heartbeat instead of a specified sequence of bits? This is very suspicious.

    --
    "Mit der Dummheit kaempfen Goetter selbst vergebens." - Schiller
  39. Re:not developed by a responsible team? by Anonymous Coward · · Score: 2, Informative

    The OpenSSL team doesn't fully test their product.

    I agree with Theo on the broader point, but disagree here: "their product" is the code they wrote with their custom memory allocator. It's not the code they wrote with some changes someone outside the product made. Their custom allocator isn't disabled or enabled depending on configuration checks or something like that, it's always part of the product.

    It was still a pretty stupid decision.

    Ted Unangst merely used a different configuration option - one provided in the standard OpenSSL software.

    Given some of the other bugs he found, we know for a fact that the OpenSSL team does not fully test their product.

    Period.

    Unangst even found OpenSSL basically assumes that "free(prt); ptr=malloc()" will return the same pointer. Holy fucking shit, you gotta be kidding me. What kind of incompetent boob doesn't test a C/C++ application for that?

    Maybe the OpenSSL folks need to begin a Kickstart campaign to pay for a Purify license or two.

  40. Yep by ledow · · Score: 2

    Can't say I'm surprised. OpenSSL is a pile of dung. It's nothing to do with being written in any language, it's just horrible.

    There's not even any documentation. I mean, literally, none. Nothing vaguely useful. How do I programmatically load a certificate into the store, along with a chain of related trusted certificates, and then set my requirements (must be in-date, must be validly signed, etc.) and get out a "It's fine" / "Something's not right" response? The only answers I could ever find were to follow published examples and tweak.

    And when it comes to working out where in the published examples structure X comes from, or how to convert it to structure Y, you're on your own unless you happen to have picked a comprehensive (and almost certainly not OpenSSL-supplied) example.

    It's just that bad. I was writing a pseudo-DRM for a game / Steam-like distribution platform as a hobbyist project. It was literally horrible to even try to self-sign some certificate and then see if it all panned out later from another computer to guarantee integrity. In the end, I had to "imagine" every possible case and find a way to counter it (i.e. client cert expired, client cert invalid, server cert not signed client cert, server cert has bad chain of trust, client cert not signable for that purpose, etc.) - and almost always there was NOTHING to indicate what the recommended way to do it was.

    There is no decent OpenSSL documentation at all. Not even a decent overview of the process of checking certificates. It scared me at the time, knowing how important the library is, and it can only lead to bad code.

    In the end, I'm quite glad I don't have to program against it for a living. If I did, I'd be seriously looking for something else.

  41. Re:not developed by a responsible team? by OneAhead · · Score: 3, Interesting

    That would have been an appropriate boilerplate response to your typical Theo De Raadt comment, but... did you actually read that "analysis of openssl freelist reuse" link? It's hard for me to imagine that having been done by mistake; it's more of an instance of a coder cleverly cutting a corner. And some might argue "don't we all?", but if one is writing such security-critical software, one should at least have some notion that clever corner-cutting is a gigantic no-no.

    Now, the freelist reuse is not the cause of the heartbleed bug; it merely frustrates what would otherwise have been a relatively straightforward mitigation strategy. But it's a symptom of an attitude that is, well, irresponsible.

  42. Re:not developed by a responsible team? by gnasher719 · · Score: 2

    I understand Theo's point, to a certain degree I kinda understand it, but I'm more inclined to feel the problem is with OpenSSL's developers clearly not understanding the security concerns about malloc(). That is, if they were aware that OpenBSD's malloc() contained code to ensure against data leakage, it would seem to me to be highly probable they would have implemented the same deal in OpenSSL given, you know, their entire point is security. The fact they didn't makes me think they didn't know OpenBSD's malloc() had these measures in the first place.

    Here is what happens, as far as I understand: a client sends two bytes of data to the server and asks the server to send the identical two bytes back to the client, to check that the server is still alive. That's how it works normally. A client could send 65,000 bytes and ask for the 65,000 bytes to be sent back, except that would be inefficient.

    Instead, an attacker sends two bytes of data to the server and asks for the same 65,000 bytes back. The server stores the two bytes with a bit of overhead into a malloc block, creates a huge malloc block for the results, and memcpy's 65,000 bytes from the small malloc block to the huge one. 64,998 bytes that are copied are just whatever was in memory after that malloc block.

    All the usual measures against buffer overwrites don't help, because there is no buffer overwrite. Nothing is destroyed on the server, instead it is tricked into giving information it didn't want to give. What could malloc do about that? A "free" and "realloc" implementation that sets memory to zero wouldn't hurt. Of course that doesn't help if the memory after the small malloc block is actually currently used. You'd need a malloc that will crash if you read past the end of a malloc buffer. That's hard to do efficiently.

  43. Re:not developed by a responsible team? by EvanED · · Score: 5, Informative

    Theo's "rant" isn't brought about by a typical bug in the sense of a mistake in the code. His rant is brought about by the fact that OpenSSL deliberately introduced wrapper functions for malloc/free, making it impossible for a system to provide hardened ones, then made those wrappers default. He further rants about the fact that, because it's default, they later introduced a bug that means you can't turn the wrappers off.

    The heartbeat bug itself was a mistake and a bug in the traditional sense. The "hey let's replace malloc/free" is much closer to "bad decision" than "mistake."

  44. Re:not developed by a responsible team? by EvanED · · Score: 2

    All the usual measures against buffer overwrites don't help, because there is no buffer overwrite. ...You'd need a malloc that will crash if you read past the end of a malloc buffer. That's hard to do efficiently.

    OpenBSD's "usual measures" would have helped, because the OpenBSD allocator will often put allocated memory in isolated pages. So it's quite likely that 64K read will cross into an unmapped page, and boom, you have your crash.

    This level of overread protection is close to free.

  45. Re:not developed by a responsible team? by chis101 · · Score: 4, Informative

    Even if OpenSSL is using system's malloc, with all its mitigation features, the bug still works. The attacker just has to be more careful, lest he should read freed() and unmapped memory, and so cause a crash and (supposedly) leave some kind of meaningful trail.

    You got it exactly right. He's complaining that because they provided their own malloc() wrapper that the read of freed() memory is NOT causing a crash. If they had used the system malloc() then there would be crashes, the issues would be detected, and they would have been fixed.

  46. Re:Test servers your self with PoC by _merlin · · Score: 2

    That's not true. A malicious server can exploit a vulnerable client and read the contents of its memory.

  47. Re:Who is Theo De Raadt? by ppanon · · Score: 3, Insightful

    Theo has been a strong proponent of hard hats/steel helmets, not tinfoil hats. Most people thought that approach was overkill for general walking around, at least up until Snowden showed there were lots of national actors firing lots of rocks into the air.

    --
    Laissez lire, et laissez danser; ces deux amusements ne feront jamais de mal au monde. - Voltaire