Sebezhetőség, amely lehetővé teszi escape-szekvenciák beillesztését mások termináljába

A wall utility, supplied in the util-linux package and intended for sending messages to terminals, has a vulnerability (CVE-2024-28085) that allows attacks on other users' terminals through manipulation of escape sequences. The issue arises because the wall utility blocks the use of escape sequences in the input stream but does not perform this operation for command-line arguments, allowing an attacker to execute escape sequences in another user's terminal.

For example, executing ‘wall $(printf ‘\033[33mHI’) can display the message ‘HI’ in yellow. Using escape sequences that allow cursor movement, clearing, and replacing content on the screen, one can simulate a prompt for the password input from the sudo utility in another user's terminal. If the user does not notice the trick and enters their password, the password will be exposed in the input history as a nonexistent command (essentially, the user will enter their password instead of a command in the command line). ‘\033[3A’ // move the cursor up by 3 lines; ‘\033[K’ // clear previous output; ‘[sudo] password for a_user:’ // display a fake sudo prompt; ‘\033[?25l’ // set background color to hide input; ‘\033[38;2;48;10;36m’.

During the display of a warning that the entered command was not found, on many distributions, the handler /usr/lib/command-not-found is invoked, which attempts to determine the package containing the missing command and provide a hint for its potential installation. The problem is that, when invoking the command-not-found handler, the nonexistent command is passed to it as a command-line parameter, which is visible when viewing processes in the system (for instance, when attempting to start the uninstalled utility ‘xsnow’, the process list will show ‘/usr/lib/command-not-found -- xsnow’). Accordingly, an attacker can monitor the running processes (for example, analyzing the appearance of ‘/proc/$pid/cmdline’ for the anticipated PID number) and determine the password entered by the victim in the command line.

A felhasználó jelszavának egy hamis sudo prompt-ra adott válaszként való megadásához egy trükköt javasoltak, amelynek lényege a sudo segédeszköz valódi indításának nyomon követése a folyamatok listájában, annak befejezésének megvárása és a támadás végrehajtása a „wall” parancson keresztül közvetlenül ezután. A támadó az escape-szekvenciák manipulálásával kicserélheti a valódi sudo végrehajtás utáni üzenetet egy hamis jelszó újrabemutatási prompt-ra. Az áldozat azt hiheti, hogy hibázott a jelszó beírásakor, és másodszor is megadja a jelszavát, ezzel felfedve azt a „command-not-found” kezelő argumentumaiban.

A támadás sikeres végrehajtásához a „mesg” módot „y” értékre kell állítani, amely alapértelmezés szerint van beállítva az Ubuntu, Debian és CentOS/RHEL rendszerekben. A támadás lehetőségét az Ubuntu 22.04 alapértelmezett konfigurációjában demonstrálták a gnome-terminal használatával. A Debian rendszerben a támadás nehezített, mivel a disztribúció alapértelmezésként nem tartalmazza a „command-not-found” kezelőt, míg a CentOS/RHEL esetében a támadás nem fog működni, mivel a wall segédeszköz setgid zászló nélkül van telepítve, és nem fér hozzá más felhasználók termináljaihoz. A windows-terminal használatával a támadás módosítható a vágólap tartalmának megváltoztatására.

A sebezhetőség a util-linux csomagban 2013 óta jelen van, miután a 2.24-es kiadásba bevezették a wall parancs parancssori üzenetének megadásának lehetőségét, de elfelejtették alkalmazni az escape-szekvenciák tisztítását. A sebezhetőség javítását a tegnapi util-linux 2.40-es kiadás tartalmazza. Érdekes, hogy a sebezhetőség 2.39-es kiadásban történő javításának kísérlete során egy újabb hasonló sebezhetőségre derült fény, amely lehetővé teszi a vezérlő karakterek behelyettesítését lokalitások manipulálásával.

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