Skip to content

Commit 7498ffb

Browse files
joerchannashif
authored andcommitted
Bluetooth: SMP: Add option to disallow unauthenticated re-pairing
Disallows all unauthenticated pairing attempts made by the peer where an unauthenticated bond already exists. This would enable cases where an attacker could copy the peer device address to connect and start an unauthenticated pairing procedure to replace the existing bond. Now in order to create a new bond the old bond has to be explicitly deleted with bt_unpair. Added option to disable this rule in order to maintain backwards compatibility in case this behavior is accepted. Signed-off-by: Joakim Andersson <[email protected]>
1 parent 2ae9e27 commit 7498ffb

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

subsys/bluetooth/host/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,17 @@ config BT_SMP_SC_ONLY
300300
Security Mode 1 Level 4 stands for authenticated LE Secure Connections
301301
pairing with encryption. Enabling this option disables legacy pairing.
302302

303+
config BT_SMP_ALLOW_UNAUTH_OVERWRITE
304+
bool "Allow unauthenticated pairing for paired device"
305+
help
306+
This option allows all unauthenticated pairing attempts made by the
307+
peer where an unauthenticated bond already exists.
308+
This would enable cases where an attacker could copy the peer device
309+
address to connect and start an unauthenticated pairing procedure
310+
to replace the existing bond. When this option is disabled in order
311+
to create a new bond the old bond has to be explicitly deleted with
312+
bt_unpair.
313+
303314
config BT_FIXED_PASSKEY
304315
bool "Use a fixed passkey for pairing"
305316
help

subsys/bluetooth/host/smp.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,12 @@ bool update_keys_check(struct bt_smp *smp)
581581
return false;
582582
}
583583

584+
if (!IS_ENABLED(CONFIG_BT_SMP_ALLOW_UNAUTH_OVERWRITE) &&
585+
(!(conn->le.keys->flags & BT_KEYS_AUTHENTICATED)
586+
&& smp->method == JUST_WORKS)) {
587+
return false;
588+
}
589+
584590
return true;
585591
}
586592

0 commit comments

Comments
 (0)