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

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
Low
Integrity
Low
Availability
High

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
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