]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/patches/wpa_supplicant/0004-Prevent-installation-of-an-all-zero-TK.patch
e3bfccbafc64e4854557bab4335b453b90b5525f
[people/pmueller/ipfire-2.x.git] / src / patches / wpa_supplicant / 0004-Prevent-installation-of-an-all-zero-TK.patch
1 From 327b6d780f2667e99e9b74d4c064531c0208b22b Mon Sep 17 00:00:00 2001
2 From: Mathy Vanhoef <Mathy.Vanhoef@cs.kuleuven.be>
3 Date: Fri, 29 Sep 2017 04:22:51 +0200
4 Subject: [PATCH 4/8] Prevent installation of an all-zero TK
5
6 Properly track whether a PTK has already been installed to the driver
7 and the TK part cleared from memory. This prevents an attacker from
8 trying to trick the client into installing an all-zero TK.
9
10 This fixes the earlier fix in commit
11 ad00d64e7d8827b3cebd665a0ceb08adabf15e1e ('Fix TK configuration to the
12 driver in EAPOL-Key 3/4 retry case') which did not take into account
13 possibility of an extra message 1/4 showing up between retries of
14 message 3/4.
15
16 Signed-off-by: Mathy Vanhoef <Mathy.Vanhoef@cs.kuleuven.be>
17 ---
18 src/common/wpa_common.h | 1 +
19 src/rsn_supp/wpa.c | 6 +++---
20 src/rsn_supp/wpa_i.h | 1 -
21 3 files changed, 4 insertions(+), 4 deletions(-)
22
23 diff --git a/src/common/wpa_common.h b/src/common/wpa_common.h
24 index 0872b12..8411686 100644
25 --- a/src/common/wpa_common.h
26 +++ b/src/common/wpa_common.h
27 @@ -219,6 +219,7 @@ struct wpa_ptk {
28 size_t kck_len;
29 size_t kek_len;
30 size_t tk_len;
31 + int installed; /* 1 if key has already been installed to driver */
32 };
33
34 struct wpa_gtk {
35 diff --git a/src/rsn_supp/wpa.c b/src/rsn_supp/wpa.c
36 index 3c8871d..cf9bf1c 100644
37 --- a/src/rsn_supp/wpa.c
38 +++ b/src/rsn_supp/wpa.c
39 @@ -594,7 +594,6 @@ static void wpa_supplicant_process_1_of_4(struct wpa_sm *sm,
40 os_memset(buf, 0, sizeof(buf));
41 }
42 sm->tptk_set = 1;
43 - sm->tk_to_set = 1;
44
45 kde = sm->assoc_wpa_ie;
46 kde_len = sm->assoc_wpa_ie_len;
47 @@ -701,7 +700,7 @@ static int wpa_supplicant_install_ptk(struct wpa_sm *sm,
48 enum wpa_alg alg;
49 const u8 *key_rsc;
50
51 - if (!sm->tk_to_set) {
52 + if (sm->ptk.installed) {
53 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG,
54 "WPA: Do not re-install same PTK to the driver");
55 return 0;
56 @@ -745,7 +744,7 @@ static int wpa_supplicant_install_ptk(struct wpa_sm *sm,
57
58 /* TK is not needed anymore in supplicant */
59 os_memset(sm->ptk.tk, 0, WPA_TK_MAX_LEN);
60 - sm->tk_to_set = 0;
61 + sm->ptk.installed = 1;
62
63 if (sm->wpa_ptk_rekey) {
64 eloop_cancel_timeout(wpa_sm_rekey_ptk, sm, NULL);
65 @@ -4183,6 +4182,7 @@ int fils_process_assoc_resp(struct wpa_sm *sm, const u8 *resp, size_t len)
66 * takes care of association frame encryption/decryption. */
67 /* TK is not needed anymore in supplicant */
68 os_memset(sm->ptk.tk, 0, WPA_TK_MAX_LEN);
69 + sm->ptk.installed = 1;
70
71 /* FILS HLP Container */
72 fils_process_hlp_container(sm, ie_start, end - ie_start);
73 diff --git a/src/rsn_supp/wpa_i.h b/src/rsn_supp/wpa_i.h
74 index 156e6cb..3b42245 100644
75 --- a/src/rsn_supp/wpa_i.h
76 +++ b/src/rsn_supp/wpa_i.h
77 @@ -24,7 +24,6 @@ struct wpa_sm {
78 struct wpa_ptk ptk, tptk;
79 int ptk_set, tptk_set;
80 unsigned int msg_3_of_4_ok:1;
81 - unsigned int tk_to_set:1;
82 u8 snonce[WPA_NONCE_LEN];
83 u8 anonce[WPA_NONCE_LEN]; /* ANonce from the last 1/4 msg */
84 int renew_snonce;
85 --
86 2.7.4
87