Skip to content
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

Consolidate TLS backends used by libcurl in cargo to reduce delays in security fixes or enhancements #8154

Open
x448 opened this issue Apr 24, 2020 · 6 comments
Labels
A-networking Area: networking issues, curl, etc. A-security Area: security C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage.

Comments

@x448
Copy link

x448 commented Apr 24, 2020

Describe the problem you are trying to solve

Detecting and supporting TLS features in every combination of OS version, OS component version, and Active Directory policy setting can get tricky.

Improvements are made more complex because there are too many TLS backends for libcurl:

Schannel has these disadvantages:

  • crates.io and Windows 7, 8, and 8.1 are always going to connect with a weak cipher suite. Microsoft might sunset Windows 8 and 8.1 in 2023.

  • Active Directory policies can enable/disable cipher suites without the user knowing. This can create support issues and make hardening TLS trickier for cargo.

  • Linux and Windows are prevented from having the same syntax for cipher suites.

MacOS 10.14 supports strong TLS 1.2 cipher suites, but I don't know what would happen if the same is specified on various older versions (ignore unknown values, quietly downgrade, or cause error).

Describe the solution you'd like

cargo for Linux, MacOS, and Windows should use OpenSSL and/or LibreSSL for its libcurl backend.

This would eliminate the Schannel disadvantages already mentioned. It would simplify and reduce effort required to harden TLS (#8113) and the same for providing a libcurl cipher suites option in cargo.

Work required for standardizing TLS backend for libcurl can be offset by not having to harden Schannel and Secure Transport against TLS 1.2 downgrade attacks. It's a good opportunity to simplify code and remove roadblocks.

Official curl binary for Windows uses OpenSSL 1.1.1f statically linked. So we can examine its code (if needed) to see how libcurl+OpenSSL is used on Windows. Maybe same for MacOS by looking at homebrew or macports (if needed).

Notes

Pull request in curl-rust to add static OpenSSL option for MacOS and Windows:
alexcrichton/curl-rust#284

Schannel on Windows 7, 8, and 8.1 doesn't support ECDHE_RSA with AES_GCM according to docs.microsoft.com.

Default cipher suites supported by Schannel when not modified by Active Directory policies:

crates.io only offers 2 strong TLS 1.2 cipher suites and both use ECDHE_RSA + AES_GCM which isn't supported by Schannel on Windows 7, 8, and 8.1.

(click to expand) 📷 crates.io TLS 1.0-1.2 cipher suites in April 2020 (SSL Report)

image

@x448 x448 added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Apr 24, 2020
@x448
Copy link
Author

x448 commented Apr 24, 2020

I updated issue to mention official curl binary for Windows uses OpenSSL 1.1.1f statically linked. So we can examine its code (if needed) to see how libcurl+OpenSSL is used on Windows.

Maybe same for MacOS by looking at homebrew or macports (if needed).

@x448 x448 changed the title Standardize on OpenSSL/LibreSSL for libcurl TLS backend because supporting too many TLS backends hinders progress Consolidate TLS backends used by libcurl in cargo to reduce delays in security fixes or enhancements Apr 25, 2020
@ehuss ehuss added A-networking Area: networking issues, curl, etc. A-security Area: security labels Apr 29, 2020
@alexcrichton
Copy link
Member

The main reason that we don't do this today is around system certificates. While OpenSSL finds system certificates on Linux pretty well, the system certificates stores on macOS and Windows were historically a bit harder to access. This evaulation, however, was done years ago at this point and things might be quite different now at this point.

@x448 would you be willing to help investigate this to implement this? It'd be great if we could ship a single TLS library on all platforms for sure! Deploying this is likely going to be very tricky since it's only really going to trip up users in "esoteric" setups, but it'd be great if we could have a temporary runtime switch for which TLS library to use to get testing on nightly. This would require implementation work to figure out the issue with system certificate stores and investigate whether a runtime switch is possible. Would you be willing to help out implementing these bits?

@joshtriplett
Copy link
Member

I'd love to see this as well. There are many things we could do more easily if we know which backend we're dealing with.

@howard0su
Copy link

Do we consider completely replace openssl with rustls?

@joshtriplett
Copy link
Member

That'd be perfectly fine, as long as it still uses the system certificate store.

@lu-zero
Copy link
Contributor

lu-zero commented Oct 19, 2020

Would we replace libcurl with reqwest or hyper while at it?

LawnGnome added a commit to LawnGnome/cargo that referenced this issue Jul 21, 2023
Making this change allows cargo to be used on Windows 7 and 8.1 against
the current Fastly TLS configuration.

This does the minimal amount of plumbing required for curl to be built
with rustls as the TLS backend, and for rustls to be configured with the
system store's root certificate bundle. (Using webpki_roots would be
inappropriate, since enterprise users may have custom CA roots
configured.)

I've made no effort to make this configurable thus far. Presumably we'd
only want to do this on Windows, if at all.

Technically, this would fix rust-lang#8154.
@epage epage added the S-triage Status: This issue is waiting on initial triage. label Nov 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-networking Area: networking issues, curl, etc. A-security Area: security C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

7 participants