diff options
| author | Jouni Malinen <j@w1.fi> | 2015-05-01 16:40:44 +0300 |
|---|---|---|
| committer | Dan Pasanen <dan.pasanen@gmail.com> | 2015-05-11 09:02:05 -0500 |
| commit | c9a4555d84a8dbcfc7939832f75ed3654a72da80 (patch) | |
| tree | 4cf0088a803b561746b177d2a927bb5d12d19739 | |
| parent | 8c7552b0d7143fdbd9afa83cd582d56fed4ec091 (diff) | |
| download | android_external_wpa_supplicant_8-c9a4555d84a8dbcfc7939832f75ed3654a72da80.tar.gz android_external_wpa_supplicant_8-c9a4555d84a8dbcfc7939832f75ed3654a72da80.tar.bz2 android_external_wpa_supplicant_8-c9a4555d84a8dbcfc7939832f75ed3654a72da80.zip | |
EAP-pwd server: 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: I5688a52eb08bbfe11dd0b82c63e540c43091ca18
Signed-off-by: Jouni Malinen <j@w1.fi>
| -rw-r--r-- | src/eap_server/eap_server_pwd.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/eap_server/eap_server_pwd.c b/src/eap_server/eap_server_pwd.c index 7e1278dd..cbce683c 100644 --- a/src/eap_server/eap_server_pwd.c +++ b/src/eap_server/eap_server_pwd.c @@ -634,9 +634,21 @@ eap_pwd_process_commit_resp(struct eap_sm *sm, struct eap_pwd_data *data, BIGNUM *x = NULL, *y = NULL, *cofactor = NULL; EC_POINT *K = NULL, *point = NULL; int res = 0; + size_t prime_len, order_len; wpa_printf(MSG_DEBUG, "EAP-pwd: Received commit response"); + 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->peer_scalar = BN_new()) == NULL) || ((data->k = BN_new()) == NULL) || ((cofactor = BN_new()) == NULL) || @@ -752,6 +764,13 @@ eap_pwd_process_confirm_resp(struct eap_sm *sm, struct eap_pwd_data *data, u8 conf[SHA256_MAC_LEN], *cruft = NULL, *ptr; int offset; + 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; + } + /* build up the ciphersuite: group | random_function | prf */ grp = htons(data->group_num); ptr = (u8 *) &cs; |
