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