|
|
Message-ID: <CAHjgt=XZY9BAeRGqH-dBSnGrkCw4tGHS-sTr5D+2_b4-qb2Dhw@mail.gmail.com>
Date: Wed, 2 Dec 2026 16:26:37 +0200
From: liad levy <liadlevy1999@...il.com>
To: oss-security@...ts.openwall.com
Subject: Pre-authentication environment injection in netkit telnetd - CVE-2026-141380
Hello,
I am reporting a pre-authentication remote code execution via
environment-injection vulnerability affects the netkit telnetd
implementation used by Debian’s telnetd-ssl package. A remote
unauthenticated client can inject arbitrary environment variables during
Telnet option negotiation. Depending on the daemon’s privilege
configuration and the presence of an attacker writable file on the target.
The issue is tracked as CVE-2026-141380.
*Summary*
Debian's patch series builds netkit telnetd 0.17 with -DACCEPT_USERVAR.
Patch 124-support_uservar.diff modifies the NEW-ENVIRON suboption handler
in suboption() (telnetd/state.c) so that any variable the client marks as
USERVAR is accepted and setenv()'d:
if (envvarok(varp) || is_uservar) setenv(...);
The client fully controls the is_uservar flag, so the envvarok() whitelist
is bypassed. A remote, unauthenticated attacker can set arbitrary
environment variables in the daemon process during the initial option
negotiation, before startslave() forks the login child. The forked child
inherits the poisoned environment, and the setuid-root telnetlogin wrapper
forwards it verbatim to /bin/login; it validates only the values of TERM
and REMOTEHOST.
*Impact*
1. Daemon runs as root (legacy inetd entries, units without User=,
Gentoo's shipped xinetd config): no privilege transition occurs in the
exec chain, AT_SECURE is never set, and glibc honors LD_PRELOAD. An
attacker-supplied shared object's constructor then runs as root inside
/bin/login before any authentication. This is pre-auth network root RCE
(CVSS 3.1: 9.8). Exploitation requires one attacker-writable file on
the target (any write primitive); without it, the loader merely prints
"ERROR: ld.so: object ... cannot be preloaded ... ignored" and
execution continues normally.
2. Daemon runs as a non-root user (Debian's shipped inetd entry): the
telnetlogin exec sets AT_SECURE and glibc strips LD_*. However,
CREDENTIALS_DIRECTORY is not stripped, and /bin/login from util-linux
>= 2.40 honors it: if $CREDENTIALS_DIRECTORY/login.noauth exists and
contains "yes", login skips PAM authentication entirely.
telnetlogin performs setuid(0), and telnetd's start_login() passes
getenv("USER") as a /bin/login argument, and USER is just another
injectable USERVAR. Injecting "USER=root" plus
"CREDENTIALS_DIRECTORY=<writable dir>" yields an unauthenticated root
shell, with no password prompt ever shown. This additionally requires
the login.noauth file (three bytes of plain text rather than an ELF).
A related local-only variant of this login mechanism was already
addressed as CVE-2026-28372 (in GNU inetutils telnetd); this finding
reaches the same mechanism remotely and pre-auth through the netkit
telnetd injection.
Refuted, recorded so it is not re-reported: because inetd forks a fresh
in.telnetd per connection, an injected environment exists only inside the
attacker's own session and never reaches a later login. Payloads that
assume otherwise (HOME=/.bash_profile, PROMPT_COMMAND) therefore run only
after the attacker authenticates as root on their own connection, i.e.
with credentials they must already hold.
*How the one-file prerequisite is satisfied in practice*
- Any separate file-write primitive: arbitrary file write, path traversal
in an upload handler, zip-slip during archive extraction, an application
writing user-controlled temp files to /tmp or /dev/shm.
- Local privilege escalation from an existing foothold: any low-privilege
RCE (webshell, compromised CI runner) plus a running telnetd, even on
localhost only.
- Persistence on an already-compromised server: telnetd runs from
inetd/xinetd per connection, so the .so on disk re-executes as root on
every future connection to port 23.
- The login.noauth variant is trivially cheap: a three-byte plain-text
file containing "yes".
In all cases the attacker is unauthenticated and remote; the single
prerequisite in every path is one attacker-writable file on the target.
*Affected*
- Debian telnetd / telnetd-ssl (source "telnet", 0.17-42 and earlier;
the ACCEPT_USERVAR build dates back to 2015): vulnerable.
- telnetd-ssl verified vulnerable end-to-end on Debian 13 trixie
(0.17.41+really0.17-6, stock util-linux login 2.41.5, shipped non-root
inetd entry): pre-auth root shell. Same verified on Ubuntu 25.04/25.10
and Kali rolling. Ubuntu and Kali ship the same source package.
- Debian 11 bullseye (util-linux 2.36) is affected by the injection
itself; the login.noauth auth-bypass variant requires util-linux >= 2.40.
- Gentoo net-misc/netkit-telnetd (applies Debian's patch series; its
shipped xinetd config runs the daemon as root): vulnerable, LD_PRELOAD
path.
*Suggested fixes*
- Revert the "|| is_uservar" relaxation in suboption(), or
- drop ACCEPT_USERVAR entirely, or
- have telnetlogin enforce a whitelist on the environment it forwards.
Best regards,
Liad
Powered by blists - more mailing lists
Please check out the Open Source Software Security Wiki, which is counterpart to this mailing list.
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.