🇰🇷 한글 설명
Linux 커널의 Bluetooth RFCOMM 계층에서 HCI 명령 응답 타이밍 문제로 인해 이미 해제된 메모리에 접근하는 null-pointer-deref 취약점입니다. RFCOMM/L2CAP 해제 후 지연된 HCI 응답이 도착하면 rfcomm_check_security 함수에서 해제된 conn 구조체의 conn->hcon에 접근하여 커널 패닉을 유발합니다.
💡 쉬운 설명
블루투스 통신 중 특정 타이밍에 이미 정리된 데이터에 접근하려고 해서 시스템이 충돌하는 버그입니다. 악의적인 블루투스 장치가 응답 시간을 조작하면 이 문제를 유발할 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
Bluetooth: rfcomm: Fix null-ptr-deref in rfcomm_check_security
During our fuzz testing of the connection and disconnection process at the
RFCOMM layer, we discovered this bug. By comparing the packets from a
normal connection and disconnection process with the testcase that
triggered a KASAN report. We analyzed the cause of this bug as follows:
1. In the packets captured during a normal connection, the host sends a
`Read Encryption Key Size` type of `HCI_CMD` packet
(Command Opcode: 0x1408) to the controller to inquire the length of
encryption key.After receiving this packet, the controller immediately
replies with a Command Completepacket (Event Code: 0x0e) to return the
Encryption Key Size.
2. In our fuzz test case, the timing of the controller's response to this
packet was delayed to an unexpected point: after the RFCOMM and L2CAP
layers had disconnected but before the HCI layer had disconnected.
3. After receiving the Encryption Key Size Response at the time described
in point 2, the host still called the rfcomm_check_security function.
However, by this time `struct l2cap_conn *conn = l2cap_pi(sk)->chan->conn;`
had already been released, and when the function executed
`return hci_conn_security(conn->hcon, d->sec_level, auth_type, d->out);`,
specifically when accessing `conn->hcon`, a null-ptr-deref error occurred.
To fix this bug, check if `sk->sk_state` is BT_CLOSED before calling
rfcomm_recv_frame in rfcomm_process_rx.
📍 영향받는 시스템
Bluetooth RFCOMM 포함한 모든 Linux 커널 (패치 적용 전)
⚔️ 공격 벡터
로컬 블루투스 연결에서 HCI 명령 응답을 특정 타이밍에 전송하여 경합 조건 유발
🛡️ 대응 방법
Linux 커널을 최신 버전으로 업데이트하거나 rfcomm_process_rx에서 sk->sk_state BT_CLOSED 검사 패치 적용
🔧 검증 코드
커널 버전 확인 후 RFCOMM 소스의 BT_CLOSED 검사 존재 여부로 패치 적용 여부 판단
uname -r && grep -r 'BT_CLOSED' /usr/src/linux*/net/bluetooth/rfcomm/ 2>/dev/null | grep -q 'rfcomm_process_rx' && echo 'Patched' || echo 'Vulnerable'