[PATCH 22/55] wpa_supplicant: Retry FT with another Diffie-Hellman group
Ilan Peer
ilan.peer at intel.com
Thu Dec 3 02:44:21 PST 2026
Use the groups configured with ieee8021x_auth_groups for the FT
protocol.
If the AP rejects the group with status code 77, retry with the next
configured group that is listed in the Supported Groups element of
the AP.
Discard a successful second FT message whose Supported Groups element
lists a group that was rejected or skipped, as a sign of a downgrade
attack.
Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
src/rsn_supp/wpa_ft.c | 1 -
wpa_supplicant/sme.c | 142 ++++++++++++++++++++++++++----
wpa_supplicant/wpa_supplicant_i.h | 3 +
3 files changed, 130 insertions(+), 16 deletions(-)
diff --git a/src/rsn_supp/wpa_ft.c b/src/rsn_supp/wpa_ft.c
index ed49516bcfc7..2ea45ca80641 100644
--- a/src/rsn_supp/wpa_ft.c
+++ b/src/rsn_supp/wpa_ft.c
@@ -643,7 +643,6 @@ static u8 * wpa_ft_add_dh_param(struct wpa_sm *sm, u8 *ft_ies,
WLAN_RSNX_CAPAB_ASSOC_FRAME_ENCRYPTION))
return ft_ies;
- /* TODO: support other groups */
if (!sm->ft_dh_group)
sm->ft_dh_group = 19;
diff --git a/wpa_supplicant/sme.c b/wpa_supplicant/sme.c
index 410025944d08..981cc1205eec 100644
--- a/wpa_supplicant/sme.c
+++ b/wpa_supplicant/sme.c
@@ -92,6 +92,20 @@ const u8 * sme_get_ext_auth_pmkid(struct wpa_supplicant *wpa_s)
return entry ? entry->pmkid : NULL;
}
+
+static bool sme_supported_groups_includes(const struct ieee802_11_elems *elems,
+ int group)
+{
+ size_t i;
+
+ for (i = 0; i + 1 < elems->supported_groups_len; i += 2) {
+ if (WPA_GET_LE16(&elems->supported_groups[i]) == group)
+ return true;
+ }
+
+ return false;
+}
+
#endif /* CONFIG_IEEE8021X_AUTH || CONFIG_ENC_ASSOC */
@@ -1943,6 +1957,85 @@ fail:
#endif /* CONFIG_ENC_ASSOC */
+#if defined(CONFIG_IEEE80211R) && defined(CONFIG_ENC_ASSOC)
+
+static const int * sme_ft_dh_groups(struct wpa_supplicant *wpa_s)
+{
+#ifdef CONFIG_IEEE8021X_AUTH
+ return sme_802_1x_groups(wpa_s, false);
+#else /* CONFIG_IEEE8021X_AUTH */
+ static const int default_groups[] = { 19, 0 };
+
+ return default_groups;
+#endif /* CONFIG_IEEE8021X_AUTH */
+}
+
+
+static int sme_ft_dh_group(struct wpa_supplicant *wpa_s)
+{
+ const int *groups = sme_ft_dh_groups(wpa_s);
+
+ if (!index_within_array(groups, wpa_s->sme.ft_dh_group_index))
+ wpa_s->sme.ft_dh_group_index = 0;
+
+ return groups[wpa_s->sme.ft_dh_group_index];
+}
+
+
+/*
+ * After UNSUPPORTED_FINITE_CYCLIC_GROUP, retry with a group from the
+ * Supported Groups element.
+ */
+static bool sme_ft_next_dh_group(struct wpa_supplicant *wpa_s,
+ const u8 *ies, size_t ies_len)
+{
+ const int *groups = sme_ft_dh_groups(wpa_s);
+ struct ieee802_11_elems elems;
+ int i;
+
+ if (ieee802_11_parse_elems(ies, ies_len, &elems, 0) == ParseFailed ||
+ !elems.supported_groups)
+ return false;
+
+ for (i = wpa_s->sme.ft_dh_group_index + 1; groups[i] > 0; i++) {
+ if (sme_supported_groups_includes(&elems, groups[i])) {
+ wpa_s->sme.ft_dh_group_index = i;
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
+static bool sme_ft_dh_group_downgrade(struct wpa_supplicant *wpa_s,
+ const u8 *ies, size_t ies_len)
+{
+ const int *groups = sme_ft_dh_groups(wpa_s);
+ struct ieee802_11_elems elems;
+ int i;
+
+ if (!wpa_s->sme.ft_dh_group_index)
+ return false;
+
+ if (ieee802_11_parse_elems(ies, ies_len, &elems, 0) == ParseFailed ||
+ !elems.supported_groups)
+ return true;
+
+ /* A skipped group means possible downgrade attack */
+ for (i = 0; i < wpa_s->sme.ft_dh_group_index && groups[i] > 0; i++) {
+ if (sme_supported_groups_includes(&elems, groups[i])) {
+ wpa_msg(wpa_s, MSG_INFO,
+ "FT: Group %d was rejected but is supported by the AP - possible downgrade attack",
+ groups[i]);
+ return true;
+ }
+ }
+
+ return false;
+}
+
+#endif /* CONFIG_IEEE80211R && CONFIG_ENC_ASSOC */
static void sme_send_authentication(struct wpa_supplicant *wpa_s,
struct wpa_bss *bss, struct wpa_ssid *ssid,
@@ -2384,6 +2477,9 @@ static void sme_send_authentication(struct wpa_supplicant *wpa_s,
if (md && (!local_ft || !wpa_key_mgmt_ft(wpa_s->key_mgmt)))
md = NULL;
if (md) {
+#ifdef CONFIG_ENC_ASSOC
+ wpa_sm_set_ft_dh_group(wpa_s->wpa, sme_ft_dh_group(wpa_s));
+#endif /* CONFIG_ENC_ASSOC */
/* Prepare for the next transition */
wpa_ft_prepare_auth_request(wpa_s->wpa, ie);
}
@@ -2941,6 +3037,9 @@ void sme_authenticate(struct wpa_supplicant *wpa_s,
#ifdef CONFIG_IEEE8021X_AUTH
wpa_s->sme.auth_1x_group_index = 0;
#endif /* CONFIG_IEEE8021X_AUTH */
+#if defined(CONFIG_IEEE80211R) && defined(CONFIG_ENC_ASSOC)
+ wpa_s->sme.ft_dh_group_index = 0;
+#endif /* CONFIG_IEEE80211R && CONFIG_ENC_ASSOC */
if (!radio_add_work(wpa_s, bss->freq, "sme-connect", 1,
sme_auth_start_cb, cwork))
@@ -4753,20 +4852,6 @@ static size_t wpas_get_kdk_len(struct wpa_supplicant *wpa_s)
}
-static bool sme_supported_groups_includes(const struct ieee802_11_elems *elems,
- int group)
-{
- size_t i;
-
- for (i = 0; i + 1 < elems->supported_groups_len; i += 2) {
- if (WPA_GET_LE16(&elems->supported_groups[i]) == group)
- return true;
- }
-
- return false;
-}
-
-
static bool sme_802_1x_next_group(struct wpa_supplicant *wpa_s,
const struct auth_info *auth, bool external)
{
@@ -5457,6 +5542,25 @@ void sme_event_auth(struct wpa_supplicant *wpa_s, union wpa_event_data *data)
ie_txt ? ie_txt : "");
os_free(ie_txt);
+#if defined(CONFIG_IEEE80211R) && defined(CONFIG_ENC_ASSOC)
+ if (data->auth.auth_type == WLAN_AUTH_FT &&
+ data->auth.auth_transaction == 2 &&
+ data->auth.status_code ==
+ WLAN_STATUS_FINITE_CYCLIC_GROUP_NOT_SUPPORTED &&
+ wpa_ft_uses_enc_assoc(wpa_s->wpa) &&
+ !wpa_key_mgmt_pqc(wpa_s->key_mgmt) &&
+ sme_ft_next_dh_group(wpa_s, data->auth.ies,
+ data->auth.ies_len)) {
+ wpa_msg(wpa_s, MSG_INFO,
+ "FT: Group not supported by the AP, retry with group %d",
+ sme_ft_dh_group(wpa_s));
+
+ sme_send_authentication(wpa_s, wpa_s->current_bss,
+ wpa_s->current_ssid, 1);
+ return;
+ }
+#endif /* CONFIG_IEEE80211R && CONFIG_ENC_ASSOC */
+
#ifdef CONFIG_FILS
if (wpa_s->sme.auth_alg == WPA_AUTH_ALG_FILS ||
wpa_s->sme.auth_alg == WPA_AUTH_ALG_FILS_SK_PFS)
@@ -5501,12 +5605,20 @@ void sme_event_auth(struct wpa_supplicant *wpa_s, union wpa_event_data *data)
if (data->auth.auth_type == WLAN_AUTH_FT) {
const u8 *ric_ies = NULL;
size_t ric_ies_len = 0;
+ bool downgrade = false;
if (wpa_s->ric_ies) {
ric_ies = wpabuf_head(wpa_s->ric_ies);
ric_ies_len = wpabuf_len(wpa_s->ric_ies);
}
- if (wpa_ft_process_response(wpa_s->wpa, data->auth.ies,
+
+#ifdef CONFIG_ENC_ASSOC
+ downgrade = sme_ft_dh_group_downgrade(wpa_s, data->auth.ies,
+ data->auth.ies_len);
+#endif /* CONFIG_ENC_ASSOC */
+
+ if (downgrade ||
+ wpa_ft_process_response(wpa_s->wpa, data->auth.ies,
data->auth.ies_len, 0,
data->auth.peer,
ric_ies, ric_ies_len,
diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h
index 2b98e8ac5ab2..555405e4d585 100644
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
@@ -1168,6 +1168,9 @@ struct wpa_supplicant {
#ifdef CONFIG_IEEE8021X_AUTH
int auth_1x_group_index;
#endif /* CONFIG_IEEE8021X_AUTH */
+#if defined(CONFIG_IEEE80211R) && defined(CONFIG_ENC_ASSOC)
+ int ft_dh_group_index;
+#endif /* CONFIG_IEEE80211R && CONFIG_ENC_ASSOC */
u8 ext_auth_bssid[ETH_ALEN];
unsigned int ext_auth_freq;
struct wpa_ssid *ext_auth_wpa_ssid;
--
2.55.0
More information about the Hostap
mailing list