-
Notifications
You must be signed in to change notification settings - Fork 687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFE: Alternate cryptographic backends #521
Comments
See also: #390. |
Another advantage of this approach is that a FIPS 140-2 certified implementation could be used where needed. I don’t have such a need, but others do. |
What is your issue with ring's approach to backwards compatibility? Have you restricted the number of available ciphersuites so that executable sizes can be reduced at link time? |
Updates to ring require time before they can propagate through the ecosystem; during this time, people are running an unsupported version. If ring provided security support to major version N - 1, this would not be anywhere near as much of a problem. Hopefully, ring will reach 1.0 and its API will stabilize.
That isn’t always practical for compatibility reasons, and it still won’t be able to beat linking to a shared system library such as OpenSSL. The vast majority of nasty OpenSSL CVEs have been in the TLS and ASN.1 code, not the cryptography, and I suspect many of the cryptographic ones affect ring too. Using a system crypto library means that I can rely on the OS to handle security updates for it, and that those who need FIPS 140-2 compliance can use rustls at all. |
briansmith/ring#535 seems to be planned for the upcoming 0.17 release: briansmith/ring#849 (comment) Could https://github.com/abetterinternet/crustls become a sufficient system package? DTLS support is tracked in #40. (DTLS 1.3 IESG state: "In Last Call (ends 2021-02-22)") As a community we should aim for getting rustls + webpki + ring certified. |
FIPS 140-2 certification is very expensive (tens of thousands of USD, IIRC) and very time-consuming (months or years). Only ring would need to be certified, since that’s where the actual crypto is done, but I still believe that trying to get ring FIPS-certified would be a mistake. LibreSSL dropped FIPS support, and Go never supported it at all. There is a branch of Go using the boringcrypto library (based on BoringSSL) that provides an alternative for those users. In short, the best approach to FIPS 140-2 compliance that I am aware of is to simply offload all cryptography to an OS-provided library. Users who need FIPS 140-2 compliance will then merely need to choose an OS that is already FIPS 140-2 certified, which they would likely need to do anyway. |
@DemiMarie Do you yourself need FIPS support? If not, why don't we drop that topic and wait for somebody who actually needs it to ask for it. |
BTW, tens of thousands of dollars isn't a lot of money for these projects. Hundreds of thousands of dollars have already been invested into them. |
@briansmith I do not. I merely brought it up because I know some people do, and as a reason someone might want to use an alternate crypto backend. |
Red Hat Enterprise Linux needs it. My understanding is that rustls cannot ship in RHEL unless it uses one of RHEL’s existing cryptographic libraries. IIRC, those are libgcrypt, Nettle, NSS, and OpenSSL, along with the kernel cryptographic code. |
Ran into so many problem with building |
It is in fact treated as such, on all major platforms. @ctz: would you accept a high-quality PR that included an OpenSSL backend? |
People who need that might be better served by using rust-native-tls. |
I consider rustls to be a better TLS implementation than OpenSSL. The majority of OpenSSL’s security holes have not been in the crypto, but rather memory safety issues elsewhere. Since most of the problems with rustls seem to be due to ring, using OpenSSL for the crypto instead seems to be an obvious alternative. |
I have also encountered a lot of issues regarding ring, cross-compiling, linking and the multi version issue of ring ( the most annoying one for me personally ). Given the above, I still do not believe that changing rustls to include openssl as a backend is the right approach, since it might actually hinder development for this project. I think the correct approach would be to create a wrapper-crate towards the entire rustls, and unyfing on an API, that could in turn switch between rust-native-tls and rustls, preferably in a drop-in manner, meaning that if one were to write an application or library using rustls, but needing a feature that is currently not in rustls because of some dependency. Then that would be treated as a "quick and dirty fix" until such time as it is supported by rustls. The "quick and dirty fix" and "until", is the basis for my reasoning, since I believe that creating a drop-in wrapper crate would be faster. And that it should be a treated as a temporary ( yeah, i know) solution to using rustls. |
The multi-version issue in ring is mostly fixed in ring's main branch now; see briansmith/ring#1268. Review and testing of that by others would be appreciated. Cross-compilation of ring has made big progress in ring's main branch as well. IIRC, there is now a C or Rust fallback for everything, so platforms for which ring doesn't have assembly language code are now supported. There is work underway to verify this with the MIPS little-endian port. After that, I think we'll have to clean up some stuff that's not supported for big-endian archs yet, but that should be relatively easy. |
Personally, I wold still like to be able to link to system-provided cryptographic libraries instead. The main reasons (in no particular order) are:
In short, I am not particularly interested in |
I now think it would be valuable to add high-level traits in rustls that abstract over the crypto operations. If we were to do that, I don't think we should include other implementations as part of rustls -- it would be up to downstream users to decide whether to trust another implementation. We might even guard the use of alternative implementations with a feature flag like |
I'd second that. One of the recommendations in the audit was to use formally verified crypto. High-level crypto traits would allow rustls to do so, for example using evercrypt. |
@briansmith So, I like Rust (a lot) and I have a lot of folks that need FIPS compliance. As mentioned, RHEL implemented This would be a HUGE boon to the adoption of Rust in places that require FIPS crypto. |
This is also a hard requirement to use hardware cryptographic accelerators. These require cryptography to be asynchronous, as they have very deep pipelines that need to be kept full. |
Is there any further discussion? Our community hopes to be able to provide a backend for wasi-crypto, and a middle layer is essential. I wish to get some tips about how to design it and pull request back to the upstream. WasmEdge/WasmEdge#1430 |
There has not been any further discussion. If you or your community wants to work on this, I'd be open to reviewing a potential design. I think essentially it would have to be a high-level set of traits that essentially mimic the current ring API to cover the rustls crypto requirements that are not currently covered by traits. |
Maybe the |
That is a very different level of abstraction, which wouldn't allow re-use of the non-cryptography code in rustls. |
Above it was said that ring has fallback paths in Rust -- do those not get used with Miri for some reason or are there no fallback paths for some operations? (Also obligatory reminder that Miri by default provides deterministic execution, so don't run any code that needs proper randomness in Miri on real data!) |
Honestly I had missed that there were fallbacks. Though note:
A C fallback isn't much use for Miri because it's still FFI, right? |
@djc any updates on this? |
True. |
For the current state, have a look at #1405. In short, the next semver-incompatible rustls release (which we expect to happen within a few weeks from now) will have support for pluggable crypto providers. |
Amazing, I totally missed that! looking forward to trying it out |
This is awesome progress. I have a (possibly naive) question. How do we audit what provider the compiled application is configured to use? As in, given binary X, what do I run to determine if it is using a provider that is allowed by my organization? |
AFAIK https://github.com/rust-secure-code/cargo-auditable could help you tell which dependencies are compiled into your binary. That should be an important part of the puzzle, although in any given binary there might be multiple sites that instantiate a rustls config and all of these might use a different crypto provider, and that might be harder to check from a binary. |
@djc That's what I suspected. It's definitely a use case that should be accounted for at some point but it sounds like the "right answer" is to always compile from scratch at this point. ( cries in 90's pre-packaging hell ) |
If you need to only use FIPS 140-certified cryptography, then you will likely need to build everything yourself indeed. There are lots of other Rust cryptographic libraries out there and you will need to make sure that none of them are built, or replace them with versions that call whatever certified cryptography is on your system. |
@DemiMarie It is certainly making Unfortunately, the burden is almost to the point of untenable for large application bases. |
Could you detail what your requirements are? Is it just the normal FIPS140 ones, ie all cryptography must be FIPS approved or FIPS allowed, and approved cryptography must be a FIPS140-certified implementation? Anything more than this? |
@ctz That's the one. But that only applies for everything that uses cryptography for the "protection of sensitive data". This means hash algorithms down the stack and, of course, the correct configuration of each. It gets more complicated by the fact that technically you can use non-FIPS algorithms as long as you're not using them for "protection of sensitive data". It's easier to just ban them outright but not actually required. So, could I use the md-5 crate for doing a bunch of checksums to prevent collisions on temp files in the filesystem that can't affect a security path? Sure! Is it hard to determine that I'm using it specifically for that use...yes. Some languages have the ability to toggle FIPS with a setting that essentially says "I'm doing the bad thing but it's OK". Likewise, some vendor implementations tie them into lower levels that remove the algorithms altogether for safety and break that application path. But, in the end, the questions that needs to be answered are:
|
@trevor-vaughan Do you just need to use approved algorithms, or do you need certified implementations of those algorithms? The latter is likely going to mean sending a bunch of patches upstream — there are good reasons (notably better APIs) why people use pure-Rust crypto implementations over the system libraries. |
@DemiMarie If you need to meet the FIPS requirement, it must be the certified implementation.
|
@trevor-vaughan we'd definitely like to make rustls an option for FIPS-certified environments so would be interesting to hear more about what challenges you have with Rust compared to, say, C++. Might also be interesting to bring this up in the wg-secure-code stream in the rustlang Zulip. |
@djc Right now, it's more In the case of any compiled language, you're definitely at the mercy of the one doing the compiling and I'm definitely starting to have 1990's |
The problem we have for OpenSUSE is much simpler - we have to build some projects on arches that arent x86_64/aarch64. Ring almost constantly fails to build on these. Because rustls is used so commonly, with no alternatives in projects, then it means we can't build a lot of projects that depend on rustls for other arches. So having the ability to set alternate cryptographic backends would help us here by allowing us to build more easily on alternate arches. |
@trevor-vaughan sorry, it's not very clear to me what you mean here with the Go vs Rust compilation issue. I think you're suggesting that Rust's compilation model causes issues for your FIPS story, but I don't understand why? |
@djc I came upon this issue when I was trying to find "the way" to flip the Rust backend over to use Golang provides IIRC, in the early days, Rust pretty much used In both cases (and every other language) you do have to make sure that someone isn't dragging in some random package to do crypto but the golang (and javascript, python, etc...) pattern of having a "core" crypto library that 99% of folks use makes it much easier for regulatory focused shops. |
Ah, so you're talking about the dependency graph model that Cargo has. So from this perspective, would it help you if the rustls ring backend lived in a separate crate, so that you could check your |
🤔 Actually, yes, that might help quite a bit. Any way that makes it easier to determine exactly what is in use (or not) is a win. |
We've made a start on this in the recent 0.22 release. Shipping FIPS140 support is tracked in #1540. |
rustls currently depends on ring as the only crypto backend.
While ring is certainly a good crypto library, it has a poor story regarding backwards compatibility. Additionally, it is statically linked, which bloats executables.
Therefore, I am filing this RFE to request support for alternate cryptographic implementations, such as OpenSSL. This would require figuring out a story for certificate verification, since we don’t want to use OpenSSL’s certificate APIs and WebPKI only supports ring. That said, on Windows and macOS there are valid reasons for just using the platform’s native certificate verification APIs instead.
The text was updated successfully, but these errors were encountered: