Sårbarhed, der muliggør indføring af escape-sekvenser i andres terminaler

I værktøjet wall, der leveres i util-linux-pakken og er beregnet til at sende meddelelser til terminaler, er der opdaget en sårbarhed (CVE-2024-28085), som muliggør angreb på andre brugers terminaler gennem manipulation af escape-sekvenser. Problemet opstår, fordi wall-blokerer brugen af escape-sekvenser i inputstrømmen, men ikke udfører denne operation for argumenter i kommandolinjen, hvilket gør det muligt for en angriber at udføre escape-sekvenser på en anden brugers terminal.

For eksempel, ved at udføre ‘wall $(printf «\033[33mHI»)’ kan man vise teksten «HI» i gul farve. Ved hjælp af escape-sekvenser, der muliggør bevægelse af markøren, rydning og erstatning af indholdet på skærmen, kan man simulere visning af en prompt for at indtaste password fra sudo-værktøjet på en anden brugers terminal. Hvis brugeren ikke bemærker noget usædvanligt og indtaster sit password, vil passwordet blive synligt i indtastningshistorikken som en ikke-eksisterende kommando (reelt indtaster brugeren sit password i kommandolinjen i stedet for en kommando). «\033[3A» // flytter markøren op 3 linjer «\033[K» // sletter tidligere output «[sudo] password for a_user:» // viser falsk sudo-prompt «\033[?25l» // sætter baggrundsfarve for at skjule indtastning «\033[38;2;48;10;36m»

Når der gives en advarsel om, at den indtastede kommando ikke blev fundet, starter mange distributioner handleren /usr/lib/command-not-found, som forsøger at identificere den pakke, der indeholder den manglende kommando, og giver forslag til, hvordan den kan installeres. Problemet er, at når handleren command-not-found køres, bliver den ikke-eksisterende kommando sendt til den som et kommandolinjeargument, som kan ses, når man ser på processerne i systemet (for eksempel, når man forsøger at køre det ikke-installerede værktøj «xsnow», vil «/usr/lib/command-not-found — xsnow» være synligt i proceslisten). Følgelig kan en angriber overvåge kørende processer (for eksempel ved at analysere fremkomsten af «/proc/$pid/cmdline» for det forventede PID-nummer) og bestemme det password, som offeret indtager i kommandolinjen.

For a user to enter a password in response to a fake sudo prompt, a trick is proposed that involves monitoring the real execution of the sudo utility in the process list, waiting for its completion, and executing an attack via 'wall' immediately after. Through manipulations with escape sequences, an attacker can replace the message after the actual execution of sudo with a fake prompt for re-entering the password. The victim may think they made an error while entering and enter the password a second time, exposing the password in the arguments of the 'command-not-found' handler.

For a successful attack, the 'mesg' mode must be set to 'y', which is the default setting in Ubuntu, Debian, and CentOS/RHEL. The attack has been demonstrated in Ubuntu 22.04 in default configuration using gnome-terminal. In Debian, the attack is complicated because the default distribution does not include the 'command-not-found' handler, and in CentOS/RHEL, the attack will not work because the wall utility is installed without the setgid flag and does not have access to others' terminals. When using windows-terminal, the attack can be modified to change the clipboard contents.

The vulnerability has been present in the util-linux package since 2013, after version 2.24 added the ability to specify a message in the wall command line but forgot to apply cleaning of escape sequences. A fix for the vulnerability has been included in yesterday's release of util-linux 2.40. Notably, an attempt to fix the vulnerability in util-linux 2.39 led to the discovery of another similar vulnerability that allows the substitution of control characters through locale manipulation.

Kilde: opennet.ru

Køb pålidelig webhosting med DDoS-beskyttelse, VPS VDS-servere 🔥 Køb pålidelig webhosting med DDoS-beskyttelse, VPS VDS-servere | ProHoster