GBHackers

Critical Telnetd Vulnerability Allows Hackers to Execute Remote Code With Root Privileges


A significant pre-authentication vulnerability in the netkit telnetd implementation allows remote, unauthenticated attackers to inject arbitrary environment variables, potentially leading to root-level code execution on affected Linux systems.

This issue, tracked as CVE-2026-141380, impacts the telnetd and telnetd-ssl packages provided by Debian and various downstream distributions, including Ubuntu, Kali, and Gentoo. In its most severe configuration, this vulnerability has been assigned a CVSS 3.1 score of 9.8.

Telnetd Vulnerability

The bug sits in Debian’s patch series, which builds netkit telnetd 0.17 with the ACCEPT_USERVAR flag. Patch 124-support_uservar.diff changes the NEW-ENVIRON suboption handler in telnetd/state.c so that any variable the client marks as USERVAR is passed straight to setenv().

The client controls that flag, so the envvarok() whitelist is fully bypassed. This follows the same pattern as the earlier GNU InetUtils authentication bypass, where an unsanitized USER value gave attackers root access.

The injection happens during the initial Telnet option negotiation, before startslave() forks the login child. The child process inherits the poisoned environment. The setuid-root telnetlogin wrapper then forwards it to /bin/login and checks only the values of TERM and REMOTEHOST.

When the daemon runs as root, as it does with legacy inetd entries and Gentoo’s shipped xinetd config, AT_SECURE is never set and glibc honors LD_PRELOAD. A shared object supplied by the attacker then runs its constructor as root inside /bin/login before any authentication takes place.

Debian’s default non-root inetd entry is also exposed. In this setup glibc strips LD_* variables, but CREDENTIALS_DIRECTORY is left in place. The login tool in util-linux 2.40 and later skips PAM entirely if a login.noauth file in that directory contains “yes”.

By injecting USER=root together with a writable CREDENTIALS_DIRECTORY, an attacker gets a root shell with no password prompt, according to the researcher’s oss-security disclosure.

Each attack path needs one file on the target that the attacker can write to. That file can come from a path traversal bug, zip-slip during archive extraction, an existing webshell, or a compromised CI runner. On servers that are already breached, the planted .so file runs again as root on every new connection to port 23, which gives attackers lasting persistence.

Researcher Liad Levy confirmed full exploitation on Debian 13 trixie, Ubuntu 25.04 and 25.10, and Kali rolling. Debian source package “telnet” 0.17-42 and earlier is vulnerable, and the ACCEPT_USERVAR build dates back to 2015. Debian 11 bullseye is affected by the injection itself, but the login.noauth variant needs util-linux 2.40 or newer.

The suggested fixes are to revert the “|| is_uservar” relaxation in suboption(), drop ACCEPT_USERVAR entirely, or make telnetlogin enforce a whitelist on the variables it forwards.

Telnet has faced repeated scrutiny this year, including a critical telnetd buffer overflow tracked as CVE-2026-32746. Administrators should turn off telnetd wherever possible, move remote access to SSH, and block port 23 at the network edge until patched packages are available.

Join ANY.RUN and Torq to learn how TI Feeds can help your SOC detect up to 30% of malicious IOCs earlier & accelerate investigations -> Attend Free Live Webinar



Source link