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

test: pin tests to TLS 1.2/TLS 1.3 policy #4926

Merged
merged 13 commits into from
Nov 27, 2024
Merged

test: pin tests to TLS 1.2/TLS 1.3 policy #4926

merged 13 commits into from
Nov 27, 2024

Conversation

toidiu
Copy link
Contributor

@toidiu toidiu commented Nov 21, 2024

#4765

Description of changes:

Pinning some tests to a numbered TLS1.2 policy in preparation for default TLS1.3 support.

Testing:

Existing tests should pass.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@toidiu toidiu changed the title Ak pin test1 test: pin tests to TLS 1.2 policy Nov 21, 2024
@@ -63,13 +64,15 @@ mod tests {
}

#[test]
fn resume_session() -> Result<(), Box<dyn Error>> {
fn resume_tls12_session() -> Result<(), Box<dyn Error>> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a test named resume_tls13_session below and this one is tls1.2 specific.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TLS1.3 test is done below and explicitly sets the default_tls13 policy.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were mean to only support TLS 1.2. We toggle on fips support to maintain current behavior.

@toidiu toidiu marked this pull request as ready for review November 21, 2024 21:17
@toidiu toidiu marked this pull request as draft November 21, 2024 21:18
@toidiu toidiu requested a review from goatgoose November 21, 2024 21:35
@toidiu toidiu marked this pull request as ready for review November 21, 2024 21:36
Comment on lines 87 to 94
let tls12 = handshake_with_domain(domain, "default").await?;
let tls12 = handshake_with_domain(domain, "20240501").await?;
assert_eq!(tls12.as_ref().actual_protocol_version()?, Version::TLS12);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to test TLS1.2 here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test were not written to work with a fips security policy so this maintains the current behavior by pinning test to "default_tls13".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tests the following ecc preferences and requires a security policy which supports all of them (aka non-FIPS). Once we switch to TLS1.3 by default, it will be possible to use a FIPS TLS1.3 policy by default, which breaks this test.

  • p256
  • x25519 (not supported with a FIPS security policy)
  • p384

@lrstewart lrstewart self-requested a review November 22, 2024 00:10
@toidiu toidiu requested a review from goatgoose November 22, 2024 00:14
bindings/rust/s2n-tls/src/security.rs Outdated Show resolved Hide resolved
Comment on lines 263 to 266
DEFER_CLEANUP(struct s2n_config *config = s2n_config_new(),
s2n_config_ptr_free);
EXPECT_NOT_NULL(config);
EXPECT_SUCCESS(s2n_config_set_cipher_preferences(config, "default_tls13"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Why bother creating a config? Couldn't you just use s2n_connection_set_cipher_preferences?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s2n_connection_set_cipher_preferences doesnt work.

s2n_connection_set_cipher_preferences sets the conn->security_policy_override field but it get overridden by this test which is also directly modifying the field.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The connection policy always takes precedence over the config policy. So if the test is overriding the connection policy, why is setting the config policy working?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea good point. Let me check if I was setting the cipher pref after the testing override behavior.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah if we have to do config here instead of connection that's fine, but I'm now worried about WHY we have to do config. I think we should confirm that before merging this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test fix requires setting the config because the actual test case is setting client->security_policy_override to NULL. This means that we end up using client->config->ecc_prefs and the ecc_prefs for a FIPS policy doesn't have s2n_ecc_curve_x25519

Here is a detailed explanation of whats happening: https://gist.github.com/toidiu/c3ddeca499ba3bcf83328520b8a18cc4

Copy link
Contributor

@lrstewart lrstewart Nov 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes much more sense! Thanks for confirming.

That makes this test kind of tricky though. The test isn't just relying on the policy supporting x25519 and TLS1.3, it's also relying on the policy not supporting pq. And I don't think it'd fail if that assumption isn't met. I wonder if it'd be safer to use a versioned policy instead of "default_tls13", and to leave a comment explaining why that policy was chosen. I'm imagining if/when we want to someday add pq to the default policy 🙃

To be clear, you're not making the test worse by using "default_tls13". The test already was missing safeguards around its policy assumptions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was considering "default_tls13" deprecated but you can never be certain of that. updated in 371ceec

bindings/rust/s2n-tls/src/security.rs Outdated Show resolved Hide resolved
@toidiu toidiu requested a review from lrstewart November 26, 2024 07:01
@toidiu toidiu enabled auto-merge (squash) November 27, 2024 18:37
@toidiu toidiu changed the title test: pin tests to TLS 1.2 policy test: pin tests to TLS 1.2/TLS 1.3 policy Nov 27, 2024
@toidiu toidiu merged commit 087c02e into aws:main Nov 27, 2024
38 checks passed
@toidiu toidiu deleted the ak-pinTest1 branch November 28, 2024 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants