1
0

008-Prevent-installation-of-an-all-zero-TK.patch 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. From: Mathy Vanhoef <Mathy.Vanhoef@cs.kuleuven.be>
  2. Date: Fri, 29 Sep 2017 04:22:51 +0200
  3. Subject: [PATCH] Prevent installation of an all-zero TK
  4. Properly track whether a PTK has already been installed to the driver
  5. and the TK part cleared from memory. This prevents an attacker from
  6. trying to trick the client into installing an all-zero TK.
  7. This fixes the earlier fix in commit
  8. ad00d64e7d8827b3cebd665a0ceb08adabf15e1e ('Fix TK configuration to the
  9. driver in EAPOL-Key 3/4 retry case') which did not take into account
  10. possibility of an extra message 1/4 showing up between retries of
  11. message 3/4.
  12. Signed-off-by: Mathy Vanhoef <Mathy.Vanhoef@cs.kuleuven.be>
  13. ---
  14. --- a/src/common/wpa_common.h
  15. +++ b/src/common/wpa_common.h
  16. @@ -205,6 +205,7 @@ struct wpa_ptk {
  17. size_t kck_len;
  18. size_t kek_len;
  19. size_t tk_len;
  20. + int installed; /* 1 if key has already been installed to driver */
  21. };
  22. struct wpa_gtk {
  23. --- a/src/rsn_supp/wpa.c
  24. +++ b/src/rsn_supp/wpa.c
  25. @@ -581,7 +581,6 @@ static void wpa_supplicant_process_1_of_
  26. os_memset(buf, 0, sizeof(buf));
  27. }
  28. sm->tptk_set = 1;
  29. - sm->tk_to_set = 1;
  30. kde = sm->assoc_wpa_ie;
  31. kde_len = sm->assoc_wpa_ie_len;
  32. @@ -686,7 +685,7 @@ static int wpa_supplicant_install_ptk(st
  33. enum wpa_alg alg;
  34. const u8 *key_rsc;
  35. - if (!sm->tk_to_set) {
  36. + if (sm->ptk.installed) {
  37. wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG,
  38. "WPA: Do not re-install same PTK to the driver");
  39. return 0;
  40. @@ -730,7 +729,7 @@ static int wpa_supplicant_install_ptk(st
  41. /* TK is not needed anymore in supplicant */
  42. os_memset(sm->ptk.tk, 0, WPA_TK_MAX_LEN);
  43. - sm->tk_to_set = 0;
  44. + sm->ptk.installed = 1;
  45. if (sm->wpa_ptk_rekey) {
  46. eloop_cancel_timeout(wpa_sm_rekey_ptk, sm, NULL);
  47. --- a/src/rsn_supp/wpa_i.h
  48. +++ b/src/rsn_supp/wpa_i.h
  49. @@ -24,7 +24,6 @@ struct wpa_sm {
  50. struct wpa_ptk ptk, tptk;
  51. int ptk_set, tptk_set;
  52. unsigned int msg_3_of_4_ok:1;
  53. - unsigned int tk_to_set:1;
  54. u8 snonce[WPA_NONCE_LEN];
  55. u8 anonce[WPA_NONCE_LEN]; /* ANonce from the last 1/4 msg */
  56. int renew_snonce;