Skip to content

bt: host: Wrong key validation check

High
ceolin published GHSA-3286-jgjx-8cvr Dec 9, 2022

Package

zephyr (west)

Affected versions

<= 3.1

Patched versions

None

Description

Impact

I have discovered what I think is a potential vulnerability in Zephyr's SMP
implementation.

There is an error in the condition of the last if-statement in the function smp_check_keys,
i.e. the one that looks to be checking that the keys requirements of level 4 and higher are met.
As written, it appears to reject the current keys if ALL requirements are
unmet, but my understanding is that it should reject the keys if ANY of the requirements are unmet.

Here is a diff showing exactly what I think is wrong and how it could be
fixed:

diff --git a/subsys/bluetooth/host/smp.c b/subsys/bluetooth/host/smp.c
index 5132ad7495..3581b77bd6 100644
--- a/subsys/bluetooth/host/smp.c
+++ b/subsys/bluetooth/host/smp.c
@@ -363,9 +363,9 @@ static bool smp_keys_check(struct bt_conn *conn)
	}

	if (conn->required_sec_level > BT_SECURITY_L3 &&
-           !(conn->le.keys->flags & BT_KEYS_AUTHENTICATED) &&
-           !(conn->le.keys->keys & BT_KEYS_LTK_P256) &&
-           !(conn->le.keys->enc_size == BT_SMP_MAX_ENC_KEY_SIZE)) {
+           (!(conn->le.keys->flags & BT_KEYS_AUTHENTICATED) ||
+            !(conn->le.keys->keys & BT_KEYS_LTK_P256) ||
+            !(conn->le.keys->enc_size == BT_SMP_MAX_ENC_KEY_SIZE))) {
		return false;
	}

Patches

For more information

If you have any questions or comments about this advisory:

embargo: 2022-11-03

Severity

High
8.6
/ 10

CVSS base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
Low
Integrity
Low
Availability
High
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:H

CVE ID

CVE-2022-2993

Weaknesses

No CWEs