Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -21862,6 +21862,23 @@ int DoApplicationData(WOLFSSL* ssl, byte* input, word32* inOutIdx, int sniff)
}
#endif

Comment thread
embhorn marked this conversation as resolved.
/* Rate-limit empty application data records to prevent DoS */
if (dataSz == 0) {
if (++ssl->options.emptyRecordCount >= WOLFSSL_MAX_EMPTY_RECORDS) {
WOLFSSL_MSG("Too many empty records");
#ifdef WOLFSSL_EXTRA_ALERTS
Comment thread
embhorn marked this conversation as resolved.
if (sniff == NO_SNIFF) {
SendAlert(ssl, alert_fatal, unexpected_message);
}
#endif
WOLFSSL_ERROR_VERBOSE(EMPTY_RECORD_LIMIT_E);
return EMPTY_RECORD_LIMIT_E;
}
Comment thread
embhorn marked this conversation as resolved.
}
else {
ssl->options.emptyRecordCount = 0;
}

/* read data */
if (dataSz) {
int rawSz = dataSz; /* keep raw size for idx adjustment */
Expand Down Expand Up @@ -27573,6 +27590,9 @@ const char* wolfSSL_ERR_reason_error_string(unsigned long e)
case ALERT_COUNT_E:
return "Alert Count exceeded error";

case EMPTY_RECORD_LIMIT_E:
return "Too many empty records error";

case EXT_MISSING:
return "Required TLS extension missing";

Expand Down
3 changes: 3 additions & 0 deletions src/tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -17043,6 +17043,9 @@ int TLSX_Parse(WOLFSSL* ssl, const byte* input, word16 length, byte msgType,
#ifdef WOLFSSL_QUIC
|| (type == TLSX_KEY_QUIC_TP_PARAMS_DRAFT)
#endif
#if defined(WOLFSSL_TLS13) && defined(HAVE_ECH)
|| (type == TLSX_ECH)
#endif
#if defined(WOLFSSL_TLS13) && defined(WOLFSSL_DUAL_ALG_CERTS)
|| (type == TLSX_CKS)
#endif
Expand Down
8 changes: 5 additions & 3 deletions src/tls13.c
Original file line number Diff line number Diff line change
Expand Up @@ -2638,9 +2638,10 @@ static int EncryptTls13(WOLFSSL* ssl, byte* output, const byte* input,
#endif

#ifdef WOLFSSL_CIPHER_TEXT_CHECK
Comment thread
embhorn marked this conversation as resolved.
if (ssl->specs.bulk_cipher_algorithm != wolfssl_cipher_null) {
if (ssl->specs.bulk_cipher_algorithm != wolfssl_cipher_null &&
dataSz >= WOLFSSL_CIPHER_CHECK_SZ) {
XMEMCPY(ssl->encrypt.sanityCheck, input,
min(dataSz, sizeof(ssl->encrypt.sanityCheck)));
sizeof(ssl->encrypt.sanityCheck));
}
#endif

Comment thread
embhorn marked this conversation as resolved.
Expand Down Expand Up @@ -2824,8 +2825,9 @@ static int EncryptTls13(WOLFSSL* ssl, byte* output, const byte* input,

#ifdef WOLFSSL_CIPHER_TEXT_CHECK
if (ssl->specs.bulk_cipher_algorithm != wolfssl_cipher_null &&
dataSz >= WOLFSSL_CIPHER_CHECK_SZ &&
XMEMCMP(output, ssl->encrypt.sanityCheck,
min(dataSz, sizeof(ssl->encrypt.sanityCheck))) == 0) {
sizeof(ssl->encrypt.sanityCheck)) == 0) {

WOLFSSL_MSG("EncryptTls13 sanity check failed! Glitch?");
return ENCRYPT_ERROR;
Expand Down
Loading
Loading