In the console window manager (terminal multiplexer) GNU screen, which provides a multi-window interface in the console, 5 vulnerabilities have been identified. The most dangerous issue (CVE-2025-23395) allows gaining root privileges on the system. A fix has been included in today's release of screen 5.0.1.
The CVE-2025-23395 vulnerability is only present in the screen 5.0.0 branch, which is provided in Fedora Linux, Arch Linux, NetBSD, OpenBSD, and Alpine. In Debian, Ubuntu, RHEL (EPEL 9), Gentoo, FreeBSD, SUSE/openSUSE, and OpenWrt, the screen 4.x branch continues to be distributed. Exploiting the vulnerability is possible in systems that install the screen executable with the setuid root flag, such as Arch Linux and NetBSD. In Fedora, the utility is installed with the setgid flag to obtain screen group privileges, allowing sockets to be placed in the system directory /run/screen, which limits the denial of service attack possibilities.
The vulnerability is caused by the fact that when run with root privileges, the logfile_reopen() function is executed before privilege drop, but processes data in the context of the directories of the current unprivileged user who started screen. Notably, the initial log opening is performed with a correct privilege drop, but upon reopening the log file, the privilege drop is not executed.
Through manipulation by enabling the logging mode of the session content, a user can achieve writing data to a file with root privileges, while the file itself may be saved in the user's home directory. The attack involves deleting the created log file and replacing it with a symbolic link pointing to any file in the system. If the file already exists, data with the content of the screen during the screen session will be added to it without changing the owner. If the file does not exist, it will be created with permissions 0644, with root as the owner and the group as that of the current user.
The attack algorithm that creates the file /etc/profile.d/exploit.sh with the command 'chown $USER /root':
- Creating a screen session with logging enabled: $ screen -Logfile $HOME/screen.log
- Pressing the Ctrl-a-H key combination to enable logging.
- Deleting the log file and replacing it with a symbolic link, which will lead to the creation of the file /etc/profile.d/exploit.sh: $ rm $HOME/screen.log; ln -s /etc/profile.d/exploit.sh $HOME/screen.log
- Powrót do sesji ekranu i wyświetlenie danych, które zostaną zapisane w pliku z logiem. $ echo -e "\nchown $USER /root;"
- Po podłączeniu prawdziwego użytkownika root do systemu uruchomi się skrypt /etc/profile.d/exploit.sh, który zmieni właściciela katalogu /root. $ ls -lhd /root drwxr-x— 5 user root 4.0K 30 Gru 2020 .
- Podobnie można stworzyć pliki konfiguracyjne sudo lub dodać komendy na końcu skryptów systemowych.
Mniej niebezpieczne luki w ekranie:
- CVE-2025-46802 — przechwycenie urządzenia TTY w wieloosobowych sesjach (użytkownik może uzyskać ustawienie dla urządzenia /dev/pts/1 praw crw-rw-rw-). Problem występuje w wersjach ekranu 4.x i 5.x.
- CVE-2025-46803 — domyślne ustawienie praw 0622 na urządzeniu PTY, zezwalających na zapis przez dowolnych użytkowników. Problem występuje tylko w wersji ekranu 5.0.
- CVE-2025-46804 — wyciek informacji o istnieniu plików i katalogów w zamkniętych katalogach (przy wskazywaniu katalogu dla soketów, używając zmiennej środowiskowej SCREENDIR, narzędzie zwraca różne komunikaty o błędach, które pozwalają zrozumieć istnienie plików i katalogów o danej nazwie). Problem występuje w wersjach ekranu 4.x i 5.x.
- CVE-2025-46805 — stan wyścigu podczas wysyłania sygnałów SIGCONT i SIGHUP, prowadzący do odmowy obsługi. Problem występuje w wersjach ekranu 4.x i 5.x.
- Niepoprawne użycie funkcji strncpy (zmiana strcpy na strncpy bez uwzględnienia różnicy w obsłudze zerowych symboli "\0"), prowadzące do awaryjnego zakończenia podczas wykonywania specjalnie przygotowanych komend. Problem występuje tylko w wersji ekranu 5.0.
Luki zostały ujawnione w trakcie audytu bazy kodu GNU screen, przeprowadzonego przez zespół odpowiedzialny za bezpieczeństwo dystrybucji SUSE Linux. Informacje o lukach zostały przesłane programistom ekranu 7 lutego, jednak w wyznaczonym czasie 90 dni nie byli w stanie przygotować poprawek dla wszystkich luk, w związku z czym pracownicy SUSE musieli samodzielnie przygotować niektóre poprawki. Według badaczy przeprowadzających audyt, obecni opiekunowie GNU screen nie orientują się wystarczająco dobrze w bazie kodu projektu i nie są w stanie w pełni zrozumieć zidentyfikowanych problemów bezpieczeństwa.
Źródło: opennet.ru
