Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3885 +/- ##
==========================================
- Coverage 79.02% 78.80% -0.23%
==========================================
Files 716 716
Lines 135498 135529 +31
Branches 19535 19533 -2
==========================================
- Hits 107079 106804 -275
- Misses 27373 27681 +308
+ Partials 1046 1044 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
🔒 Security Review — View Report Please review before merging. |
| TEST(SSLTest, PaddingAfterEmptyCustomExtension) { | ||
| bssl::UniquePtr<SSL_CTX> ctx(SSL_CTX_new(TLS_method())); | ||
| ASSERT_TRUE(ctx); | ||
| ASSERT_TRUE(SSL_CTX_set_max_proto_version(ctx.get(), TLS1_1_VERSION)); |
There was a problem hiding this comment.
This test doesn't cover the custom_extensions.cc change: the empty session_ticket extension already leaves last_was_empty true, so the test still passes with that change reverted. Disabling tickets makes the custom extension the only empty one.
SSL_CTX_set_options(ctx.get(), SSL_OP_NO_TICKET);There was a problem hiding this comment.
+1. I checked: with the last_was_empty update in custom_extensions.cc removed, the test still passes as written. It only fails when SSL_OP_NO_TICKET is set.
| expect_no_key_set(); | ||
|
|
||
| ScopedEVP_HPKE_CTX ctx; | ||
| auto poison_ctx = [&] { |
There was a problem hiding this comment.
IMO the 0xab poisoning (here and in AuthModeNotSupported) makes a regression undefined behavior rather than a test failure, since the scoped context's cleanup then calls through a garbage aead pointer; with the fix reverted, this test hangs in EVP_AEAD_CTX_cleanup on my macOS ASan build. I think it would be better to set the context up successfully first and then check that the getters return NULL after the failed setup, as SetupSenderBufferTooSmall does.
There was a problem hiding this comment.
+1. I checked: with the HPKE change reverted, the 0xab version of ZeroedKeyFailsCleanly segfaults crypto_test on Linux, while a live-context setup followed by NULL-getter checks fails with plain assertions.
| if (ssl->server) { | ||
| return 0; | ||
| } | ||
| *out_len = 0; |
There was a problem hiding this comment.
this bug wasn't introduced in this PR, but I believe its the one leading to the msan failures. I checked locally with clang 15 and -fsanitize-memory-param-retval
| *out = nullptr; | |
| *out_len = 0; |
Context and motivation
Some servers reject a ClientHello whose final extension is empty. AWS-LC avoids this by adding a 1-byte padding extension when
last_was_emptyis true. The extension loop setslast_was_empty = (bytes_written == 4)after every extension, including extensions that write nothing. An extension that writes nothing hasbytes_written == 0, which sets the flag to false. If an empty extension is followed only by extensions that write nothing, the flag ends as false and no padding is added.When HPKE setup fails, it should leave the context empty. It did not. The KEM, KDF and AEAD fields stayed set, and the getters returned them instead of NULL. Some setup functions also returned before they zeroed the context.
Description of changes
9284eb2 updates
last_was_emptyonly when an extension writes bytes. Custom extensions now update it too. Default TLS 1.0 and TLS 1.1 ClientHellos grow by 5 bytes because they now end with the padding extension. TLS 1.2 and TLS 1.3 defaults do not change.2f9e084 zeroes the HPKE context at the start of every setup function and in
EVP_HPKE_CTX_cleanup. A failed setup now leaves the context empty. The getters then return NULL and cleanup is safe.Testing
Updated the existing ClientHello and HPKE tests to cover both bugs, added
SSLTest.PaddingAfterEmptyCustomExtensionfor custom extensions, and ran the fullssl_testand the HPKE tests under ASan.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.