202 points · by patrickmn · 10y ago · 61 comments
I'm surprised to learn that Go did not already check the result of calculations; that's a pretty standard countermeasure, also to e.g. protect your private key on somewhat-unreliable hardware.
There was a carry propagation bug in OpenSSL/BoringSSL/LibreSSL just a few weeks ago.
And nit: The OpenSSL bug didn't affect libressl (I discovered it, I checked for that).
Yeah. As the announcement says, it's coming in 1.6 and we (CloudFlare) backported it in our public tree, in case anyone else wants to use it: https://github.com/cloudflare/go/commits/go1.5.3-cloudflare1
However, I was proposing verifying the signature - which involves only the public key and the signed data, neither of which are likely to be all that sensitive.
(The situation is more subtle for RSA decryption.)
https://groups.google.com/forum/#!topic/golang-announce/MLaP...
If you're using Go, you should already have the infrastructure to do this. Everything we have gets rebuilt for each go release anyway, so this is no different, just a little more immediate.
Unless you're using packages in an APT or Yum repo. You instead get to wait for packages to come downstream, almost certainly not in anything approaching synchronicity. Awesome.
We got away from statically linked monoliths for a reason.
It's been particularly bad in the past for things like nginx, where we've known about memory corruption bugs for multiple days and had clients who were incapable of patching because they only had infrastructure for downloading packages.
You should have tools in place to build, from source, anything that might be a significant security issue.
Imagine the nightmare of having to hunt tens of shared libraries versions, and even have to re-build them and patch them with the correct version of the language/apis so that they continue to work.
But it's probably not so trivial to hunt down every single old binary on every system. There's also a continuous risk that you may receive old binaries from third parties in the future.
For example, gitlab has started to ship a component written in Go in recent versions. Things like these are easy to forget about.
http://blog.skylable.com/2014/05/tweetnacl-carrybit-bug/
StackOverflow had nothing useful with that phrase. Weird. I tried Modular and Montgomery Multiplication as they're important key words that should give you an idea about potential carry issues. I found these decent descriptions in my short Googling:
https://en.wikipedia.org/wiki/Kochanski_multiplication
http://www.hackersdelight.org/MontgomeryMultiplication.pdf
Best I can do with little time and the flood of irrelevant results I saw. Maybe need a thorough write-up on these sorts of things that shows up in Google. At least I serendipitously found a great paper on statically detecting flaws in error propagation:
http://pages.cs.wisc.edu/~liblit/dissertations/crubio.pdf
So, thanks for asking even if not an intended benefit. :)
A carry propagation bug is a special case of a fault attack. Fault attacks, in their most general form, are attacks where an adversary tries to induce an error during a cryptographic computation. The consequences of a fault during a computation are algorithm-specific; here are some examples:
- In RSA, a fault during a decryption or signature operation using a particular (CRT) implementation approach lets the attacker recover the private key [1]. You do this by obtaining an incorrect signature S for some message M you know about, and then recover one of the prime factors of the modulus with the easy computation gcd(S - M^e, N). This is often called the Bellcore attack.
- With elliptic curves, if you can convince a scalar multiplication to work on an incorrect point on the curve (either because the implementation doesn't check the point is valid, or via a hardware fault), you can likewise recover the secret key [2]. The process here is a little more complicated, but no less efficient.
- With AES, if you can trigger a fault in a state byte right before the eighth round, you can recover the full key very easily having both the valid ciphertext and the erroneous one [3]. This attack only makes sense for hardware implementations, since software implementations of symmetric ciphers do not generally leave much space for errors to occur.
In the Golang case, the carry bit failure leads to the Bellcore attack. All you have to do, in principle, is to harvest around 2^25 RSA signatures (and respctive messages) from a buggy target, compute a GCD, and you're done.
[1] https://doi.org/10.1007/3-540-69053-0_4
I would have expected them to learn from Javas mistakes and use something that has a hope of being maintained indefinitely and isn't coupled to something like language version. JSSE (TLS implementation in Java) is so broken and behind Tomcat ships with some marshal interface to OpenSSL, but that takes considerable effort and software converges to language defaults.
The specific type of cryptographic flaw that occurred here is common to virtually all crypto libraries. As I said upthread: even Nacl got bit by carry propagation. Using OpenSSL wouldn't have protected Go from these kinds of flaws; OpenSSL has had several carry bugs.
Do you know if this is still true? Or does it even matter, if OpenSSL is the only other contender for TLS? As someone who has no expertise in crypto, it's hard to make sound judgments.
> It's really up to the provider of the service in question to make the call. All we can say about crypto/tls is that it hasn't been thoroughly reviewed from a cryptographic standpoint. Whether that suits your use case or not is very much up to you.
That is still true. Of course, the implementation has been reviewed and beat on in production use more now than it had been in 2013, but the fact remains that there has been no systematic, independent outside audit focused specifically on cryptography. On the other hand, the cascade of "interesting" bugs since 2013 like Goto Fail and Heartbleed suggests that maybe the other implementations are not quite as audited as one might have expected.
As tptacek mentioned in another comment, Adam Langley is the primary author and maintainer for Go's crypto packages. He's also one of the key people involved in Chrome's TLS implementation and Google's use of TLS more broadly, and he's a significant committer to OpenSSL and the creator and maintainer of BoringSSL. You can learn more about his work at his blog, imperialviolet.org. Having Adam involved with Go's crypto/tls raises my comfort level considerably. It's not Joe Random (or Jane Random) working on the crypto code, as others suggested below. Even so, even experts make mistakes and it would be nice to get a second expert to go through it looking for problems.
For the most part Google does not use Go's crypto/tls for user-facing traffic. That is primarily a detail of Google's pre-existing serving architecture (we use separate servers to do that, much like putting nginx in front of your main server, and many engineering years of work went into those servers before Go even started). Because of that, Google has not really evaluated Go's crypto/tls one way or the other for that use. I believe we do run Go's crypto/tls to serve HTTPS on godoc.org, although I'd have to double-check. I certainly run it on swtch.com, rsc.io, and so on, not that there are real secrets in any of those servers.
I suspect the largest production user of Go's crypto/tls is CloudFlare. Maybe someone from there can say something about their comfort level or exposure.
Like Andrew said, it's really up to the provider of the service to make the call. You can have the same bugs as everyone else, or you can have a different set of bugs.
I'm not sure I understand how Go's implementation is so much better when your justification is that they are making the same mistakes other libraries already have. The bar should be higher for new software, not the same.
It makes it really easy to build software and distribute it to your server farms.
If you want, you can link OpenSSL statically. It's about as recommended as statically linking the entire universe into a binary.
Go's crypto wasn't rolled out by amateurs.