[Security] Bluetooth: L2CAP: deferred BR/EDR accept bypasses the required BT_SECURITY level

From: Mohammed

Date: Wed Nov 18 2026 - 16:42:30 EST


Hi,

I'm reporting a vulnerability in the Linux kernel Bluetooth L2CAP layer
(net/bluetooth, deferred connection setup). A fix is posted separately as the
patch "[PATCH] Bluetooth: L2CAP: check security before completing a deferred
BR/EDR accept".

Affected: present in torvalds/linux 666539eecdf4 and unchanged at
mainline master
as of 2026-11-19 (no net/bluetooth change since then touches
__l2cap_connect_rsp_defer
or the deferred completion path). Reachable in a default
configuration: BlueZ's own
BR/EDR profile servers listen this way through its standard
bt_io_listen() API, so no
bespoke daemon is required (details below).

Summary
----------------
A BR/EDR L2CAP service that listens with BT_DEFER_SETUP asks the
kernel to enforce
its BT_SECURITY level and only decides which peer to admit. The deferred-accept
completion path does not honour that. The child channel is pollable before link
security resolves, so when userspace accepts and recvmsg()s it in that window,
l2cap_sock_defer() replies CONN_RSP result=SUCCESS with no security
check. If the
security procedure then fails, l2cap_security_cfm() has no branch that matches a
failed result on the now-completed channel, so nothing tears it down:
a peer that
failed the service's required security level keeps a connected,
data-passing channel.
No MITM-protected pairing is required; an auth failure is enough.

Details
-----------
1. The child channel is enqueued on the parent's accept queue at
CONN_REQ time, and
bt_accept_poll() (net/bluetooth/af_bluetooth.c) reports it pollable
while it is
still in BT_CONNECT2, specifically when the parent has BT_SK_DEFER_SETUP:

if (state == BT_CONNECTED ||
(test_bit(BT_SK_DEFER_SETUP, &bt->flags) &&
state == BT_CONNECT2)) {
mask = EPOLLIN | EPOLLRDNORM;

A poll-driven server therefore takes the connection while the link security
procedure is still pending.

2. l2cap_sock_defer() (net/bluetooth/l2cap_sock.c), reached from
recvmsg() on the
deferred child, completes the BR/EDR setup with no security consult:

} else { /* BR/EDR basic / ERTM */
sk->sk_state = BT_CONFIG;
chan->state = BT_CONFIG;
release_sock(sk);
__l2cap_connect_rsp_defer(chan);
}

__l2cap_connect_rsp_defer() then hardcodes rsp.result = L2CAP_CR_SUCCESS. The
sibling setsockopt(BT_SECURITY) path in the same file *does* re-check, via
l2cap_chan_check_security(); the non-deferred incoming path denies with
L2CAP_CR_SEC_BLOCK. Only this deferred BR/EDR path is missing the check.

3. On an auth failure, l2cap_security_cfm()
(net/bluetooth/l2cap_core.c) only denies
a channel still in BT_CONNECT2:

} else if (chan->state == BT_CONNECT2 && !(... FLOWCTL)) {
...
} else {
l2cap_state_change(chan, BT_DISCONN);
... res = L2CAP_CR_SEC_BLOCK;

The early accept in step 2 already moved the channel to BT_CONFIG,
so neither this
failure branch nor the !status success branch matches it: the
failed result is
silently dropped and the channel stays connected.

This is the BR/EDR counterpart of CVE-2025-39889 ("Bluetooth: l2cap:
Check encryption
key size on incoming connection", commit 522e9ed157e3), which added a
SEC_BLOCK gate
for the same class of problem at the non-deferred incoming site; the
kernel CNA rated
that one High (CVSS 8.1). The deferred site was not covered. The LE
connection-oriented deferred path is being given equivalent handling separately
(Kyle Pepper's "Keep credits from completing security upgrades"
series); this report
is the BR/EDR basic/ERTM piece that series does not touch.

Default-configuration reachability: BlueZ's bt_io_listen() enables
BT_DEFER_SETUP
whenever a confirm callback is supplied (btio/btio.c), and BR/EDR
profile servers
listen that way with a security level -- e.g. the HID interrupt channel,
profiles/input/server.c: bt_io_listen(NULL, confirm_event_cb, ...,
BT_IO_OPT_SEC_LEVEL,
...) on L2CAP_PSM_HIDP_INTR (A2DP/AVDTP, AVRCP and BNEP use the same
pattern). On an
incoming connection BlueZ runs the profile's confirm callback and
bt_io_accept() does
the completing read() while security is still pending. The kernel
inherits both the
defer flag and the security level onto the child (l2cap_sock_init).

Reproduction
------------------
On an unmodified build of commit 666539eecdf4 (CONFIG_BT=y, BT_BREDR=y, BT_LE=y,
BT_HCIVHCI=y, debugfs on), driven over /dev/vhci in a QEMU arm64 guest. A local
service listens with setsockopt(BT_SECURITY, HIGH) +
setsockopt(BT_DEFER_SETUP, 1) and
poll-accepts; the harness is both the controller and a BR/EDR peer that holds
Authentication_Complete:

- The service accepts during the pending window: the kernel sends CONN_RSP
result=PEND, the service accepts and recvmsg()s, and the kernel then
sends CONN_RSP
result=SUCCESS with the link still unauthenticated (the service
reads security level
0 on its own socket).
- The peer's Authentication_Complete is then delivered as a genuine failure
(status=6); the kernel emits MGMT_EV_AUTH_FAILED but sends no
Disconnection Request
and no CONN_RSP SEC_BLOCK. The channel stays BT_CONNECTED and keeps delivering
attacker data; the only teardown in the trace is the service process
being killed.
- Boundary control: the identical attacker against a listener
*without* BT_DEFER_SETUP
is refused with CONN_RSP result=3 (SEC_BLOCK) at the auth failure and receives
nothing. The deferred path is the hole.

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

Impact
------------
A remote BR/EDR peer in range, via a connection whose security the
kernel was asked to
enforce and which fails, ends up with a connected, data-delivering
L2CAP channel to a
service that required the kernel to deny it. In a default install that
service is a
bluetoothd profile server. The authorization decision the service
delegated to the
kernel is never applied. Access that the admitted channel may
subsequently reach 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:L/I:H/A:N = 7.1 (High).
I:H because the
security level the service required is bypassed and never enforced. C:L for the
attacker->service data flow shown (service->attacker confidentiality was not
demonstrated); A:N. UI:N because the kernel completes and keeps the
channel with no
user interaction, and the failing peer never needs a pairing prompt.
This matches the
kernel's own High (8.1) rating of the non-deferred sibling CVE-2025-39889.

Fix
------------
A suggested fix is posted separately (the patch named above); the
final form is of
course yours to decide. It gates the deferred completion on the
security state, in
two small parts:

- l2cap_sock_defer(): before completing a BR/EDR deferred accept, call
l2cap_chan_check_security() -- the same check the
setsockopt(BT_SECURITY) sibling
runs. If the level is not yet met, mark the socket BT_SK_ACCEPTED,
leave the channel
in BT_CONNECT2 and send nothing. The existing BT_CONNECT2 failure
branch then denies
with SEC_BLOCK on failure.
- l2cap_security_cfm(): on success, a channel the daemon already accepted
(BT_SK_ACCEPTED, read before the branch) is completed through the same path a
non-deferred accept takes (state -> BT_CONFIG, CONN_RSP SUCCESS +
CONF_REQ) instead
of re-signalling an accept already made, so exactly one CONN_RSP is
sent per channel
and the on-air sequence stays strictly monotonic.

Tested on the affected commit over the QEMU/vhci rig: before the patch, the
early-accepted channel survives a genuine auth failure and delivers
data; after it,
that case is answered with CONN_RSP SEC_BLOCK and no data flows,
identical to the
non-deferred control, while an early accept followed by a successful
auth completes
with exactly one CONN_RSP SUCCESS only after the security chain resolves, and a
deferred listener that accepts only after security resolves completes
via the designed
CR_PEND -> recvmsg -> SUCCESS path with the link at the required level. The test
kernel was built without lockdep; a PROVE_LOCKING run before applying
is worth doing,
though the added l2cap_chan_check_security() call takes no lock that
l2cap_security_cfm() does not already hold.

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

Thanks!