0013-EAP-pwd-client-Verify-received-scalar-and-element.patch 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. From 8ad8585f91823ddcc3728155e288e0f9f872e31a Mon Sep 17 00:00:00 2001
  2. From: Mathy Vanhoef <mathy.vanhoef@nyu.edu>
  3. Date: Sun, 31 Mar 2019 17:43:44 +0200
  4. Subject: [PATCH 13/14] EAP-pwd client: Verify received scalar and element
  5. When processing an EAP-pwd Commit frame, the server's scalar and element
  6. (elliptic curve point) were not validated. This allowed an adversary to
  7. bypass authentication, and act as a rogue Access Point (AP) if the
  8. crypto implementation did not verify the validity of the EC point.
  9. Fix this vulnerability by assuring the received scalar lies within the
  10. valid range, and by checking that the received element is not the point
  11. at infinity and lies on the elliptic curve being used. (CVE-2019-9499)
  12. The vulnerability is only exploitable if OpenSSL version 1.0.2 or lower
  13. is used, or if LibreSSL or wolfssl is used. Newer versions of OpenSSL
  14. (and also BoringSSL) implicitly validate the elliptic curve point in
  15. EC_POINT_set_affine_coordinates_GFp(), preventing the attack.
  16. Signed-off-by: Mathy Vanhoef <mathy.vanhoef@nyu.edu>
  17. ---
  18. src/eap_peer/eap_pwd.c | 20 ++++++++++++++++++++
  19. 1 file changed, 20 insertions(+)
  20. diff --git a/src/eap_peer/eap_pwd.c b/src/eap_peer/eap_pwd.c
  21. index 761c16a..5a05e54 100644
  22. --- a/src/eap_peer/eap_pwd.c
  23. +++ b/src/eap_peer/eap_pwd.c
  24. @@ -594,6 +594,26 @@ eap_pwd_perform_commit_exchange(struct eap_sm *sm, struct eap_pwd_data *data,
  25. goto fin;
  26. }
  27. + /* verify received scalar */
  28. + if (crypto_bignum_is_zero(data->server_scalar) ||
  29. + crypto_bignum_is_one(data->server_scalar) ||
  30. + crypto_bignum_cmp(data->server_scalar,
  31. + crypto_ec_get_order(data->grp->group)) >= 0) {
  32. + wpa_printf(MSG_INFO,
  33. + "EAP-PWD (peer): received scalar is invalid");
  34. + goto fin;
  35. + }
  36. +
  37. + /* verify received element */
  38. + if (!crypto_ec_point_is_on_curve(data->grp->group,
  39. + data->server_element) ||
  40. + crypto_ec_point_is_at_infinity(data->grp->group,
  41. + data->server_element)) {
  42. + wpa_printf(MSG_INFO,
  43. + "EAP-PWD (peer): received element is invalid");
  44. + goto fin;
  45. + }
  46. +
  47. /* check to ensure server's element is not in a small sub-group */
  48. if (!crypto_bignum_is_one(cofactor)) {
  49. if (crypto_ec_point_mul(data->grp->group, data->server_element,
  50. --
  51. 2.7.4