[PATCH 20/21] tests: Add MBSSID test verifying beacon loss if MIC is incorrect
Benjamin Berg
benjamin at sipsolutions.net
Tue Oct 27 06:17:06 PDT 2026
From: Benjamin Berg <benjamin.berg at intel.com>
This adds a test where the BIGTK is corrupted on the AP side, causing
all beacons to be lost. Then reverse the checks to verify the expected
failures.
Signed-off-by: Benjamin Berg <benjamin.berg at intel.com>
Reviewed-by: Andrei Otcheretianski <andrei.otcheretianski at intel.com>
---
tests/hwsim/test_he_mbssid.py | 46 +++++++++++++++++++++++++++--------
1 file changed, 36 insertions(+), 10 deletions(-)
diff --git a/tests/hwsim/test_he_mbssid.py b/tests/hwsim/test_he_mbssid.py
index befe7d1caa..422a39cd7c 100644
--- a/tests/hwsim/test_he_mbssid.py
+++ b/tests/hwsim/test_he_mbssid.py
@@ -433,6 +433,11 @@ def test_mbssid_nontx_beacon_prot_non_tx_then_tx(dev, apdev, params):
"""HE AP MBSSID beacon protection (only non-TX) with Association on non-Tx BSS followed by Tx BSS"""
run_mbssid_beacon_prot(dev, apdev, params, True, False)
+def test_he_ap_mbssid_beacon_prot_invalid_bigtk(dev, apdev, params):
+ """HE AP MBSSID beacon protection with invalid BIGTK on AP (Tx BSS then non-Tx BSS)"""
+ run_mbssid_beacon_prot(dev, apdev, params, False, invalidate_bigtk=True)
+
+
def get_mac80211_bigtks(dev):
phy = dev.get_driver_status_field("phyname")
keys = f"/sys/kernel/debug/ieee80211/{phy}/keys"
@@ -463,7 +468,7 @@ def get_mac80211_bigtks(dev):
return res
-def run_mbssid_beacon_prot(dev, apdev, params, non_tx_first, tx_beacon_prot=True):
+def run_mbssid_beacon_prot(dev, apdev, params, non_tx_first, tx_beacon_prot=True, invalidate_bigtk=False):
check_sae_capab(dev[0])
check_sae_capab(dev[1])
f, fname, ifname = mbssid_create_cfg_file(apdev, params)
@@ -486,6 +491,7 @@ def run_mbssid_beacon_prot(dev, apdev, params, non_tx_first, tx_beacon_prot=True
dev[1].set("sae_groups", "")
hapd, pid = mbssid_start_ap(dev, apdev, params, fname, ifname, None,
only_start_ap=True)
+
if non_tx_first:
dev[1].connect("bss-1", psk="another password", key_mgmt="SAE",
ieee80211w="2", beacon_prot="1", scan_freq="2412")
@@ -499,7 +505,17 @@ def run_mbssid_beacon_prot(dev, apdev, params, non_tx_first, tx_beacon_prot=True
dev[1].connect("bss-1", psk="another password", key_mgmt="SAE",
ieee80211w="2", beacon_prot="1", scan_freq="2412")
- bigtk_mismatch = False
+ if invalidate_bigtk:
+ WPA_ALG_BIP_CMAC_128 = 4
+ KEY_FLAG_DEFAULT = 0x02
+ KEY_FLAG_TX = 0x08
+ KEY_FLAG_GROUP = 0x10
+ KEY_FLAG_GROUP_TX_DEFAULT = KEY_FLAG_GROUP | KEY_FLAG_TX | KEY_FLAG_DEFAULT
+
+ # key index 7, as we will have had one update
+ hapd.request('SET_KEY %d %s %d %d %s %s %d' % (WPA_ALG_BIP_CMAC_128, "ff:ff:ff:ff:ff:ff",
+ 7, 1, 6*"00", 16*"00", KEY_FLAG_GROUP_TX_DEFAULT))
+
unexpected_bigtk = False
try:
ap_bigtks = get_mac80211_bigtks(hapd)
@@ -509,6 +525,7 @@ def run_mbssid_beacon_prot(dev, apdev, params, non_tx_first, tx_beacon_prot=True
logger.info(f'BIGTKs dev0: {dev0_bigtks}')
logger.info(f'BIGTKs dev1: {dev1_bigtks}')
+ bigtk_mismatch = False
if tx_beacon_prot:
if dev0_bigtks[0] not in ap_bigtks:
bigtk_mismatch = True
@@ -518,8 +535,8 @@ def run_mbssid_beacon_prot(dev, apdev, params, non_tx_first, tx_beacon_prot=True
if dev1_bigtks[0] not in ap_bigtks:
bigtk_mismatch = True
except HwsimSkip:
- # We can still check that no beacon loss happened
- pass
+ # We can still check the beacon loss condition
+ bigtk_mismatch = True if invalidate_bigtk else False
beacon_loss0 = False
beacon_loss1 = False
@@ -532,12 +549,21 @@ def run_mbssid_beacon_prot(dev, apdev, params, non_tx_first, tx_beacon_prot=True
mbssid_stop_ap(hapd, pid)
- if beacon_loss0:
- raise Exception("Beacon loss detected on TX BSS")
- if beacon_loss1:
- raise Exception("Beacon loss detected on non-TX BSS")
- if bigtk_mismatch:
- raise Exception("Installed BIGTKs did not match between AP and STA(s)")
+ if not invalidate_bigtk:
+ if beacon_loss0:
+ raise Exception("Beacon loss detected on TX BSS")
+ if beacon_loss1:
+ raise Exception("Beacon loss detected on non-TX BSS")
+ if bigtk_mismatch:
+ raise Exception("Installed BIGTKs did not match between AP and STA(s)")
+ else:
+ if not beacon_loss0:
+ raise Exception("No beacon loss detected on TX BSS")
+ if not beacon_loss1:
+ raise Exception("No beacon loss detected on non-TX BSS")
+ if not bigtk_mismatch:
+ raise Exception("Installed BIGTKs matched between AP and STA(s)")
+
if unexpected_bigtk:
raise Exception("STA on TX-BSSID should not have a BIGTK installed")
finally:
--
2.56.0
More information about the Hostap
mailing list