1 From dd2f043c9c43d156494e33d7ce22db96e6ef42c7 Mon Sep 17 00:00:00 2001
2 From: Jouni Malinen <j@w1.fi>
3 Date: Fri, 1 May 2015 16:37:45 +0300
4 Subject: [PATCH 1/5] EAP-pwd peer: Fix payload length validation for Commit
7 The length of the received Commit and Confirm message payloads was not
8 checked before reading them. This could result in a buffer read
9 overflow when processing an invalid message.
11 Fix this by verifying that the payload is of expected length before
12 processing it. In addition, enforce correct state transition sequence to
13 make sure there is no unexpected behavior if receiving a Commit/Confirm
14 message before the previous exchanges have been completed.
16 Thanks to Kostya Kortchinsky of Google security team for discovering and
19 Signed-off-by: Jouni Malinen <j@w1.fi>
21 src/eap_peer/eap_pwd.c | 29 +++++++++++++++++++++++++++++
22 1 file changed, 29 insertions(+)
24 diff --git a/src/eap_peer/eap_pwd.c b/src/eap_peer/eap_pwd.c
25 index f2b0926..a629437 100644
26 --- a/src/eap_peer/eap_pwd.c
27 +++ b/src/eap_peer/eap_pwd.c
28 @@ -355,6 +355,23 @@ eap_pwd_perform_commit_exchange(struct eap_sm *sm, struct eap_pwd_data *data,
29 BIGNUM *mask = NULL, *x = NULL, *y = NULL, *cofactor = NULL;
31 u8 *ptr, *scalar = NULL, *element = NULL;
32 + size_t prime_len, order_len;
34 + if (data->state != PWD_Commit_Req) {
39 + prime_len = BN_num_bytes(data->grp->prime);
40 + order_len = BN_num_bytes(data->grp->order);
42 + if (payload_len != 2 * prime_len + order_len) {
43 + wpa_printf(MSG_INFO,
44 + "EAP-pwd: Unexpected Commit payload length %u (expected %u)",
45 + (unsigned int) payload_len,
46 + (unsigned int) (2 * prime_len + order_len));
50 if (((data->private_value = BN_new()) == NULL) ||
51 ((data->my_element = EC_POINT_new(data->grp->group)) == NULL) ||
52 @@ -554,6 +571,18 @@ eap_pwd_perform_confirm_exchange(struct eap_sm *sm, struct eap_pwd_data *data,
53 u8 conf[SHA256_MAC_LEN], *cruft = NULL, *ptr;
56 + if (data->state != PWD_Confirm_Req) {
61 + if (payload_len != SHA256_MAC_LEN) {
62 + wpa_printf(MSG_INFO,
63 + "EAP-pwd: Unexpected Confirm payload length %u (expected %u)",
64 + (unsigned int) payload_len, SHA256_MAC_LEN);
69 * first build up the ciphersuite which is group | random_function |