[PATCH 07/15] AP: Validate Extended RSN Capabilities in STA Security Profile element

Andrei Otcheretianski andrei.otcheretianski at intel.com
Tue Nov 24 00:53:03 PST 2026


From: Ilan Peer <ilan.peer at intel.com>

The indications in the Security Profile element were verified only
against the Extended RSN element. Fix this to also verify the
indications against the Extended RSN Capabilities field in the
Security Profile element as well.

Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
 src/ap/ieee802_11.c | 77 ++++++++++++++++++++++++++++++---------------
 1 file changed, 51 insertions(+), 26 deletions(-)

diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c
index e1e0d4ada1..3b0eb61c66 100644
--- a/src/ap/ieee802_11.c
+++ b/src/ap/ieee802_11.c
@@ -250,6 +250,41 @@ static bool hostapd_sec_prof_enabled(const struct hostapd_bss_config *conf,
 }
 
 
+static bool
+sec_prof_check_rsnx_capab(const struct security_profile_entry *entry,
+			  const u8 *capab, size_t capab_len, const char *src)
+{
+	if (entry->ieee8021x_auth_frame &&
+	    !ieee802_11_rsnx_capab_len(capab, capab_len,
+				       WLAN_RSNX_CAPAB_802_1X_IN_AUTH_FRAMES)) {
+		wpa_printf(MSG_DEBUG,
+			   "Security profile=%d: 8021x_auth_frame capab missing in %s",
+			   entry->number, src);
+		return false;
+	}
+
+	if (entry->assoc_frame_encrypt &&
+	    !ieee802_11_rsnx_capab_len(capab, capab_len,
+				       WLAN_RSNX_CAPAB_ASSOC_FRAME_ENCRYPTION)) {
+		wpa_printf(MSG_DEBUG,
+			   "Security profile=%d: assoc_frame_encrypt capab missing in %s",
+			   entry->number, src);
+		return false;
+	}
+
+	if (entry->pmksa_caching_privacy &&
+	    !ieee802_11_rsnx_capab_len(capab, capab_len,
+				       WLAN_RSNX_CAPAB_PMKSA_CACHING_PRIVACY)) {
+		wpa_printf(MSG_DEBUG,
+			   "Security profile=%d: pmksa_caching_privacy capab missing in %s",
+			   entry->number, src);
+		return false;
+	}
+
+	return true;
+}
+
+
 /**
  * find_and_validate_profile - Find and validate a matching security profile
  * @hapd: AP data
@@ -259,6 +294,8 @@ static bool hostapd_sec_prof_enabled(const struct hostapd_bss_config *conf,
  * @rsne_data: Parsed RSNE data from STA
  * @rsnxe: STA's RSNXE data
  * @rsnxe_len: STA's RSNXE data len
+ * @sp_rsnx: Extended RSN Capabilities field of STA's Security Profile element
+ * @sp_rsnx_len: Length of sp_rsnx
  * @profile_matched: On success, returns the matched profile entry
  * Returns: true if a matching security profile is found and validated, false
  * otherwise
@@ -268,6 +305,7 @@ static bool find_and_validate_profile(
 	int sta_profile_num,
 	const struct wpa_ie_data *rsne_data,
 	const u8 *rsnxe, size_t rsnxe_len,
+	const u8 *sp_rsnx, size_t sp_rsnx_len,
 	const struct security_profile_entry **profile_matched)
 {
 	const struct security_profile_entry *entry;
@@ -328,24 +366,10 @@ static bool find_and_validate_profile(
 	}
 
 	/* Validate RSNXE fields */
-	if (entry->ieee8021x_auth_frame &&
-	    !ieee802_11_rsnx_capab_len(rsnxe, rsnxe_len,
-				       WLAN_RSNX_CAPAB_802_1X_IN_AUTH_FRAMES)) {
-		wpa_printf(MSG_DEBUG,
-			   "Security profile number %d 8021x_auth_frame capab missing",
-			   sta_profile_num);
+	if (!sec_prof_check_rsnx_capab(entry, rsnxe, rsnxe_len, "RSNXE") ||
+	    !sec_prof_check_rsnx_capab(entry, sp_rsnx, sp_rsnx_len,
+				       "Security Profile element"))
 		return false;
-	}
-
-	if (entry->assoc_frame_encrypt &&
-	    !ieee802_11_rsnx_capab_len(rsnxe, rsnxe_len,
-				       WLAN_RSNX_CAPAB_ASSOC_FRAME_ENCRYPTION))
-	{
-		wpa_printf(MSG_DEBUG,
-			   "Security profile number %d assoc_frame_encrypt capab missing",
-			   sta_profile_num);
-		return false;
-	}
 
 	if (entry->assoc_frame_encrypt && !ap_sta_is_epp(sta)) {
 		wpa_printf(MSG_DEBUG,
@@ -365,15 +389,6 @@ static bool find_and_validate_profile(
 		return false;
 	}
 
-	if (entry->pmksa_caching_privacy &&
-	    !ieee802_11_rsnx_capab_len(rsnxe, rsnxe_len,
-				       WLAN_RSNX_CAPAB_PMKSA_CACHING_PRIVACY)) {
-		wpa_printf(MSG_DEBUG,
-			   "Security profile number %d pmksa_caching_privacy capab missing",
-			   sta_profile_num);
-		return false;
-	}
-
 	wpa_printf(MSG_DEBUG,
 		   "Station " MACSTR
 		   " indicated security profile number %d matches (key_mgmt=0x%x cipher=0x%x)",
@@ -411,6 +426,8 @@ static bool validate_sta_security_profile(
 {
 	struct wpa_ie_data data;
 	int sta_profile_num;
+	const u8 *sp_rsnx = NULL;
+	size_t sp_rsnx_len = 0, offset;
 
 	if (!hapd->conf->security_profiles)
 		return true; /* No profiles configured, allow */
@@ -445,9 +462,17 @@ static bool validate_sta_security_profile(
 	wpa_printf(MSG_DEBUG, "STA " MACSTR " profile number: %d",
 		   MAC2STR(sta->addr), sta_profile_num);
 
+	/* Extended RSN Capabilities follow the Bitmap (no vendor profiles) */
+	offset = 2 + (sec_prof[1] & 0x0f);
+	if (offset < sec_prof_len) {
+		sp_rsnx = sec_prof + offset;
+		sp_rsnx_len = sec_prof_len - offset;
+	}
+
 	/* Use the helper function to find and validate the profile */
 	return find_and_validate_profile(hapd, sta, assoc, sta_profile_num,
 					 &data, rsnxe, rsnxe_len,
+					 sp_rsnx, sp_rsnx_len,
 					 profile_matched);
 }
 
-- 
2.56.1




More information about the Hostap mailing list