[PATCH 20/55] wpa_supplicant: Verify the FTE MIC of the second FT message
Ilan Peer
ilan.peer at intel.com
Thu Dec 3 02:44:19 PST 2026
When association frame encryption is used with the FT protocol,
the FTE in the second FT message carries a MIC computed over the
whole frame body. Pass the frame body of the FT Authentication
frame to wpa_ft_process_response() and verify the MIC.
Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
src/rsn_supp/wpa.h | 7 ++++--
src/rsn_supp/wpa_ft.c | 53 ++++++++++++++++++++++++++++++++++++++++-
src/rsn_supp/wpa_i.h | 5 ++++
wpa_supplicant/events.c | 4 ++--
wpa_supplicant/sme.c | 4 +++-
5 files changed, 67 insertions(+), 6 deletions(-)
diff --git a/src/rsn_supp/wpa.h b/src/rsn_supp/wpa.h
index 6ebe09f90874..3834bb10b7bb 100644
--- a/src/rsn_supp/wpa.h
+++ b/src/rsn_supp/wpa.h
@@ -604,7 +604,8 @@ int wpa_ft_add_mdie(struct wpa_sm *sm, u8 *ies, size_t ies_len,
const u8 * wpa_sm_get_ft_md(struct wpa_sm *sm);
int wpa_ft_process_response(struct wpa_sm *sm, const u8 *ies, size_t ies_len,
int ft_action, const u8 *target_ap,
- const u8 *ric_ies, size_t ric_ies_len);
+ const u8 *ric_ies, size_t ric_ies_len,
+ const u8 *frame_body, size_t frame_body_len);
int wpa_sm_802_1x_ft_pmk_to_ptk(struct wpa_sm *sm, const u8 *xxkey,
size_t xxkey_len, const u8 *snonce,
const u8 *anonce, const u8 *aa,
@@ -655,7 +656,9 @@ static inline int wpa_ft_add_mdie(struct wpa_sm *sm, u8 *ies, size_t ies_len,
static inline int
wpa_ft_process_response(struct wpa_sm *sm, const u8 *ies, size_t ies_len,
- int ft_action, const u8 *target_ap)
+ int ft_action, const u8 *target_ap,
+ const u8 *ric_ies, size_t ric_ies_len,
+ const u8 *frame_body, size_t frame_body_len)
{
return 0;
}
diff --git a/src/rsn_supp/wpa_ft.c b/src/rsn_supp/wpa_ft.c
index cf0ed63957bc..96cbf2a81aa6 100644
--- a/src/rsn_supp/wpa_ft.c
+++ b/src/rsn_supp/wpa_ft.c
@@ -668,9 +668,53 @@ const u8 * wpa_sm_get_ft_md(struct wpa_sm *sm)
}
+#ifdef CONFIG_ENC_ASSOC
+
+static int wpa_ft_check_msg2_mic(struct wpa_sm *sm, const u8 *bssid,
+ const u8 *frame_body, size_t body_len,
+ const struct wpa_ft_ies *parse)
+{
+ u8 mic[WPA_EAPOL_KEY_MIC_MAX_LEN];
+ u8 *body;
+ int ret;
+
+ if (!frame_body || parse->fte_mic_len != sm->ptk.kck_len ||
+ parse->fte_mic < frame_body ||
+ parse->fte_mic + parse->fte_mic_len > frame_body + body_len) {
+ wpa_printf(MSG_DEBUG, "FT: Invalid FTE MIC in FT message 2");
+ return -1;
+ }
+
+ body = os_memdup(frame_body, body_len);
+ if (!body)
+ return -1;
+
+ os_memset(body + (parse->fte_mic - frame_body), 0, parse->fte_mic_len);
+
+ ret = wpa_ft_msg2_mic(sm->key_mgmt, sm->ptk.kck, sm->ptk.kck_len,
+ sm->own_addr, bssid,
+ sm->ap_rsn_ie, sm->ap_rsn_ie_len,
+ sm->ap_rsnxe, sm->ap_rsnxe_len,
+ body, body_len, mic);
+
+ os_free(body);
+ if (ret < 0)
+ return -1;
+
+ if (os_memcmp_const(mic, parse->fte_mic, parse->fte_mic_len) != 0) {
+ wpa_printf(MSG_DEBUG, "FT: Invalid MIC in FT message 2");
+ return -1;
+ }
+
+ return 0;
+}
+
+#endif /* CONFIG_ENC_ASSOC */
+
int wpa_ft_process_response(struct wpa_sm *sm, const u8 *ies, size_t ies_len,
int ft_action, const u8 *target_ap,
- const u8 *ric_ies, size_t ric_ies_len)
+ const u8 *ric_ies, size_t ric_ies_len,
+ const u8 *frame_body, size_t frame_body_len)
{
u8 *ft_ies;
size_t ft_ies_len;
@@ -808,6 +852,13 @@ int wpa_ft_process_response(struct wpa_sm *sm, const u8 *ies, size_t ies_len,
kdk_len) < 0)
goto fail;
+#ifdef CONFIG_ENC_ASSOC
+ if (sm->ft_enc_assoc &&
+ wpa_ft_check_msg2_mic(sm, bssid, frame_body, frame_body_len,
+ &parse) < 0)
+ goto fail;
+#endif /* CONFIG_ENC_ASSOC */
+
os_memcpy(sm->key_mobility_domain, sm->mobility_domain,
MOBILITY_DOMAIN_ID_LEN);
diff --git a/src/rsn_supp/wpa_i.h b/src/rsn_supp/wpa_i.h
index c3130ca0d00e..d956aba3570d 100644
--- a/src/rsn_supp/wpa_i.h
+++ b/src/rsn_supp/wpa_i.h
@@ -196,6 +196,11 @@ struct wpa_sm {
u8 mdie_ft_capab; /* FT Capability and Policy from target AP MDIE */
u8 *assoc_resp_ies; /* MDIE and FTIE from (Re)Association Response */
size_t assoc_resp_ies_len;
+#ifdef CONFIG_ENC_ASSOC
+ struct crypto_ecdh *ft_ecdh;
+ u16 ft_dh_group; /* 0 means use the group 19 */
+ bool ft_enc_assoc;
+#endif /* CONFIG_ENC_ASSOC */
#ifdef CONFIG_PASN
/*
* Currently, the WPA state machine stores the PMK-R1, PMK-R1-Name and
diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index 365ae90dd38f..cb351b5507e5 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -5868,7 +5868,7 @@ wpa_supplicant_event_ft_response(struct wpa_supplicant *wpa_s,
data->ft_ies.ft_action,
data->ft_ies.target_ap,
data->ft_ies.ric_ies,
- data->ft_ies.ric_ies_len) < 0) {
+ data->ft_ies.ric_ies_len, NULL, 0) < 0) {
/* TODO: prevent MLME/driver from trying to associate? */
}
}
@@ -5954,7 +5954,7 @@ static void ft_rx_action(struct wpa_supplicant *wpa_s, const u8 *da,
if (wpa_ft_process_response(wpa_s->wpa, data + 1 + 2 * ETH_ALEN + 2,
len - (1 + 2 * ETH_ALEN + 2), 1,
- target_ap_addr, NULL, 0) < 0)
+ target_ap_addr, NULL, 0, NULL, 0) < 0)
return;
#ifdef CONFIG_SME
diff --git a/wpa_supplicant/sme.c b/wpa_supplicant/sme.c
index 54b27ba904bd..591b2995e807 100644
--- a/wpa_supplicant/sme.c
+++ b/wpa_supplicant/sme.c
@@ -5508,7 +5508,9 @@ void sme_event_auth(struct wpa_supplicant *wpa_s, union wpa_event_data *data)
if (wpa_ft_process_response(wpa_s->wpa, data->auth.ies,
data->auth.ies_len, 0,
data->auth.peer,
- ric_ies, ric_ies_len) < 0) {
+ ric_ies, ric_ies_len,
+ data->auth.frame_body,
+ data->auth.frame_body_len) < 0) {
wpa_dbg(wpa_s, MSG_DEBUG,
"SME: FT Authentication response processing failed");
wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_DISCONNECTED "bssid="
--
2.55.0
More information about the Hostap
mailing list