Skip to contentSkip to conversation

Bluetooth: SMP: Fail if local and remote public key X coords match

PATCH Applied Chun-Yi Lee 3 participants 3 messages Nov 11

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Bluetooth: SMP: Fail if local and remote public key X coords match

From: Chun-Yi Lee <[email protected]>

The commit 6d19628f539f ("Bluetooth: SMP: Fail if remote and local public keys are identical")
patch be introduced since v5.13. Looks this patch can handle the
CVE-2021-37577 issue. However, it only checks if the full 64-byte
public key (X and Y coordinates) is identical, which is insufficient.

In CVE-2021-37577:
Bluetooth LE and BR/EDR Secure Connections pairing and Secure Simple Pairing using the Passkey entry protocol in Bluetooth Core Specifications 2.1 through 5.3 may permit an unauthenticated man-in-the-middle attacker to identify the Passkey used during pairing by reflection of a crafted public key with the same X coordinate as the offered public key and by reflection of the authentication evidence of the initiating device, potentially permitting this attacker to complete authenticated pairing with the responding device using the correct Passkey for the pairing session. This is a related issue to CVE-2020-26558.

Furthermore, according to the Bluetooth Core Specification, the remote and local public keys should not have the same X coordinate:

Bluetooth Core Specification Version: v5.4
(7.1 PHASE 1: PUBLIC KEY EXCHANGE)
"If the two public keys have the same X coordinate and neither is the debug key (see [Vol 4] Part E, Section 7.6.4), each device should fail the pairing process."

Bluetooth Core Specification Version: v6.0
(7.1 Phase 1: Public key exchange)
"If the two public keys have the same X coordinate and neither is the debug key (see [Vol 4] Part E, Section 7.6.4), each device shall fail the pairing process."

To ensure both initiator and responder roles strictly enforce this rule:
- In smp_cmd_public_key(), restrict the check for the initiator to compare only the 32-byte X coordinate of the public keys rather than the full 64 bytes.
- In sc_send_public_key(), add the corresponding check for the responder to verify that the 32-byte X coordinate of remote_pk does not match local_pk before transmitting its own public key.

This makes the validation compliant with the specification and mitigates CVE-2021-37577 across both pairing roles.

Fixes 6d19628f539f ("Bluetooth: SMP: Fail if remote and local public keys are identical")
---
 net/bluetooth/smp.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
net/bluetooth/smp.c +12 -1
index 2df303f6a38f..d1786e398128 100644
@@ -1889,6 +1889,16 @@ static u8 sc_send_public_key(struct smp_chan *smp)
 	}
 
 done:
+	/* Check if remote and local public keys are the same and debug key is
+	 * not in use.
+	 */
+	if (!test_bit(SMP_FLAG_DEBUG_KEY, &smp->flags) &&
+	    !test_bit(SMP_FLAG_INITIATOR, &smp->flags) &&
+	    !crypto_memneq(smp->remote_pk, smp->local_pk, 32)) {
+		bt_dev_err(hdev, "Remote and local public keys are identical");
+		return SMP_DHKEY_CHECK_FAILED;
+	}
+
 	SMP_DBG("Local Public Key X: %32phN", smp->local_pk);
 	SMP_DBG("Local Public Key Y: %32phN", smp->local_pk + 32);
 
@@ -2734,7 +2744,8 @@ static int smp_cmd_public_key(struct l2cap_conn *conn, struct sk_buff *skb)
 	 * not in use.
 	 */
 	if (!test_bit(SMP_FLAG_DEBUG_KEY, &smp->flags) &&
-	    !crypto_memneq(key, smp->local_pk, 64)) {
+	    test_bit(SMP_FLAG_INITIATOR, &smp->flags) &&
+	    !crypto_memneq(key, smp->local_pk, 32)) {
 		bt_dev_err(hdev, "Remote and local public keys are identical");
 		return SMP_DHKEY_CHECK_FAILED;
 	}
Signature · 1 line
2.51.0
#1 lore raw

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/series/1208171/

---Test result---

Test Summary:

CheckPatch                    FAIL      0.84 seconds
VerifyFixes                   PASS      0.11 seconds
VerifySignedoff               PASS      1.15 seconds
GitLint                       FAIL      0.33 seconds
SubjectPrefix                 PASS      0.11 seconds
BuildKernel                   PASS      31.36 seconds
CheckAllWarning               PASS      35.88 seconds
CheckSparse                   PASS      37.99 seconds
BuildKernel32                 PASS      31.27 seconds
CheckKernelLLVM               PASS      41.46 seconds
TestRunnerSetup               PASS      748.56 seconds
TestRunner_smp-tester         PASS      6.42 seconds
IncrementalBuild              PASS      29.14 seconds

Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
Bluetooth: SMP: Fail if local and remote public key X coords match
WARNING: Prefer a maximum 75 chars per line (possible unwrapped commit description?) #122:
The commit 6d19628f539f ("Bluetooth: SMP: Fail if remote and local public keys are identical")

total: 0 errors, 1 warnings, 0 checks, 25 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.

/home/runner/work/bluetooth-next/bluetooth-next/src/patch/14971828.patch has style problems, please review.

NOTE: Ignored message types: UNKNOWN_COMMIT_ID

NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.

##############################
Test: GitLint - FAIL
Desc: Run gitlint
Output:
Bluetooth: SMP: Fail if local and remote public key X coords match

5: B1 Line exceeds max length (94>80): "The commit 6d19628f539f ("Bluetooth: SMP: Fail if remote and local public keys are identical")"

https://github.com/bluez/bluetooth-next/pull/1109

---
Regards,
Linux Bluetooth

#2 lore raw
In reply to Chun-Yi Lee
This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:

Hello:

This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:

Quoted 8 lines · On Wed, 11 Nov 2026 17:45:18 +0800 you wrote:

From: Chun-Yi Lee <[email protected]>

The commit 6d19628f539f ("Bluetooth: SMP: Fail if remote and local public keys are identical")
patch be introduced since v5.13. Looks this patch can handle the
CVE-2021-37577 issue. However, it only checks if the full 64-byte
public key (X and Y coordinates) is identical, which is insufficient.

[...]

Here is the summary with links:
- Bluetooth: SMP: Fail if local and remote public key X coords match

    https://git.kernel.org/bluetooth/bluetooth-next/c/fd038b82c71b

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html