LibreSSL, and the new libtls API
openbsd.org
openbsd.org
No matter how you feel about the forking or the openbsd team, there is something to be learned here. There are times when forking, deleting old code, and major clean-ups can be very useful strategies. Sunk cost bias can be an enemy of progress.
[1] - https://en.wikipedia.org/wiki/LibreSSL#Security_and_vulnerab...
This is the current roadmap. https://www.openssl.org/policies/roadmap.html Picking out a few highlights: * "Objective met (2015): The FIPS code has been removed from the master branch, and will be re-integrated more cleanly during a future validation. " * "Objective met (2015): All use of dynamic memory allocation has been cleaned up and made consistent, and the internal memory pool has been removed. "
Under Coding Style: * "Objective met (2015): All release branches were reformatted using a script included in the release." (so all code now adheres to a consistent style at least, which is a good starting point)
And amongst their targeted goals now: * Legacy platforms that are unlikely to have wide deployment will be removed from the code. .. but .. * Non-supported platforms requiring regular maintenance activities will eventually be removed from the code after first seeking community owners to support the platforms in platform specific repositories.
Not convinced that's necessarily the right route, but I can appreciate where they're coming from.
While attending a security conference in Vancouver earlier this year, someone commented that they thought the OpenBSD team was childish for forking LibreSSL, and several people chimed in with agreement.
Of course this is all hear-say for you, and your experiences may vary. I've met more than a handful of people who did not like the fork. There are lots of people in the world, and they all have different opinions.
If you don't, people still clamor for legacy support and bug-for-bug compatibility. A fork is the only way of truly signalling "We aren't going to support our old mistakes anymore."
New features don't need forks, but cleaning up raging stupid and cruft does.
When you want to make idealogcal changes to an existing codebase that does not mesh with the idealologies of the maintainer(s), forking is a great way to make your changes happen. Time will tell if your ideas were good ones. That and how well your maintain and promote your fork. :-)
In the case of OpenSSL vs LibreSSL, it appears the OpenBSD team made a great call and they are making it work really well. As for if anyone else agrees and adopts it, only time will tell.
I suppose that this attitude comes from people who think the fork happened solely because of Heartbleed, when the real reasons are a little more intricate[0] but the straw that broke the camels back was the discovery that OpenSSL had known about certain bugs and let patches to fix them rot in their bug tracker for years. It's hard to contribute changes back when a project won't take patches.
OpenSSL could have taken LibreSSL's changes if they wanted to, it's all public in the OpenBSD source tree, but they haven't.
The OpenSSL developers would have a much tougher time dropping MSDOS and VMS and OS/360 support because there are still a couple of people who need it.
Every horrifying thing in there is justifiable because "someone might be using it". Not enough reason to risk the security of every net-connected Unix over.
Problems are easier to spot when there are less underlying assumptions.
I think at some point, if you've got a legacy application running on such an old platform, the cost of maintaining your own fork of libraries like OpenSSL has to fall on you eventually.
Although OpenSSL themselves continuing to maintain these ancient ports is admirable in a way, the unmaintainability it has caused to the code base as a whole is a serious problem that has reduced security for everyone.
Less code http://www.openbsd.org/papers/libtls-fsec-2015/mgp00004.html
What's wrong with the OpenSSL API http://www.openbsd.org/papers/libtls-fsec-2015/mgp00007.html
TLS small set of functions http://www.openbsd.org/papers/libtls-fsec-2015/mgp00009.html
read() and write() semantics http://www.openbsd.org/papers/libtls-fsec-2015/mgp00011.html
No need for handling errno EAGAIN/EINTR yay! http://www.openbsd.org/papers/libtls-fsec-2015/mgp00016.html
There's more stuff like event/poll, but I don't want to link more. The presentation is very interesting.
Yay for EINTR, but you're still handling EAGAIN; it's just called TLS_POLLIN/TLS_POLLOUT now. (Not that this is a bad thing: this is exactly what I'd expect from such an API, as it needs to integrate with the local event loop.)
The "What's wrong with the OpenSSL API" is excellent: a coworker ran into this just recently. A client was failing to connect, and had SSL23_XXX in the stack trace, and he wondered why it was using an outdated version of SSL; since we've long since disabled support for SSLv3 server-side, he figured — reasonably — that the client was failing to connect for that reason.
For those wondering, from the Python docs, which have the best explanation I know of:
> ssl.PROTOCOL_SSLv23
> Selects the highest protocol version that both the client and server support. Despite the name, this option can select “TLS” protocols as well as “SSL”.
I think their point is that you just have to check the return value to know how to proceed, you don't have to check the return value and errno.
Note: I'm not a C developer nor do I typically work at this level of the stack, thus my seeking opinions.
But there's a significant difference between auditing, cleaning up, and fixing up an old code base (which, however crappy, contains a lot of domain knowledge and bug fixes that have built up over the years), and a project to write exciting new bugs from scratch, in whatever language.
Tony Arcieri's talk in particular covers a lot of the areas Rust help prevent some of the recent snafus but also covers the areas Rust might be more dangerous to implement crypto in https://speakerdeck.com/tarcieri/thoughts-on-rust-cryptograp...
Videos: https://air.mozilla.org/bay-area-rust-meetup-december-2014/
The BSD team needed a library that worked pretty much straight away as a drop in replacement, and then they could gradually bring in a new API on the side. If they had rewritten we'd still be waiting.
Also, the OpenBSD guys are really good at writing C. They have far safer versions of the standard memory and string handling functions, better functions for allocating arrays to guard against integer overflows calculating the size, etc., and the skill and strict standards to use them properly.
I've been meaning to post on the mailing list, but I have some requests I guess I'll try here:
- For libtls, accept custom read and write callbacks. libuv has no way to poll for writable: https://github.com/libuv/libuv/issues/517
- I wish they would provide (and maintain) the modern cyphersuite from here: https://wiki.mozilla.org/Security/Server_Side_TLS ("secure", "legacy" and "high" are all lacking in various ways)
These are fairly minor issues and overall LibreSSL and (especially) libtls have been a huge step forward. Thanks again.
I'd love to get away from some of openssl's arcane flags... :-)
/usr/bin/ssh -V
OpenSSH_6.9p1, LibreSSL 2.1.7 $ openssl version
OpenSSL 0.9.8zg 14 July 2015
$ which openssl
/usr/bin/opensslDon't forget their version is ancient (API-wise; they back-port fixes) and LibreSSL is much newer, so it's not a drop in replacement for such an old version.
Lo, how times have changed. ;-)
Apple thus stopped shipping OpenSSL and has officially deprecated it, these days you won't find headers for it anywhere in the stock system and there is no official way to link against it anymore either in El Capitan. It just exists for backwards compatibility.
If a developer now wants to use OpenSSL in their binary instead of the Common Crypto framework that Apple provides they will have to provide their own version of the library in their application, and they are then responsible for making sure users get patched in time.
These two links roughly explain the issues/reasoning:
http://rentzsch.tumblr.com/post/33696323211/wherein-i-write-... http://ludovicrousseau.blogspot.com/2011/08/mac-os-x-lion-an...
for example any demo code for me to try out the libtls?
You can read example code use by browsing the source codes of the applications listed in the presentation such as netcat and httpd.
Also, they ripped out a bunch of what they called "exploit mitigation countermeasures" in OpenSSL's memory allocation code.
For example, I find worthless the Annex K of C11 as solution for memory corruption, because the functions still require to keep track of a separate pointer and size, while making sure they match. And the Annex is anyway optional.
However OpenBSD coding guidelines do look quite good:
http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man9/...
I like that they request developers to make use of static analysis.