diff options
| author | Jouni Malinen <j@w1.fi> | 2015-05-01 16:37:45 +0300 |
|---|---|---|
| committer | Michael Bestas <mikeioannina@gmail.com> | 2015-11-11 19:39:15 +0200 |
| commit | 9d163e3bdd9f4cbbc512e385e609704ffb40b616 (patch) | |
| tree | 2ae20792b5099c7a1316c1840584ec7d1f2e3af0 | |
| parent | 01d5bf8e065431d2e090959d3b188ae71cabf1b4 (diff) | |
| download | android_external_wpa_supplicant_8-9d163e3bdd9f4cbbc512e385e609704ffb40b616.tar.gz android_external_wpa_supplicant_8-9d163e3bdd9f4cbbc512e385e609704ffb40b616.tar.bz2 android_external_wpa_supplicant_8-9d163e3bdd9f4cbbc512e385e609704ffb40b616.zip | |
EAP-pwd peer: Fix payload length validation for Commit and Confirm
The length of the received Commit and Confirm message payloads was not
checked before reading them. This could result in a buffer read
overflow when processing an invalid message.
Fix this by verifying that the payload is of expected length before
processing it. In addition, enforce correct state transition sequence to
make sure there is no unexpected behavior if receiving a Commit/Confirm
message before the previous exchanges have been completed.
Thanks to Kostya Kortchinsky of Google security team for discovering and
reporting this issue.
Change-Id: Id2bc93879b12ffcd94b1ecdc98fc6c5f730d7027
Signed-off-by: Jouni Malinen <j@w1.fi>
| -rw-r--r-- | src/eap_peer/eap_pwd.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/eap_peer/eap_pwd.c b/src/eap_peer/eap_pwd.c index 267d0a5c..5d6e9e7f 100644 --- a/src/eap_peer/eap_pwd.c +++ b/src/eap_peer/eap_pwd.c @@ -271,6 +271,23 @@ eap_pwd_perform_commit_exchange(struct eap_sm *sm, struct eap_pwd_data *data, BIGNUM *mask = NULL, *x = NULL, *y = NULL, *cofactor = NULL; u16 offset; u8 *ptr, *scalar = NULL, *element = NULL; + size_t prime_len, order_len; + + if (data->state != PWD_Commit_Req) { + ret->ignore = TRUE; + goto fin; + } + + prime_len = BN_num_bytes(data->grp->prime); + order_len = BN_num_bytes(data->grp->order); + + if (payload_len != 2 * prime_len + order_len) { + wpa_printf(MSG_INFO, + "EAP-pwd: Unexpected Commit payload length %u (expected %u)", + (unsigned int) payload_len, + (unsigned int) (2 * prime_len + order_len)); + goto fin; + } if (((data->private_value = BN_new()) == NULL) || ((data->my_element = EC_POINT_new(data->grp->group)) == NULL) || @@ -466,6 +483,18 @@ eap_pwd_perform_confirm_exchange(struct eap_sm *sm, struct eap_pwd_data *data, u8 conf[SHA256_MAC_LEN], *cruft = NULL, *ptr; int offset; + if (data->state != PWD_Confirm_Req) { + ret->ignore = TRUE; + goto fin; + } + + if (payload_len != SHA256_MAC_LEN) { + wpa_printf(MSG_INFO, + "EAP-pwd: Unexpected Confirm payload length %u (expected %u)", + (unsigned int) payload_len, SHA256_MAC_LEN); + goto fin; + } + /* * first build up the ciphersuite which is group | random_function | * prf |
