mirror of
https://github.com/Divested-Mobile/DivestOS-Build.git
synced 2024-10-01 01:35:54 -04:00
093df020a2
Signed-off-by: Tavi <tavi@divested.dev>
63 lines
2.4 KiB
Diff
63 lines
2.4 KiB
Diff
From 9dabeb4f8d2ab8936c84823786fab90d0e929ce3 Mon Sep 17 00:00:00 2001
|
|
From: Brian Delwiche <delwiche@google.com>
|
|
Date: Mon, 22 Apr 2024 21:14:56 +0000
|
|
Subject: [PATCH] [BACKPORT] Fix an authentication bypass bug in SMP
|
|
|
|
When pairing with BLE legacy pairing initiated
|
|
from remote, authentication can be bypassed.
|
|
This change fixes it.
|
|
|
|
Bug: 251514170
|
|
Test: m com.android.btservices
|
|
Test: manual run against PoC
|
|
Ignore-AOSP-First: security
|
|
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:8a3dbadc71428a30b172a74343be08498c656747)
|
|
Merged-In: I66b1f9a80060f48a604001829db8ea7c96c7b7f8
|
|
Change-Id: I66b1f9a80060f48a604001829db8ea7c96c7b7f8
|
|
---
|
|
stack/smp/smp_act.c | 11 +++++++++++
|
|
stack/smp/smp_int.h | 1 +
|
|
2 files changed, 12 insertions(+)
|
|
|
|
diff --git a/stack/smp/smp_act.c b/stack/smp/smp_act.c
|
|
index 8702e109578..a9bcd4c87c2 100644
|
|
--- a/stack/smp/smp_act.c
|
|
+++ b/stack/smp/smp_act.c
|
|
@@ -331,6 +331,7 @@ void smp_send_confirm(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
|
|
{
|
|
SMP_TRACE_DEBUG("%s", __func__);
|
|
smp_send_cmd(SMP_OPCODE_CONFIRM, p_cb);
|
|
+ p_cb->flags |= SMP_PAIR_FLAGS_CMD_CONFIRM_SENT;
|
|
}
|
|
|
|
/*******************************************************************************
|
|
@@ -704,6 +705,16 @@ void smp_proc_init(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
|
|
return;
|
|
}
|
|
|
|
+ if (!((p_cb->loc_auth_req & SMP_SC_SUPPORT_BIT) &&
|
|
+ (p_cb->peer_auth_req & SMP_SC_SUPPORT_BIT)) &&
|
|
+ !(p_cb->flags & SMP_PAIR_FLAGS_CMD_CONFIRM_SENT))
|
|
+ {
|
|
+ // in legacy pairing, the peer should send its rand after
|
|
+ // we send our confirm
|
|
+ smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &reason);
|
|
+ return;
|
|
+ }
|
|
+
|
|
/* save the SRand for comparison */
|
|
STREAM_TO_ARRAY(p_cb->rrand, p, BT_OCTET16_LEN);
|
|
}
|
|
diff --git a/stack/smp/smp_int.h b/stack/smp/smp_int.h
|
|
index aea85380edd..aac64ea2ef1 100644
|
|
--- a/stack/smp/smp_int.h
|
|
+++ b/stack/smp/smp_int.h
|
|
@@ -251,6 +251,7 @@ typedef union
|
|
#define SMP_PAIR_FLAG_HAVE_PEER_PUBL_KEY (1 << 6) /* used on slave to resolve race condition */
|
|
#define SMP_PAIR_FLAG_HAVE_PEER_COMM (1 << 7) /* used to resolve race condition */
|
|
#define SMP_PAIR_FLAG_HAVE_LOCAL_PUBL_KEY (1 << 8) /* used on slave to resolve race condition */
|
|
+#define SMP_PAIR_FLAGS_CMD_CONFIRM_SENT (1 << 9)
|
|
|
|
/* check if authentication requirement need MITM protection */
|
|
#define SMP_NO_MITM_REQUIRED(x) (((x) & SMP_AUTH_YN_BIT) == 0)
|