Linux bluetooth development
 help / color / mirror / Atom feed
* [Security] Bluetooth: SMP accepts a peer's claimed identity over an RPA link and overwrites another bond's IRK
@ 2026-11-18 16:16 Mohammed
  2026-11-18 16:29 ` Luiz Augusto von Dentz
  2026-11-18 18:23 ` bluez.test.bot
  0 siblings, 2 replies; 4+ messages in thread
From: Mohammed @ 2026-11-18 16:16 UTC (permalink / raw)
  To: marcel, Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hi,

I'm reporting a vulnerability in the Linux kernel Bluetooth LE Security Manager
(net/bluetooth SMP / IRK handling). A suggested tested fix is inlined
below the scissors
line at the end (git am --scissors).

Affected: present in torvalds/linux 666539eecdf4 and unchanged at
mainline master
as of 2026-11-18 (no net/bluetooth change since 2026-11-09 touches these paths).
Reachable once LE privacy / RPA resolution is active, which userspace
(bluetoothd)
enables via mgmt Set Privacy whenever LE privacy is in use; not
reachable on a bare
kernel with no userspace privacy setup.

Summary
----------------
During LE pairing key distribution, smp_cmd_ident_addr_info() accepts
the identity
address a peer claims in its SMP Identity Address Information PDU without any
ownership check when the connection is over a Resolvable Private
Address, which is
the normal LE-privacy case. hci_add_irk() then stores the peer's IRK under that
claimed identity and overwrites any existing entry in place. A peer
can therefore
claim the identity address of a different, already-bonded device and
replace that
bond's stored IRK (and the LTK distributed in the same pairing) with its own key
material. No MITM-protected pairing method is required; Just Works is
sufficient.

Details
-----------
1. smp_cmd_ident_addr_info() (net/bluetooth/smp.c) rejects a mismatched identity
   only when the connection address is itself an identity address:

        if (hci_is_identity_address(&hcon->dst, hcon->dst_type) &&
            (bacmp(&info->bdaddr, &hcon->dst) ||
             info->addr_type != hcon->dst_type)) {
                bt_dev_err(hcon->hdev,
                           "ignoring IRK with invalid identity address");
                goto distribute;
        }

   hci_is_identity_address() is false for an RPA/NRPA connection, so under LE
   privacy (hcon->dst is an RPA for a fresh pairing) this check is
skipped and the
   claimed (bdaddr, addr_type) is accepted. The in-code comment above this check
   states the intent to drop a peer that provides a different identity address,
   which is the guard the RPA path is missing. The sibling that does enforce an
   identity property is the type check just above (commit e12af489, discard IRKs
   whose address type is not public or static random); the mismatch check itself
   (commit 1d87b88ba26e) was added as a workaround for one device and
only covers
   the non-RPA case.

2. hci_add_irk() (net/bluetooth/hci_core.c) is find-or-create and overwrites:

        old_irk = hci_find_irk_by_addr(hdev, bdaddr, addr_type);
        irk = old_irk;
        if (!irk) { ... allocate ... }
        memcpy(irk->val, val, 16);
        bacpy(&irk->rpa, rpa);
        if (!old_irk)
                list_add_rcu(&irk->list, &hdev->identity_resolving_keys);

   If an IRK for the claimed (identity, type) already exists, that
bond's key value
   and cached RPA are replaced with the attacker's.

3. Nothing requires the distributed IRK to resolve the connection's
RPA before it
   is bound to an identity. smp_cmd_ident_addr_info() records the
connection RPA but
   never verifies ah(IRK, prand) == RPA.

4. On completion, smp_notify_keys() exports the entry (mgmt New IRK)
and, for an LE
   link, rewrites hcon->dst to the claimed identity; the LTK and any
CSRK from the
   same pairing are stored under that identity. hci_find_irk_by_rpa()
then resolves
   an RPA the attacker forges from its own IRK to the claimed identity.

This is distinct from CVE-2025-62235 (Apache NimBLE) and the BLERP
re-pairing work,
which concern the LTK via the SMP Security Request / re-pairing path
in other stacks
and do not touch IRK or identity-address handling.

Reproduction
------------------
On an unmodified build of commit 666539eecdf4 (CONFIG_BT=y, BT_LE=y,
BT_HCIVHCI=y,
debugfs on), driven over /dev/vhci in a QEMU guest:

- Establish a legitimate bond: a Just Works pairing from an RPA, distributing an
  IRK for identity B (a public address). debugfs
identity_resolving_keys shows one
  entry for B with that IRK.
- Poisoning pairing: a second Just Works pairing from a fresh RPA whose Identity
  Address Information claims B's identity. No rejection fires. debugfs shows the
  same single entry, its IRK value overwritten in place with the attacker's; the
  attacker LTK is stored under B's identity (mgmt New Long Term Key for B).
- Impersonation: an RPA forged from the attacker's IRK is resolved by
the kernel to
  B's identity (mgmt Device Connected reports B's address).

A self-contained reproducer (fake controller plus attacker pairing) is
available on
request.

Impact
------------
A remote peer, via a pairing the kernel accepts, overwrites the stored
IRK and LTK
of a different already-bonded device in hdev->identity_resolving_keys,
which breaks
that legitimate bond, and the kernel then resolves addresses the
attacker forges to
the victim device's identity. The destruction and redirection of an
unrelated bond
do not depend on the host trusting the attacker's own device; the only
interaction
required is that the host pairs with the attacker. Access that bond
resolution may
subsequently authorize at the application layer was not exercised and
is not claimed.

Severity: CVSS:3.1/AV:A/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:L = 7.1 (High).
I:H because a
trusted bond's key is overwritten and the attacker is then resolved as
that device;
S:U because the impact stays within the host's own Bluetooth bond
store (no crossing
into another security authority); A:L for the denial of the
overwritten bond. UI:N
because the kernel performs the overwrite with no user interaction:
the SMP state
machine accepts the Identity Address Information PDU and overwrites
the IRK, and Just
Works bonding with a NoInputNoOutput peer is auto-accepted with no prompt.

Suggested fix
-------------
The patch below is a suggested fix; the final form is of course yours
to decide. It
refuses, in smp_cmd_ident_addr_info(), to replace an IRK that is
already bound to an
identity when the peer connects from an unresolved RPA
(hci_bdaddr_is_rpa(&hcon->dst) && hci_find_irk_by_addr(... info->bdaddr ...)). A
genuine reconnection of a bonded device has its RPA resolved to that
identity before
key distribution, so hcon->dst is the identity and the existing check
applies; an
unresolved RPA claiming an already-bonded identity means the peer is
not that device.
First-time bonding and reconnection of a bonded device are unaffected;
changing a
bonded identity's IRK now requires removing the old bond first.
Requiring the IRK to
resolve the RPA was considered and does not work, since the peer
controls both and
derives its RPA from the IRK it sends. Tested on the affected commit: before the
patch the poisoning pairing overwrote the bond's IRK and the forged
RPA resolved to
the victim; after it, the pairing is rejected, the stored IRK is
unchanged, and the
forged RPA no longer resolves.

Credit
-------------
Mohammed Alquraini, HUMAIN. Found with an AI tool (an LLM-based code analysis
pipeline) and validated by hand with the reproduction above.



------------------------ >8 ------------------------
From: Mohammed Alquraini <mohammed.saad.alquraini@gmail.com>
Subject: Bluetooth: SMP: don't overwrite a bonded IRK from an unresolved RPA

smp_cmd_ident_addr_info() stores the IRK a peer distributes under the
identity address the peer claims, via hci_add_irk(), which replaces any
existing entry for that (address, type). The only ownership check, added
by commit 1d87b88ba26e, is gated on hci_is_identity_address(&hcon->dst)
and is skipped when the connection is over a Resolvable Private Address,
i.e. the normal LE privacy case.

A peer can use this to claim the identity address of a different,
already-bonded device and overwrite that bond's IRK (and the LTK
distributed in the same pairing) with its own key material. Just Works is
enough. The legitimate bond then stops resolving, and an RPA the attacker
forges from its own IRK resolves to the victim device's identity.

Requiring the distributed IRK to resolve the connection RPA does not help:
the peer controls both and can derive its RPA from the IRK it sends.

Refuse instead to replace an IRK already bound to an identity when the peer
connects from an unresolved RPA. A genuine reconnection of a bonded device
has its RPA resolved to that identity before key distribution, so hcon->dst
is the identity rather than an RPA. First-time bonding and reconnection of a
bonded device are unaffected; changing the IRK of a bonded identity now
requires removing the existing bond first.

Fixes: 1d87b88ba26e ("Bluetooth: Add SMP workaround Microsoft Surface
Precision Mouse bug")
Reported-by: Mohammed Alquraini <mohammed.saad.alquraini@gmail.com>
Assisted-by: LLM
Signed-off-by: Mohammed Alquraini <mohammed.saad.alquraini@gmail.com>
---
 net/bluetooth/smp.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index b7015e37e1f1..6a417e3c9041 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -2634,6 +2634,16 @@ static int smp_cmd_ident_addr_info(struct
l2cap_conn *conn,
      info->addr_type != hcon->dst_type)) {
  bt_dev_err(hcon->hdev,
    "ignoring IRK with invalid identity address");
+ goto distribute;
+ }
+
+ /* Don't let a peer connecting from an unresolved RPA replace the IRK of
+ * an already-bonded identity: it has not proven it is that device.
+ */
+ if (hci_bdaddr_is_rpa(&hcon->dst, hcon->dst_type) &&
+    hci_find_irk_by_addr(hcon->hdev, &info->bdaddr, info->addr_type)) {
+ bt_dev_err(hcon->hdev,
+   "ignoring IRK for an identity already bound to a bond");
  goto distribute;
  }

--
2.43.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-18 18:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18 16:16 [Security] Bluetooth: SMP accepts a peer's claimed identity over an RPA link and overwrites another bond's IRK Mohammed
2026-11-18 16:29 ` Luiz Augusto von Dentz
2026-11-18 16:51   ` Mohammed
2026-11-18 18:23 ` bluez.test.bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox