1
1
KNOB


2
BIAS攻击
-
LSC过程中master发起连接请求,slave返回自己的LTK认证响应,但master可以不进行校验,也就是说在LSC中对LTK的校验只是单向的,即master校验slave的LTK即可。因此在LSC中攻击者可以轻易伪造成master进行连接。
-
在LSC过程中,攻击者若想伪造成slave,则可以在收到master的连接请求后发起Role Switch角色互换请求,将自己变成master,从而在1的基础上伪造成Slave。
-
在Secure Connection的情况下,攻击者可以通过返回Secure Connection not Support来发起降级攻击,从而使用LSC进行后续连接,即回退到1/2的场景中进行对端伪造。
-
在Secure Connection的情况下,另一种攻击方法是反射攻击。即在收到Secure Connection的请求后发起Role Switch操作,并且伪造对端的认证请求,由于两端的LTK相同,因此对端可以返回合法的认证响应;之后再发起一次Role Switch,将合法的认证响应转发给对端,从而完成安全链接。
3
Blacktooth攻击


2
1
BleedingTooth漏洞
static void hci_le_ext_adv_report_evt(struct hci_dev *hdev, struct sk_buff *skb)
{
u8 num_reports = skb->data[0];
void *ptr = &skb->data[1];
hci_dev_lock(hdev);
while (num_reports--) {
struct hci_ev_le_ext_adv_report *ev = ptr;
u8 legacy_evt_type;
u16 evt_type;
evt_type = __le16_to_cpu(ev->evt_type);
legacy_evt_type = ext_evt_type_to_legacy(hdev, evt_type);
if (legacy_evt_type != LE_ADV_INVALID) {
process_adv_report(hdev, legacy_evt_type, &ev->bdaddr,ev->bdaddr_type,
NULL, 0, ev->rssi,ev->data, ev->length);
}
ptr += sizeof(*ev) + ev->length;
}
hci_dev_unlock(hdev);
}
// https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/net/bluetooth/hci_event.c
static void store_pending_adv_report(struct hci_dev *hdev, bdaddr_t *bdaddr,
u8 bdaddr_type, s8 rssi, u32 flags,u8 *data, u8 len)
{
struct discovery_state *d = &hdev->discovery;
...
memcpy(d->last_adv_data, data, len);d->last_adv_data_len = len;
}
// pahole -E -C hci_dev --hex bluetooth.ko
struct hci_dev {
...
struct discovery_state {
...
/* typedef u8 -> __u8 */ unsigned char last_adv_data[31];
/* 0xab0 0x1f */
...
} discovery; /* 0xa68 0x88 */
...
struct list_head {
struct list_head * next;
/* 0xb18 0x8 */struct list_head * prev;
/* 0xb20 0x8 */
} mgmt_pending; /* 0xb18 0x10 */
...
/* size: 4264, cachelines: 67, members: 192 */
/* sum members: 4216, holes: 17, sum holes: 48 */
/* paddings: 10, sum paddings: 43 */
/* forced alignments: 1 */
/* last cacheline: 40 bytes */
} __attribute__((__aligned__(8)));
// https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/net/bluetooth/a2mp.c
static int a2mp_getinfo_req(struct amp_mgr *mgr, struct sk_buff *skb,struct a2mp_cmd *hdr)
{
struct a2mp_info_req *req = (void *) skb->data;
...
hdev = hci_dev_get(req->id);
if (!hdev || hdev->dev_type != HCI_AMP) {
struct a2mp_info_rsp rsp;
rsp.id = req->id;
rsp.status = A2MP_STATUS_INVALID_CTRL_ID;
a2mp_send(mgr, A2MP_GETINFO_RSP, hdr->ident, sizeof(rsp),&rsp);
goto done;
}
...
}
// https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/net/bluetooth/l2cap_core.c
static int l2cap_data_rcv(struct l2cap_chan *chan, struct sk_buff *skb)
{
...
if ((chan->mode == L2CAP_MODE_ERTM ||
chan->mode == L2CAP_MODE_STREAMING) && sk_filter(chan->data, skb))
goto drop;
...
}
// https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/net/bluetooth/a2mp.c
static struct l2cap_chan *a2mp_chan_open(struct l2cap_conn *conn, bool locked)
{
struct l2cap_chan *chan;
int err;
chan = l2cap_chan_create();
if (!chan)
return NULL;
...
chan->mode = L2CAP_MODE_ERTM;
...
return chan;
}
...
static struct amp_mgr *amp_mgr_create(struct l2cap_conn *conn, bool locked)
{
struct amp_mgr *mgr;
struct l2cap_chan *chan;
mgr = kzalloc(sizeof(*mgr), GFP_KERNEL);
if (!mgr)
return NULL;
...
chan = a2mp_chan_open(conn, locked);
if (!chan) {
kfree(mgr);
return NULL;
}
mgr->a2mp_chan = chan;
chan->data = mgr;
...
return mgr;
}
2
BlueFrag

static void reassemble_and_dispatch(UNUSED_ATTR BT_HDR *packet) {
...
packet->offset = HCI_ACL_PREAMBLE_SIZE;
uint16_t projected_offset = partial_packet->offset + (packet->len - HCI_ACL_PREAMBLE_SIZE);
if (projected_offset > partial_packet->len) { // len stores the expected length
LOG_WARN(LOG_TAG, "%s got packet which would exceed expected length of %d.""Truncating.", __func__, partial_packet->len);
packet->len = partial_packet->len - partial_packet->offset;
projected_offset = partial_packet->len;
}
memcpy(partial_packet->data + partial_packet->offset, packet->data + packet->offset, packet->len - packet->offset);
...
}
3
BlueBorne漏洞
-
CVE-2017-0781:Android中l2cap协议中的内存破坏漏洞,可能导致RCE
-
CVE-2017-0782:Android中bnep协议中的内存破坏漏洞,可能导致RCE
-
CVE-2017-0785:Android中SDP协议continuation请求偏移校验不当导致的信息泄露
-
CVE-2017-0783:Android中PANU交互不当导致的中间人攻击
-
CVE-2017-8628:Windows中蓝牙驱动实现不当导致的中间人攻击
-
CVE-2017-1000250:Linux BlueZ中SDP实现不当导致的信息泄露,与前面Android中的SDP漏洞原理类似
-
CVE-2017-1000251:Linux BlueZ中处理L2CAP配置响应不当导致的栈溢出,可能导致RCE
-
CVE-2017-14315:iOS中LEAP(Low Energy Audio Protocol)协议的堆溢出,可能导致RCE
3


总结
-
https://knobattack.com/ -
https://github.com/francozappa/knob -
https://francozappa.github.io/publication/knob/slides.pdf -
《Blacktooth: Breaking through the Defense of Bluetooth in Silence》, 2022, http://staff.ustc.edu.cn/~kpxue/paper/CCS2022-MingruiAi.pdf -
BleedingTooth, https://xz.aliyun.com/t/9465 -
https://www.bluetooth.com/blog/exploring-bluetooth5-whats-new-in-advertising/ -
BlueFrag, https://paper.seebug.org/1121/ -
https://www.armis.com/research/blueborne/ -
https://arxiv.org/abs/2208.00110 -
https://www.usenix.org/conference/usenixsecurity22/presentation/garbelini -
https://www.armis.com/research/blueborne/ -
https://www.usenix.org/conference/usenixsecurity20/presentation/ruge



更多阅读








原文始发于微信公众号(云起无垠):技术分享 | 蓝牙协议安全(下)