Skip to content

Commit 5b316bd

Browse files
authored
fix: update default security policies (#4523)
1 parent 16efec9 commit 5b316bd

15 files changed

+245
-65
lines changed

bindings/rust/bench/src/harness.rs

+1
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ where
292292
self.client.handshake()?;
293293
self.server.handshake()?;
294294
}
295+
assert!(self.handshake_completed());
295296
Ok(())
296297
}
297298

bindings/rust/bench/src/s2n_tls.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl crate::harness::TlsBenchConfig for S2NConfig {
7474
let security_policy = match (crypto_config.cipher_suite, crypto_config.kx_group) {
7575
(CipherSuite::AES_128_GCM_SHA256, KXGroup::Secp256R1) => "20230317",
7676
(CipherSuite::AES_256_GCM_SHA384, KXGroup::Secp256R1) => "20190802",
77-
(CipherSuite::AES_128_GCM_SHA256, KXGroup::X25519) => "default_tls13",
77+
(CipherSuite::AES_128_GCM_SHA256, KXGroup::X25519) => "20240417",
7878
(CipherSuite::AES_256_GCM_SHA384, KXGroup::X25519) => "20190801",
7979
};
8080

docs/usage-guide/topics/ch06-security-policies.md

+28-16
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@ The following chart maps the security policy version to protocol version and cip
1515

1616
| version | TLS1.0 | TLS1.1 | TLS1.2 | TLS1.3 | AES-CBC | AES-GCM | CHACHAPOLY | 3DES | RC4 | DHE | ECDHE | RSA kx |
1717
|---------------|--------|--------|--------|--------|---------|---------|------------|------|-----|-----|-------|--------|
18+
| default | | | X | | X | X | | | | | X | |
19+
| default_fips | | | X | | X | X | | | | | X | |
20+
| default_tls13 | | | X | X | X | X | X | | | | X | |
21+
| 20240501 | | | X | | X | X | | | | | X | |
22+
| 20240502 | | | X | | X | X | | | | | X | |
23+
| 20240503 | | | X | X | X | X | | | | | X | |
1824
| 20230317 | | | X | X | X | X | | | | | X | |
1925
| 20240331 | | | X | | X | X | | | | | X | |
20-
| default | X | X | X | | X | X | X | | | | X | X |
21-
| default_tls13 | X | X | X | X | X | X | X | | | | X | X |
22-
| default_fips | | | X | | X | X | | | | X | X | |
2326
| 20190214 | X | X | X | | X | X | | X | | X | X | X |
2427
| 20170718 | X | X | X | | X | X | | | | | X | X |
2528
| 20170405 | X | X | X | | X | X | | X | | | X | X |
@@ -43,13 +46,10 @@ The following chart maps the security policy version to protocol version and cip
4346
The "default", "default_tls13", and "default_fips" versions are special in that they will be updated with future s2n-tls changes to keep up-to-date with current security best practices. Ciphersuites, protocol versions, and other options may be added or removed, or their internal order of preference might change. **Warning**: this means that the default policies may change as a result of library updates, which could break peers that rely on legacy options.
4447

4548
In contrast, numbered or dated versions are fixed and will never change. The numbered equivalents of the default policies are currently:
46-
* "default": "20170210"
47-
* "default_tls13": "20240417"
48-
* "default_fips": "20240416"
49-
50-
"20230317" offers more limited but more secure options than the default policies. Consider it if you don't need or want to support less secure legacy options like TLS1.1 or SHA1. It is also FIPS compliant and supports TLS1.3. If you need a version of this policy that doesn't support TLS1.3, choose "20240331" instead.
51-
52-
"20160411" follows the same general preference order as "default". The main difference is it has a CBC cipher suite at the top. This is to accommodate certain Java clients that have poor GCM implementations. Users of s2n-tls who have found GCM to be hurting performance for their clients should consider this version.
49+
* "default": "20240501"
50+
* "default_fips": "20240502"
51+
* "default_tls13": "20240503"
52+
For previous defaults, see the "Default Policy History" section below.
5353

5454
"rfc9151" is derived from [Commercial National Security Algorithm (CNSA) Suite Profile for TLS and DTLS 1.2 and 1.3](https://datatracker.ietf.org/doc/html/rfc9151). This policy restricts the algorithms allowed for signatures on certificates in the certificate chain to RSA or ECDSA with sha384, which may require you to update your certificates.
5555
Like the default policies, this policy may also change if the source RFC definition changes.
@@ -71,10 +71,13 @@ s2n-tls usually prefers AES over ChaCha20. However, some clients-- particularly
7171

7272
| version | RSA PKCS1 | ECDSA | SHA-1 Legacy | RSA PSS |
7373
|---------------|-----------|-------|--------------|---------|
74+
| default | X | X | | X |
75+
| default_fips | X | X | | X |
76+
| default_tls13 | X | X | | X |
77+
| 20240501 | X | X | | X |
78+
| 20240502 | X | X | | X |
79+
| 20240503 | X | X | | X |
7480
| 20230317 | X | X | | X |
75-
| default | X | | X | |
76-
| default_tls13 | X | X | X | X |
77-
| default_fips | X | X | | |
7881
| 20190214 | X | X | X | |
7982
| 20170718 | X | | X | |
8083
| 20170405 | X | | X | |
@@ -103,10 +106,13 @@ s2n-tls usually prefers AES over ChaCha20. However, some clients-- particularly
103106

104107
| version | secp256r1 | secp384r1 | x25519 |
105108
|---------------|-----------|-----------|--------|
106-
| 20230317 | X | X | |
107-
| default | X | X | |
108-
| default_tls13 | X | X | X |
109+
| default | X | X | X |
109110
| default_fips | X | X | |
111+
| default_tls13 | X | X | X |
112+
| 20240501 | X | X | X |
113+
| 20240502 | X | X | |
114+
| 20240503 | X | X | X |
115+
| 20230317 | X | X | |
110116
| 20190214 | X | X | |
111117
| 20170718 | X | X | |
112118
| 20170405 | X | X | |
@@ -126,3 +132,9 @@ s2n-tls usually prefers AES over ChaCha20. However, some clients-- particularly
126132
| 20190802 | X | X | |
127133
| 20200207 | X | X | X |
128134
| rfc9151 | | X | |
135+
136+
### Default Policy History
137+
| Version | "default" | "default_fips" | "default_tls13" |
138+
|------------|-----------|----------------|-----------------|
139+
| v1.4.16 | 20240501 | 20240502 | 20240503 |
140+
| Older | 20170210 | 20240416 | 20240417 |

tests/unit/s2n_client_hello_test.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ int main(int argc, char **argv)
314314
struct s2n_connection *conn = NULL;
315315
EXPECT_NOT_NULL(conn = s2n_connection_new(S2N_CLIENT));
316316
struct s2n_stuffer *hello_stuffer = &conn->handshake.io;
317+
conn->actual_protocol_version = i;
317318

318319
conn->session_id_len = S2N_TLS_SESSION_ID_MAX_LEN;
319320
EXPECT_MEMCPY_SUCCESS(conn->session_id, test_session_id, S2N_TLS_SESSION_ID_MAX_LEN);
@@ -831,8 +832,9 @@ int main(int argc, char **argv)
831832
*
832833
* Our test SSLv2 ClientHello advertises TLS1.2.
833834
* So the security policy only needs to support TLS1.2.
835+
* (and at least one of the ciphers in the hard coded sslv2 client hello)
834836
*/
835-
EXPECT_SUCCESS(s2n_config_set_cipher_preferences(server_config, "default"));
837+
EXPECT_SUCCESS(s2n_config_set_cipher_preferences(server_config, "20170210"));
836838

837839
/* Send the client hello message */
838840
EXPECT_EQUAL(write(io_pair.client, sslv2_client_hello_header, sslv2_client_hello_header_len), sslv2_client_hello_header_len);

tests/unit/s2n_config_test.c

-8
Original file line numberDiff line numberDiff line change
@@ -156,19 +156,11 @@ int main(int argc, char **argv)
156156
struct s2n_config *config = NULL;
157157
EXPECT_NOT_NULL(config = s2n_config_new());
158158
EXPECT_EQUAL(config->security_policy, default_security_policy);
159-
EXPECT_EQUAL(config->security_policy->cipher_preferences, &cipher_preferences_20170210);
160-
EXPECT_EQUAL(config->security_policy->kem_preferences, &kem_preferences_null);
161-
EXPECT_EQUAL(config->security_policy->signature_preferences, &s2n_signature_preferences_20140601);
162-
EXPECT_EQUAL(config->security_policy->ecc_preferences, &s2n_ecc_preferences_20140601);
163159
EXPECT_SUCCESS(s2n_config_free(config));
164160

165161
EXPECT_SUCCESS(s2n_enable_tls13_in_test());
166162
EXPECT_NOT_NULL(config = s2n_config_new());
167163
EXPECT_EQUAL(config->security_policy, tls13_security_policy);
168-
EXPECT_EQUAL(config->security_policy->cipher_preferences, &cipher_preferences_20210831);
169-
EXPECT_EQUAL(config->security_policy->kem_preferences, &kem_preferences_null);
170-
EXPECT_EQUAL(config->security_policy->signature_preferences, &s2n_signature_preferences_20200207);
171-
EXPECT_EQUAL(config->security_policy->ecc_preferences, &s2n_ecc_preferences_20200310);
172164
EXPECT_SUCCESS(s2n_config_free(config));
173165
EXPECT_SUCCESS(s2n_disable_tls13_in_test());
174166
}

tests/unit/s2n_connection_test.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ int main(int argc, char **argv)
371371
EXPECT_SUCCESS(s2n_config_set_unsafe_for_testing(config));
372372
EXPECT_SUCCESS(s2n_config_set_client_auth_type(config, S2N_CERT_AUTH_REQUIRED));
373373
EXPECT_SUCCESS(s2n_config_add_cert_chain_and_key_to_store(config, rsa_chain_and_key));
374-
EXPECT_SUCCESS(s2n_config_set_cipher_preferences(config, "default"));
374+
EXPECT_SUCCESS(s2n_config_set_cipher_preferences(config, "20170210"));
375375

376376
struct s2n_connection *client_conn = s2n_connection_new(S2N_CLIENT);
377377
EXPECT_NOT_NULL(client_conn);

tests/unit/s2n_handshake_test.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ int main(int argc, char **argv)
261261
}
262262

263263
EXPECT_NOT_NULL(client_config = s2n_config_new());
264+
EXPECT_SUCCESS(s2n_config_set_cipher_preferences(client_config, "20170210"));
264265
EXPECT_SUCCESS(s2n_config_set_unsafe_for_testing(client_config));
265266

266267
EXPECT_SUCCESS(s2n_config_set_verification_ca_location(client_config, S2N_DEFAULT_TEST_CERT_CHAIN, NULL));
@@ -457,7 +458,7 @@ int main(int argc, char **argv)
457458

458459
DEFER_CLEANUP(struct s2n_config *config = s2n_config_new(), s2n_config_ptr_free);
459460
EXPECT_NOT_NULL(config);
460-
EXPECT_SUCCESS(s2n_config_set_cipher_preferences(config, "default"));
461+
EXPECT_SUCCESS(s2n_config_set_cipher_preferences(config, "20170210"));
461462
EXPECT_SUCCESS(s2n_config_add_cert_chain_and_key_to_store(config, chain_and_key));
462463
EXPECT_SUCCESS(s2n_config_set_verification_ca_location(config, S2N_DEFAULT_TEST_CERT_CHAIN, NULL));
463464
EXPECT_SUCCESS(s2n_config_disable_x509_verification(config));

0 commit comments

Comments
 (0)