by tptacek · 6y ago · 0 comments
The right response to this vulnerability is to jettison support for anything but named curves.
This is probably an inside-baseball argument for people who don't pay attention to elliptic curve implementation details. But it's easy to quickly understand.
Go to SAFECURVES.CR.YP.TO; you'll see a big long list of curves, each with their parameters and some implementation details. In reality, only a subset of these curves are commonly used (P-224, P-256, Secp256k1, and Curve25519 probably account for 95% of all curves).
Further, most specific curves are implemented not as parameters plugged into a generic elliptic curve scalar multiplication routine, but rather as curve-specific code (one of the major reasons we have different curves is to allow specific implementation optimizations). A browser that supports Curve25519 certainly uses Curve25519 code, not generic code.
The "explicit curve" feature that blew up on Microsoft is designed to allow people to specify their own parameters, not for well-known curves but for curves they themselves generated. Nobody does that. There was a time, in the long long ago, when people thought that might be a good idea; nobody thinks that anymore; everyone thinks the opposite thing. If anything, we're trying to get rid of a bunch of curves. Certainly we shouldn't be randomly supplying new Weierstrass curves.
So that's the problem here. A lot of cryptography engineers were probably surprised this CryptoAPI feature even worked. We had considered it awhile ago as a cryptopals challenge (and Sean actually did add it as one in Set 8 a few years ago), but we never dreamed anyone would be crazy enough to let this bug happen in the real world.
Over time, this has been shown to open up a big security vulnerabilities such as this one, and also issues with key agility in TLS, etc.
I think the tendency today is to make make crypto more omakase where there are a few well studied, well implemented algorithms that you use for everything.
The Windows CryptoAPI is from that older time.
Part of the problem of the Windows CryptoAPI in question is that it has to serve "both customers", the omakase sort that need the best option, and the a la carte needs to higher level tools serving as the omakase option. That is, for some traditional/legacy C/C++ users that CrpytoAPI is about as high level as they will get, and it's up to the documentation to steer its consumers to the best omakase options. But crypto32.dll also is the low-level backend of tools like WinRT's Windows.Security.Cryptography and .NET's System.Security.Cryptography (on Windows).
The push towards omakase and somewhat getting applications away from micromanaging the a la carte stuff, definitely seems the smart path. Handling the onion of it all in what needs to be supported at a low level to keep the high level omakase shop running smooth seems like it still has a lot of pitfalls.
I'd be happier if nobody used the P-curves (they're unsafe for other reasons). But that's got nothing to do with whether people should literally be plugging their own Weierstrass coefficients and base points into X.509.
Standards should immediately deprecate support for explicit curve parameters.
I don't believe it exactly either, I just know it as a zeitgeist reason why some of the dialog about curve changes has been happening. In hindsight I supposed I'd have been better off not mentioning it.
> Standards should immediately deprecate support for explicit curve parameters.
I agree and that wasn't the intent of my post, if it came across that way. While elsewhere in the thread it is mentioned that many named curves are implemented standalone, my understanding is that not all of them are.
I was only suggesting that crypto32.dll is intended to be low level enough that it is possible that some of the higher-level APIs that Microsoft has built that do focus on named curves only (such as the UWP/WinRT and .NET APIs I mentioned) may rely on the explicit parameter support in the lower level library. I don't envy Microsoft the task of balancing what is in a low-level API like that versus backwards compatibility, "upwards" compatibility with high level components, etc.
In other words I would not be to surprised if NSA found this bug by accident because it caused some of their internal “secret” cryptosystem to not work at all instead of by actively looking for it.