In Netfilter, the Linux kernel subsystem used for filtering and modifying network packets, a vulnerability (CVE-2021-22555) has been discovered that allows a local user to gain root privileges on the system, even while residing in an isolated container. A working prototype of an exploit that bypasses the KASLR, SMAP, and SMEP safeguards has been prepared for testing. The researcher who identified the vulnerability received a reward of $20,000 from Google for discovering the method to bypass container isolation in the kCTF cluster.
The issue has been present since kernel 2.6.19, released 15 years ago, and is caused by a bug in the IPT_SO_SET_REPLACE and IP6T_SO_SET_REPLACE handlers, leading to a buffer overflow when sending specially crafted parameters through a setsockopt call in compat mode. Normally, the compat_setsockopt() call can only be executed by the root user, but the permissions necessary to carry out the attack can also be obtained by an unprivileged user in systems with user namespace support enabled.
L'utente può creare un contenitore con un utente root separato e sfruttare una vulnerabilità da esso. Ad esempio, i «namespace utente» sono abilitati per impostazione predefinita in Ubuntu e Fedora, ma non attivati in Debian e RHEL. La patch per correggere la vulnerabilità è stata accettata nel kernel Linux il 13 aprile. Gli aggiornamenti dei pacchetti sono già stati formati dai progetti Debian, Arch Linux e Fedora. In Ubuntu, RHEL e SUSE, gli aggiornamenti sono in fase di preparazione.
Il problema si verifica nella funzione xt_compat_target_from_user() a causa di un calcolo errato della dimensione della memoria durante il salvataggio delle strutture del kernel dopo la conversione da una rappresentazione a 32 bit a una a 64 bit. L'errore consente di scrivere quattro byte zero in qualsiasi posizione al di fuori del buffer allocato, limitata dall'offset 0x4C. Questa possibilità è stata sufficiente per creare un exploit che consente di ottenere diritti di root: attraverso la pulizia del puntatore m_list->next nella struttura msg_msg, si creavano le condizioni per accedere ai dati dopo il rilascio della memoria (use-after-free), che veniva poi utilizzata per ottenere informazioni sugli indirizzi e modificare altre strutture mediante manipolazione della chiamata di sistema msgsnd().
Fonte: opennet.ru
