702-pppd-Ignore-received-EAP-messages-when-not-doing-EAP.patch 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. From 8d45443bb5c9372b4c6a362ba2f443d41c5636af Mon Sep 17 00:00:00 2001
  2. From: Paul Mackerras <paulus@ozlabs.org>
  3. Date: Mon, 3 Feb 2020 16:31:42 +1100
  4. Subject: [PATCH] pppd: Ignore received EAP messages when not doing EAP
  5. This adds some basic checks to the subroutines of eap_input to check
  6. that we have requested or agreed to doing EAP authentication before
  7. doing any processing on the received packet. The motivation is to
  8. make it harder for a malicious peer to disrupt the operation of pppd
  9. by sending unsolicited EAP packets. Note that eap_success() already
  10. has a check that the EAP client state is reasonable, and does nothing
  11. (apart from possibly printing a debug message) if not.
  12. Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
  13. ---
  14. pppd/eap.c | 18 ++++++++++++++++++
  15. 1 file changed, 18 insertions(+)
  16. diff --git a/pppd/eap.c b/pppd/eap.c
  17. index 1b93db01aebd..082e95343120 100644
  18. --- a/pppd/eap.c
  19. +++ b/pppd/eap.c
  20. @@ -1328,6 +1328,12 @@ int len;
  21. int fd;
  22. #endif /* USE_SRP */
  23. + /*
  24. + * Ignore requests if we're not open
  25. + */
  26. + if (esp->es_client.ea_state <= eapClosed)
  27. + return;
  28. +
  29. /*
  30. * Note: we update es_client.ea_id *only if* a Response
  31. * message is being generated. Otherwise, we leave it the
  32. @@ -1736,6 +1742,12 @@ int len;
  33. u_char dig[SHA_DIGESTSIZE];
  34. #endif /* USE_SRP */
  35. + /*
  36. + * Ignore responses if we're not open
  37. + */
  38. + if (esp->es_server.ea_state <= eapClosed)
  39. + return;
  40. +
  41. if (esp->es_server.ea_id != id) {
  42. dbglog("EAP: discarding Response %d; expected ID %d", id,
  43. esp->es_server.ea_id);
  44. @@ -2047,6 +2059,12 @@ u_char *inp;
  45. int id;
  46. int len;
  47. {
  48. + /*
  49. + * Ignore failure messages if we're not open
  50. + */
  51. + if (esp->es_client.ea_state <= eapClosed)
  52. + return;
  53. +
  54. if (!eap_client_active(esp)) {
  55. dbglog("EAP unexpected failure message in state %s (%d)",
  56. eap_state_name(esp->es_client.ea_state),