0011-EAP-pwd-server-Verify-received-scalar-and-element.patch 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. From 70ff850e89fbc8bc7da515321b4d15b5eef70581 Mon Sep 17 00:00:00 2001
  2. From: Mathy Vanhoef <mathy.vanhoef@nyu.edu>
  3. Date: Sun, 31 Mar 2019 17:13:06 +0200
  4. Subject: [PATCH 11/14] EAP-pwd server: Verify received scalar and element
  5. When processing an EAP-pwd Commit frame, the peer's scalar and element
  6. (elliptic curve point) were not validated. This allowed an adversary to
  7. bypass authentication, and impersonate any user if the crypto
  8. 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-9498)
  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_server/eap_server_pwd.c | 20 ++++++++++++++++++++
  19. 1 file changed, 20 insertions(+)
  20. diff --git a/src/eap_server/eap_server_pwd.c b/src/eap_server/eap_server_pwd.c
  21. index d0fa54a..74979da 100644
  22. --- a/src/eap_server/eap_server_pwd.c
  23. +++ b/src/eap_server/eap_server_pwd.c
  24. @@ -718,6 +718,26 @@ eap_pwd_process_commit_resp(struct eap_sm *sm, struct eap_pwd_data *data,
  25. goto fin;
  26. }
  27. + /* verify received scalar */
  28. + if (crypto_bignum_is_zero(data->peer_scalar) ||
  29. + crypto_bignum_is_one(data->peer_scalar) ||
  30. + crypto_bignum_cmp(data->peer_scalar,
  31. + crypto_ec_get_order(data->grp->group)) >= 0) {
  32. + wpa_printf(MSG_INFO,
  33. + "EAP-PWD (server): 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->peer_element) ||
  40. + crypto_ec_point_is_at_infinity(data->grp->group,
  41. + data->peer_element)) {
  42. + wpa_printf(MSG_INFO,
  43. + "EAP-PWD (server): received element is invalid");
  44. + goto fin;
  45. + }
  46. +
  47. /* check to ensure peer'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->peer_element,
  50. --
  51. 2.7.4