Skip to content

Commit d05111b

Browse files
1sealVudentz
authored andcommitted
Bluetooth: SMP: force responder MITM requirements before building the pairing response
smp_cmd_pairing_req() currently builds the pairing response from the initiator auth_req before enforcing the local BT_SECURITY_HIGH requirement. If the initiator omits SMP_AUTH_MITM, the response can also omit it even though the local side still requires MITM. tk_request() then sees an auth value without SMP_AUTH_MITM and may select JUST_CFM, making method selection inconsistent with the pairing policy the responder already enforces. When the local side requires HIGH security, first verify that MITM can be achieved from the IO capabilities and then force SMP_AUTH_MITM in the response in both rsp.auth_req and auth. This keeps the responder auth bits and later method selection aligned. Fixes: 2b64d15 ("Bluetooth: Add MITM mechanism to LE-SMP") Cc: stable@vger.kernel.org Suggested-by: Luiz Augusto von Dentz <luiz.dentz@gmail.com> Signed-off-by: Oleh Konko <security@1seal.org> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
1 parent bda93ee commit d05111b

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

net/bluetooth/smp.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1826,14 +1826,18 @@ static u8 smp_cmd_pairing_req(struct l2cap_conn *conn, struct sk_buff *skb)
18261826
if (sec_level > conn->hcon->pending_sec_level)
18271827
conn->hcon->pending_sec_level = sec_level;
18281828

1829-
/* If we need MITM check that it can be achieved */
1829+
/* If we need MITM check that it can be achieved. */
18301830
if (conn->hcon->pending_sec_level >= BT_SECURITY_HIGH) {
18311831
u8 method;
18321832

18331833
method = get_auth_method(smp, conn->hcon->io_capability,
18341834
req->io_capability);
18351835
if (method == JUST_WORKS || method == JUST_CFM)
18361836
return SMP_AUTH_REQUIREMENTS;
1837+
1838+
/* Force MITM bit if it isn't set by the initiator. */
1839+
auth |= SMP_AUTH_MITM;
1840+
rsp.auth_req |= SMP_AUTH_MITM;
18371841
}
18381842

18391843
key_size = min(req->max_key_size, rsp.max_key_size);

0 commit comments

Comments
 (0)