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

* Re: [Security] Bluetooth: SMP accepts a peer's claimed identity over an RPA link and overwrites another bond's IRK
  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
  1 sibling, 1 reply; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2026-11-18 16:29 UTC (permalink / raw)
  To: Mohammed; +Cc: marcel, linux-bluetooth

Hi Mohammed,

On Wed, Nov 18, 2026 at 11:16 AM Mohammed
<mohammed.saad.alquraini@gmail.com> wrote:
>
> 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.

The last sentences are actually not correct, even with NoInputNoOutput
it will still require the user to authorize, the only way to skip it
is by setting main.conf:JustWorksRepairing=always[1] which would mean
that the system accepts the risk of having impersonation attacks like
this, so no its nothing new, although hardning against it is still
valid.

> 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")

Fixes tag looks wrong, we probably need the commit id of the one that
added the check for is_identity, etc.

> 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;
>   }

And this needs to be a proper patch, git format-patch + git send-email
preferably.

-- 
Luiz Augusto von Dentz

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

* Re: [Security] Bluetooth: SMP accepts a peer's claimed identity over an RPA link and overwrites another bond's IRK
  2026-11-18 16:29 ` Luiz Augusto von Dentz
@ 2026-11-18 16:51   ` Mohammed
  0 siblings, 0 replies; 4+ messages in thread
From: Mohammed @ 2026-11-18 16:51 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: marcel, linux-bluetooth

[-- Attachment #1: Type: text/plain, Size: 11826 bytes --]

Hi Luiz,

Appreciate the quick response. The point you raised is fair to be honest.

I have attached the patch in the email; my smtp is broken and I'm
relying on Gmail GUI :).

Best,
Mohammed

On Wed, Nov 18, 2026 at 7:29 PM Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
>
> Hi Mohammed,
>
> On Wed, Nov 18, 2026 at 11:16 AM Mohammed
> <mohammed.saad.alquraini@gmail.com> wrote:
> >
> > 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.
>
> The last sentences are actually not correct, even with NoInputNoOutput
> it will still require the user to authorize, the only way to skip it
> is by setting main.conf:JustWorksRepairing=always[1] which would mean
> that the system accepts the risk of having impersonation attacks like
> this, so no its nothing new, although hardning against it is still
> valid.
>
> > 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")
>
> Fixes tag looks wrong, we probably need the commit id of the one that
> added the check for is_identity, etc.
>
> > 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;
> >   }
>
> And this needs to be a proper patch, git format-patch + git send-email
> preferably.
>
> --
> Luiz Augusto von Dentz

[-- Attachment #2: REPORT-linux-bluetooth-smp-irk-poisoning.patch --]
[-- Type: application/octet-stream, Size: 2971 bytes --]

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Mohammed Alquraini <mohammed.saad.alquraini@gmail.com>
Date: Tue, 18 Nov 2026 00:00:00 +0000
Subject: [PATCH] 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 identity-address checks there
are gated on hci_is_identity_address(&hcon->dst), which is false when the
connection is over a Resolvable Private Address (the normal LE privacy
case), so they are skipped and the claimed identity is accepted as-is.

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.

This was found with an AI-assisted code-analysis tool: it flagged the
missing ownership check in smp_cmd_ident_addr_info() for the RPA case,
and the fix was written and verified by hand. The overwrite and the
forged-RPA resolution were reproduced, and this fix confirmed to stop
both, over /dev/vhci in a QEMU guest on v7.4-rc3; the reproducer is
available on request.

Fixes: e12af489b91d ("Bluetooth: Fix valid Identity Address check")
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

* RE: [Security] Bluetooth: SMP accepts a peer's claimed identity over an RPA link and overwrites another bond's IRK
  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 18:23 ` bluez.test.bot
  1 sibling, 0 replies; 4+ messages in thread
From: bluez.test.bot @ 2026-11-18 18:23 UTC (permalink / raw)
  To: linux-bluetooth, mohammed.saad.alquraini

[-- Attachment #1: Type: text/plain, Size: 774 bytes --]

This is an automated email and please do not reply to this email.

Dear Submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
While preparing the CI tests, the patches you submitted couldn't be applied to the current HEAD of the repository.

----- Output -----

error: corrupt patch at line 14
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"

Please resolve the issue and submit the patches again.


---
Regards,
Linux Bluetooth


^ permalink raw reply	[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