Skip to contentSkip to conversation

eap-peap: Fix misdetection of EAP-Extensions

PATCH New John Kiril Swenson 1 participant 1 message Oct 21

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 eap-peap: Fix misdetection of EAP-Extensions

In PEAPv0, only EAP-Extensions requests carry a full header, the rest are headerless. This code only detected EAP-Extensions by checking pkt[4] which did not consider some headerless cases.

For instance, a headerless MSCHAPv2 Challenge has the low byte of MS-Length at this byte. With a 12 character Name field MS-Length ends up being exactly 33 = 0x21, the same as EAP_TYPE_EXTENSIONS, so this code is fooled and drops the packet when it sees there is no matching EAP_CODE_REQUEST.

To fix, _only_ treat the packet as EAP-Extensions if ALL code, length and type match. This happens to do the same thing that wpa_supplicant does (which works correctly).
---
Ran into this connecting to eduroam at UChicago with my alma mater's (UMN) account where wpa_supplicant worked but iwd didn't.

 src/eap-peap.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)
src/eap-peap.c +8 -11
index 4559066..8d71bc1 100644
@@ -507,17 +507,14 @@ static bool eap_peap_tunnel_handle_request(struct eap_state *eap,
 	struct peap_state *peap_state;
 	uint8_t id;
 
-	if (len > 4 && pkt[4] == EAP_TYPE_EXTENSIONS) {
-		uint16_t pkt_len;
-		uint8_t code = pkt[0];
-
-		if (code != EAP_CODE_REQUEST)
-			return false;
-
-		pkt_len = l_get_be16(pkt + 2);
-		if (pkt_len != len)
-			return false;
-
+	/*
+	 * A headerless PEAPv0 packet, e.g. an MSCHAPv2 Challenge, can also
+	 * have EAP_TYPE_EXTENSIONS at offset 4 by sheer coincidence,
+	 * so check the whole header.
+	 */
+	if (len > 4 && pkt[4] == EAP_TYPE_EXTENSIONS &&
+			pkt[0] == EAP_CODE_REQUEST &&
+			l_get_be16(pkt + 2) == len) {
 		id = pkt[1];
 
 		eap_extensions_handle_request(eap, id,
Signature · 1 line
2.55.0