Vulnerability in the Linux kernel affecting the CAN BCM network protocol

A Linux kernel vulnerability (CVE-2021-3609) has been identified, allowing a local user to escalate their privileges within the system. The issue is caused by a race condition in the CAN BCM protocol implementation and is present in Linux kernel releases from 2.6.25 to 5.13-rc6. The problem remains unpatched in distributions (RHEL, Fedora, Debian, Ubuntu, SUSE, Arch).

The researcher who discovered the vulnerability was able to prepare an exploit to obtain root privileges on systems with Linux kernels 5.4 and newer, demonstrating the possibility of successfully carrying out an attack on Ubuntu 20.04.02 LTS. There is also a chance of adapting the exploit to work with older kernels (in kernel 5.4, the CAN BCM code (net/can/bcm.c) was transitioned from hrtimer_tasklet to HRTIMER_MODE_SOFT).

The CAN BCM protocol allows registering a custom message handler for incoming messages through the CAN (controller area network) bus and attaching it to a specific network socket. When an incoming message arrives, the function bcm_rx_handler() is invoked. An attacker can exploit the race condition to close the network socket concurrently with the execution of bcm_rx_handler(). When the socket is closed, the bcm_release() function is called, which frees the memory allocated for the bcm_op and bcm_sock structures that are still being used by the ongoing bcm_rx_handler(). This situation leads to access to a freed memory block (use-after-free).

The attack involves opening two CAN BCM sockets and binding them to the vcan interface. The first socket executes the sendmsg() call with the RX_SETUP flag to set up the incoming CAN message handler, while the second socket makes a sendmsg() call to send a message to the first socket. Once the message arrives, bcm_rx_handler() is triggered, and the attacker chooses the right moment to close the first socket, causing bcm_release() to run and free the bcm_op and bcm_sock structures, even though the execution of bcm_rx_handler() is still ongoing.

A támadó a bcm_sock tartalmának manipulálásával felül tudja írni a sk->sk_data_ready(sk) függvényre mutató mutatót, átirányítja a végrehajtást, és visszahívás-orientált programozási (ROP – Return-Oriented Programming) technikák segítségével újraíró paramétert hozhat létre modprobe_path és végrehajthatja saját kódját root jogosultságokkal. ROP technika alkalmazása során a támadó nem próbálja meg elhelyezni a saját kódját a memóriában, hanem meglévő gépi utasítások darabjaival dolgozik, amelyek a könyvtárakban találhatók, és visszairányító utasítással zárulnak (ez általában a könyvtári funkciók végén található). Az exploit működése a hasonló blokkok („gadgetek”) hívási láncának felépítésére korlátozódik a kívánt funkcionalitás elérése érdekében.

Vulnerability in the Linux kernel affecting the CAN BCM network protocol

A támadáshoz CAN socketek létrehozásához való hozzáférés és a vcan hálózati interfész beállítása szükséges. A támadáshoz szükséges jogosultságok a nem privilegizált felhasználók számára is megszerezhetők olyan konténerek létrehozásával, ahol a felhasználói azonosítók (user namespaces) támogatása engedélyezve van. Például az Ubuntu és Fedora alapértelmezés szerint engedélyezi a felhasználói neveket, de a Debian és RHEL-ben nem aktiválták.

Forrás: opennet.ru

Megbízható hosting vásárlása weboldalak számára, DDoS védelemmel, VPS VDS szerverek. 🔥 Megbízható webtárhely vásárlása DDoS védelemmel, VPS VDS szerverek | ProHoster