fix: add missing TLS1.3 p521 sig schemes #4496
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolved issues:
Related to #3916
Description of changes:
TLS signature schemes are a combination of a signing algorithm / certificate type (like ECDSA) and a hash algorithm (like SHA512). Starting in TLS1.3, ECDSA signature schemes also imply a specific curve (for example, ECDSA+SHA512 requires p521).
s2n-tls uses “struct s2n_signature_scheme” to represent TLS signature schemes. When TLS1.3 support was added, separate “struct s2n_signature_scheme”s were added for each TLS1.3 ECDSA signature scheme despite those schemes having the same IANA value as the existing TLS1.2 versions. That means that we have both a TLS1.2 “s2n_ecdsa_sha512” and a TLS1.3 “s2n_ecdsa_secp521r1_sha512”.
As a consequence, security policies can choose to support ECDSA signature schemes for only TLS1.2 or for only TLS1.3. The same behavior is not possible with RSA signature schemes. We also potentially send duplicate ECDSA IANAs in our ClientHellos, but that has not actually caused any incompatibilities yet.
Note: Do you keep making typos by referring to both 521 and 512?: Hopefully not. The hash algorithm is SHA512, but the curve is p521. It’s awful and I apologize if I do mix it up.
The Problem
We apparently forgot to add “s2n_ecdsa_secp521r1_sha512” (the TLS1.3 version of ECDSA+SHA512) to several policies that support TLS1.3 and contain “s2n_ecdsa_sha512” (the TLS1.2 version of ECDSA+SHA512). The root of the problem is really one set of signature schemes shared by a large number of policies— basically, we forgot to add “s2n_ecdsa_secp521r1_sha512” in one place.
This led to a customer trying and failing to use a p521 certificate for mutual auth, because their security policy did not support any ECDSA signature scheme compatible with p521. They could successfully use the same certificate with TLS1.2. I accidentally ran into the exact same problem when I tried to reproduce, because I incorrectly assumed “default_tls13” would behave sanely.
The obvious solution is to fix the mistake and add “s2n_ecdsa_secp521r1_sha512” to any TLS1.3 security policy that supports “s2n_ecdsa_sha512”. However, that is technically modifying existing versioned security policies, which we don’t do.
Longer term, I’d also like to combine “s2n_ecdsa_sha512” and “s2n_ecdsa_secp521r1_sha512” into one s2n_signature_scheme that is usable with both TLS1.2 and TLS1.3. That will have basically the same implications as this change, but also simplify security policies to avoid this whole category of mistakes.
Why is the current behavior a bug instead of a design choice?
What is the behavior change?
Let’s examine the consequences of adding “s2n_ecdsa_secp521r1_sha512” to every TLS1.3 security policy that currently supports “s2n_ecdsa_sha512”.
Standard Handshake
Mutual Auth Handshake
Is this a one-way door?
Yes. Adding an option is much safer than removing an option. If we add s2n_ecdsa_secp521r1_sha512, we can’t remove it.
But your PR adds the scheme in two places, not one!
The second place I add it is the certificate signature schemes only used by “default_tls13”. We should be able to add whatever we want to a default policy, even if it is a slight behavior change. But this is also very safe to add to certificate signature schemes. It doesn’t make sense to only allow SHA512 signatures on certificates when doing TLS1.2 but not TLS1.3.
Full list of affected policies
Callouts
This addresses the customer impact, but does NOT fix the underlying problem of ECDSA signature schemes being duplicated. However, if we agree that this change is acceptable, that fix becomes much easier because we can just combine the two existing signature scheme objects: 878c83b I would prefer to keep the two changes separate due to some customer use cases-- ask me offline if you have questions about that.
Testing:
Added a test to enforce that both the TLS1.2 and TLS1.3 versions are included.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.