[PATCH] P2P: Check PBMA attribute length before reading bootstrap

Junyu Lai junyulai at google.com
Tue Nov 17 19:19:41 PST 2026


All P2P2 Pairing and Bootstrapping Method Attributes (PBMA) carry at
least a 2-octet Bootstrapping Method field. However, attribute parsing
previously allowed 1-octet PBMA payloads, and Provision Discovery
bootstrap request handling read the 16-bit bootstrapping method without
verifying that at least 2 octets were present.

- Require at least 2 octets when parsing
  P2P_ATTR_PAIRING_AND_BOOTSTRAPPING.
- Check that PBMA length is at least 2 octets before reading the
  bootstrapping method in Provision Discovery bootstrap requests.

Signed-off-by: Junyu Lai <junyulai at google.com>
---
 src/p2p/p2p_parse.c | 2 +-
 src/p2p/p2p_pd.c    | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/p2p/p2p_parse.c b/src/p2p/p2p_parse.c
index cd3332d6b..faddbfecf 100644
--- a/src/p2p/p2p_parse.c
+++ b/src/p2p/p2p_parse.c
@@ -428,7 +428,7 @@ static int p2p_parse_attribute(u8 id, const u8 *data, u16 len,
 		wpa_printf(MSG_DEBUG, "P2P: * PCEA (length=%u)", len);
 		break;
 	case P2P_ATTR_PAIRING_AND_BOOTSTRAPPING:
-		if (len < 1) {
+		if (len < 2) {
 			wpa_printf(MSG_DEBUG, "P2P: Too short PBMA (length %d)",
 				   len);
 			return -1;
diff --git a/src/p2p/p2p_pd.c b/src/p2p/p2p_pd.c
index d9bff5a68..bb40c87e7 100644
--- a/src/p2p/p2p_pd.c
+++ b/src/p2p/p2p_pd.c
@@ -784,6 +784,10 @@ static void p2p_process_prov_disc_bootstrap_req(struct p2p_data *p2p,
 		}
 	} else {
 		/* PBMA request */
+		if (!pos || msg->pbma_info_len < 2) {
+			p2p_dbg(p2p, "Truncated PBMA");
+			return;
+		}
 		bootstrap = WPA_GET_LE16(pos);
 
 		os_free(dev->bootstrap_params);
-- 
2.56.1.703.gf848ed807c-goog




More information about the Hostap mailing list