-
Notifications
You must be signed in to change notification settings - Fork 970
Fenrir fixes #10230
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
base: master
Are you sure you want to change the base?
Fenrir fixes #10230
Changes from all commits
646ff6d
535aaf2
b8da926
0f9fb2f
ef73b3b
01cc5b1
d97d037
920e175
9aa69f4
2df4936
ff60134
f3e183a
558c329
9d49f7f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1822,16 +1822,20 @@ static void TLSX_ALPN_FreeAll(ALPN *list, void* heap) | |
| static word16 TLSX_ALPN_GetSize(ALPN *list) | ||
| { | ||
| ALPN* alpn; | ||
| word16 length = OPAQUE16_LEN; /* list length */ | ||
| word32 length = OPAQUE16_LEN; /* list length */ | ||
|
|
||
| while ((alpn = list)) { | ||
| list = alpn->next; | ||
|
|
||
| length++; /* protocol name length is on one byte */ | ||
| length += (word16)XSTRLEN(alpn->protocol_name); | ||
| length += (word32)XSTRLEN(alpn->protocol_name); | ||
|
|
||
| if (length > WOLFSSL_MAX_16BIT) { | ||
| return 0; | ||
| } | ||
| } | ||
|
|
||
| return length; | ||
| return (word16)length; | ||
| } | ||
|
|
||
| /** Writes the ALPN objects of a list in a buffer. */ | ||
|
|
@@ -2957,7 +2961,7 @@ static void TLSX_TCA_FreeAll(TCA* list, void* heap) | |
| static word16 TLSX_TCA_GetSize(TCA* list) | ||
| { | ||
| TCA* tca; | ||
| word16 length = OPAQUE16_LEN; /* list length */ | ||
| word32 length = OPAQUE16_LEN; /* list length */ | ||
|
|
||
| while ((tca = list)) { | ||
| list = tca->next; | ||
|
|
@@ -2975,9 +2979,13 @@ static word16 TLSX_TCA_GetSize(TCA* list) | |
| length += OPAQUE16_LEN + tca->idSz; | ||
| break; | ||
| } | ||
|
|
||
| if (length > WOLFSSL_MAX_16BIT) { | ||
| return 0; | ||
| } | ||
|
julek-wolfssl marked this conversation as resolved.
|
||
| } | ||
|
|
||
| return length; | ||
| return (word16)length; | ||
| } | ||
|
|
||
| /** Writes the TCA objects of a list in a buffer. */ | ||
|
|
@@ -7592,7 +7600,7 @@ static word16 TLSX_CA_Names_GetSize(void* data) | |
| { | ||
| WOLFSSL* ssl = (WOLFSSL*)data; | ||
| WOLF_STACK_OF(WOLFSSL_X509_NAME)* names; | ||
| word16 size = 0; | ||
| word32 size = 0; | ||
|
|
||
| /* Length of names */ | ||
| size += OPAQUE16_LEN; | ||
|
|
@@ -7602,11 +7610,14 @@ static word16 TLSX_CA_Names_GetSize(void* data) | |
|
|
||
| if (name != NULL) { | ||
| /* 16-bit length | SEQ | Len | DER of name */ | ||
| size += (word16)(OPAQUE16_LEN + SetSequence(name->rawLen, seq) + | ||
| size += (word32)(OPAQUE16_LEN + SetSequence(name->rawLen, seq) + | ||
| name->rawLen); | ||
| if (size > WOLFSSL_MAX_16BIT) { | ||
| return 0; | ||
| } | ||
| } | ||
| } | ||
| return size; | ||
| return (word16)size; | ||
|
julek-wolfssl marked this conversation as resolved.
|
||
| } | ||
|
|
||
| static word16 TLSX_CA_Names_Write(void* data, byte* output) | ||
|
|
@@ -11933,14 +11944,22 @@ static int TLSX_PreSharedKey_GetSize(PreSharedKey* list, byte msgType, | |
| { | ||
| if (msgType == client_hello) { | ||
| /* Length of identities + Length of binders. */ | ||
| word16 len = OPAQUE16_LEN + OPAQUE16_LEN; | ||
| word32 len = OPAQUE16_LEN + OPAQUE16_LEN; | ||
| while (list != NULL) { | ||
| /* Each entry has: identity, ticket age and binder. */ | ||
| len += OPAQUE16_LEN + list->identityLen + OPAQUE32_LEN + | ||
| OPAQUE8_LEN + (word16)list->binderLen; | ||
| OPAQUE8_LEN + (word32)list->binderLen; | ||
| if (len > WOLFSSL_MAX_16BIT) { | ||
| WOLFSSL_ERROR_VERBOSE(LENGTH_ERROR); | ||
| return LENGTH_ERROR; | ||
| } | ||
| list = list->next; | ||
| } | ||
| *pSz += len; | ||
| if ((word32)*pSz + len > WOLFSSL_MAX_16BIT) { | ||
| WOLFSSL_ERROR_VERBOSE(LENGTH_ERROR); | ||
| return LENGTH_ERROR; | ||
| } | ||
| *pSz += (word16)len; | ||
| return 0; | ||
|
julek-wolfssl marked this conversation as resolved.
|
||
| } | ||
|
|
||
|
|
@@ -11963,7 +11982,7 @@ static int TLSX_PreSharedKey_GetSize(PreSharedKey* list, byte msgType, | |
| int TLSX_PreSharedKey_GetSizeBinders(PreSharedKey* list, byte msgType, | ||
| word16* pSz) | ||
| { | ||
| word16 len; | ||
| word32 len; | ||
|
|
||
| if (msgType != client_hello) { | ||
| WOLFSSL_ERROR_VERBOSE(SANITY_MSG_E); | ||
|
|
@@ -11973,11 +11992,15 @@ int TLSX_PreSharedKey_GetSizeBinders(PreSharedKey* list, byte msgType, | |
| /* Length of all binders. */ | ||
| len = OPAQUE16_LEN; | ||
| while (list != NULL) { | ||
| len += OPAQUE8_LEN + (word16)list->binderLen; | ||
| len += OPAQUE8_LEN + (word32)list->binderLen; | ||
| if (len > WOLFSSL_MAX_16BIT) { | ||
| WOLFSSL_ERROR_VERBOSE(LENGTH_ERROR); | ||
| return LENGTH_ERROR; | ||
| } | ||
| list = list->next; | ||
| } | ||
|
|
||
| *pSz = len; | ||
| *pSz = (word16)len; | ||
| return 0; | ||
| } | ||
|
|
||
|
|
@@ -14937,8 +14960,15 @@ static int TLSX_GetSize(TLSX* list, byte* semaphore, byte msgType, | |
|
|
||
| case TLSX_TRUSTED_CA_KEYS: | ||
| /* TCA only sends the list on the request. */ | ||
| if (isRequest) | ||
| length += TCA_GET_SIZE((TCA*)extension->data); | ||
| if (isRequest) { | ||
| word16 tcaSz = TCA_GET_SIZE((TCA*)extension->data); | ||
| /* 0 on non-empty list means 16-bit overflow. */ | ||
| if (tcaSz == 0 && extension->data != NULL) { | ||
| ret = LENGTH_ERROR; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 [Medium] LENGTH_ERROR from TCA/ALPN/CA_Names cases can be clobbered by later extension handlers · Incorrect error handling The new Fix: After setting
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This actually is a good point. @julek-wolfssl could you take a look?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed. |
||
| break; | ||
| } | ||
| length += tcaSz; | ||
| } | ||
|
julek-wolfssl marked this conversation as resolved.
|
||
| break; | ||
|
|
||
| case TLSX_MAX_FRAGMENT_LENGTH: | ||
|
|
@@ -14979,9 +15009,16 @@ static int TLSX_GetSize(TLSX* list, byte* semaphore, byte msgType, | |
| isRequest); | ||
| break; | ||
|
|
||
| case TLSX_APPLICATION_LAYER_PROTOCOL: | ||
| length += ALPN_GET_SIZE((ALPN*)extension->data); | ||
| case TLSX_APPLICATION_LAYER_PROTOCOL: { | ||
| word16 alpnSz = ALPN_GET_SIZE((ALPN*)extension->data); | ||
| /* 0 on non-empty list means 16-bit overflow. */ | ||
| if (alpnSz == 0 && extension->data != NULL) { | ||
| ret = LENGTH_ERROR; | ||
| break; | ||
| } | ||
| length += alpnSz; | ||
| break; | ||
| } | ||
| #if !defined(NO_CERTS) && !defined(WOLFSSL_NO_SIGALG) | ||
| case TLSX_SIGNATURE_ALGORITHMS: | ||
| length += SA_GET_SIZE(extension->data); | ||
|
|
@@ -15059,9 +15096,16 @@ static int TLSX_GetSize(TLSX* list, byte* semaphore, byte msgType, | |
| #endif | ||
|
|
||
| #if !defined(NO_CERTS) && !defined(WOLFSSL_NO_CA_NAMES) | ||
| case TLSX_CERTIFICATE_AUTHORITIES: | ||
| length += CAN_GET_SIZE(extension->data); | ||
| case TLSX_CERTIFICATE_AUTHORITIES: { | ||
| word16 canSz = CAN_GET_SIZE(extension->data); | ||
| /* 0 on non-empty list means 16-bit overflow. */ | ||
| if (canSz == 0 && extension->data != NULL) { | ||
| ret = LENGTH_ERROR; | ||
| break; | ||
| } | ||
| length += canSz; | ||
| break; | ||
| } | ||
| #endif | ||
| #endif | ||
| #ifdef WOLFSSL_SRTP | ||
|
|
@@ -15101,6 +15145,9 @@ static int TLSX_GetSize(TLSX* list, byte* semaphore, byte msgType, | |
| break; | ||
| } | ||
|
|
||
| if (ret != 0) | ||
| return ret; | ||
|
|
||
| /* Early exit: stop accumulating as soon as the running total | ||
| * cannot possibly fit the 2-byte wire length. Check *before* | ||
| * marking the extension as processed so the semaphore is not | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.