No fluff. Just the config that works.
Executive Summary
Netkit telnetd CVE-2026-141380 is a pre-authentication environment injection bug that can hand a remote, unauthenticated attacker a root shell with no password prompt. Researcher Liad Levy disclosed it on the oss-security mailing list on December 2, 2026, and it carries a CVSS 3.1 score of 9.8. The flaw is not new code: it comes from a 2015 Debian patch that let Telnet clients mark environment variables as USERVAR and skip the daemon’s whitelist.
Objective: find every host running a vulnerable netkit telnetd build, remove it or wall it off, and put network and host controls in place so the chain breaks even before a vendor patch lands.
Target audience: Linux admins, security engineers and FortiGate operators who own Debian, Ubuntu, Kali or Gentoo systems, including the forgotten lab boxes and appliances that still answer on TCP 23.
What Netkit telnetd CVE-2026-141380 Actually Does
Telnet lets the client send environment variables through the NEW-ENVIRON option during negotiation, before anyone logs in. Stock netkit telnetd only accepts names that pass envvarok(), a whitelist that blocks dangerous variables. Debian builds netkit telnetd 0.17 with -DACCEPT_USERVAR, and patch 124-support_uservar.diff changed the check in suboption() (telnetd/state.c) to this:
if (envvarok(varp) || is_uservar) setenv(...);
The client decides whether a variable is flagged USERVAR, so the client decides whether the whitelist applies at all. The daemon writes the attacker’s variables into its own environment, forks, and the setuid-root telnetlogin wrapper hands that environment to /bin/login. The wrapper only sanity-checks TERM and REMOTEHOST.
Figure 1: The injection chain and the control that breaks each step

Two ways to root
| Path | When it applies | What the attacker abuses | Extra requirement |
|---|---|---|---|
| A: root daemon | inetd or xinetd launches in.telnetd as root (legacy entries, units with no User=, Gentoo’s default xinetd config) | No privilege change, so AT_SECURE is not set and glibc honors loader variables such as LD_PRELOAD | One file on disk that the attacker controls |
| B: Debian default | Debian’s shipped inetd entry runs the daemon as a non-root user | CREDENTIALS_DIRECTORY survives the setuid exec, and util-linux 2.40 or later login can be told to skip PAM authentication |
util-linux 2.40+ and an attacker-writable location |
Each connection gets its own forked in.telnetd, so the injected variables live only inside the attacker’s session. That limits blast radius to the host, not to other users’ logins, but it does not make the bug any less critical on an exposed box.
Who is affected
| Platform | Package to look for | Status |
|---|---|---|
| Debian 13 trixie | telnetd-ssl (source netkit-telnet-ssl), verified build 0.17.41+really0.17-6 | Vulnerable, full root via Path B |
| Debian 12 bookworm | telnetd-ssl 0.17.41+really0.17-3 | Listed vulnerable by the Debian tracker |
| Debian 11 bullseye | netkit telnetd builds with util-linux 2.36 | Injection works, Path B does not (util-linux too old); Path A still applies if run as root |
| Ubuntu 25.04 and 25.10 | Same netkit source package | Verified by the researcher |
| Kali rolling | Same netkit source package | Verified by the researcher |
| Gentoo | net-misc/netkit-telnetd | Vulnerable via Path A, xinetd runs it as root |
| Amazon Linux 2, 2023 | Not shipped | Reported not affected |
Prerequisites and Architecture
Assumed knowledge
- Comfortable with a Linux shell, sudo, dpkg/apt and systemd.
- Know how inetd or xinetd launches on-demand services.
- FortiGate CLI basics: firewall policies, address objects, IPS sensors.
Lab components
| Component | Role | Address |
|---|---|---|
| Attacker / untrusted host | Simulates an Internet or user-VLAN client | 198.18.50.10 |
| FortiGate (wan1, port2, port3) | Segmentation, deny policy, IPS | wan1 198.18.0.1, port2 10.0.10.1/24, port3 10.0.20.1/24 |
| Linux server (Debian 13) | Target running telnetd-ssl | 10.0.10.20 |
| Server subnet | Address object LINUX-SERVERS | 10.0.10.0/24 |
| Management hosts | Address object MGMT-HOSTS, only source allowed to reach TCP 23 if Telnet must stay | 10.0.99.0/24 |
| User VLAN | Regular clients behind port3 | 10.0.20.0/24 |
Step-by-Step Implementation
Step 1: Find every exposed host
Goal: know where TCP 23 answers before you touch anything.
Action: sweep your internal ranges from a management host, then confirm per host.
# Fleet sweep from a management host (10.0.99.0/24)
sudo nmap -p 23 --open -sV 10.0.0.0/16 -oG telnet-hosts.gnmap
grep '23/open' telnet-hosts.gnmap
Verification: every line in the output is a host that needs Step 2. Expect version strings like Linux telnetd. Anything you did not know about is the real finding.
Step 2: Confirm the package, the user and util-linux
Goal: decide which path applies on each host.
Action: run these on each hit from Step 1.
# Which telnetd packages are installed, and from which source?
dpkg-query -W -f='${Package} ${Version} ${source:Package}\n' \
'telnetd*' 'inetutils-telnetd' 2>/dev/null
# What is listening on 23, and which binary is it?
sudo ss -ltnp 'sport = :23'
# How is it launched, and as which user? (field 5 in inetd.conf)
grep -E '^[^#]*telnet' /etc/inetd.conf 2>/dev/null
grep -E 'disable|user|server' /etc/xinetd.d/telnet* 2>/dev/null
# util-linux version that owns /bin/login (2.40+ enables Path B)
dpkg -S "$(readlink -f /bin/login)"
dpkg-query -W -f='${Package} ${Version}\n' util-linux login 2>/dev/null
Verification: a typical Debian inetd entry looks like the line below. The fifth field is the user. telnetd means Path B is your concern; root means Path A is live too.
telnet stream tcp nowait telnetd /usr/sbin/tcpd /usr/sbin/in.telnetd
Step 3: Remove it (the actual fix)
Goal: take the vulnerable daemon off the box and move admins to SSH.
Action: purge the packages, then make sure the super-server forgot about it.
# Make sure SSH works first, from a second session
sudo systemctl enable --now ssh
# Remove netkit telnetd (and inetutils-telnetd while you are here)
sudo apt purge -y telnetd-ssl telnetd inetutils-telnetd
# Confirm nothing still references telnet in inetd
grep -E '^[^#]*telnet' /etc/inetd.conf || echo "no telnet entry"
# Restart whichever super-server is installed
systemctl list-unit-files | grep -Ei 'inetd'
sudo systemctl restart inetd 2>/dev/null || sudo systemctl restart inetutils-inetd
# Nothing should be listening now
sudo ss -ltn 'sport = :23'
On Gentoo, remove net-misc/netkit-telnetd with emerge --depclean after unmerging it, and delete or disable its xinetd file. Because Gentoo’s default config runs the daemon as root, removal is the only honest mitigation there.
Verification: ss prints only its header line, and apt policy telnetd-ssl shows it as not installed.
Step 4: If Telnet must stay, restrict it on the host
Goal: buy time on the box you cannot touch yet (a vendor appliance on a support contract, a lab console server).
Action: confirm the daemon is not running as root, then allow only management hosts with TCP wrappers and nftables, and close the side doors an attacker would use to drop a file.
# TCP wrappers (Debian's inetd entry runs through /usr/sbin/tcpd)
echo 'in.telnetd: 10.0.99.0/255.255.255.0' | sudo tee -a /etc/hosts.allow
echo 'in.telnetd: ALL' | sudo tee -a /etc/hosts.deny
# nftables: drop TCP 23 from everything except management (IPv4 and IPv6)
sudo nft add table inet telnetguard
sudo nft add chain inet telnetguard input \
'{ type filter hook input priority -10; policy accept; }'
sudo nft add rule inet telnetguard input \
ip saddr != 10.0.99.0/24 tcp dport 23 counter drop
sudo nft add rule inet telnetguard input \
meta nfproto ipv6 tcp dport 23 counter drop
# Side doors: world-writable directories without the sticky bit
sudo find / -xdev -type d -perm -0002 ! -perm -1000 2>/dev/null
# Services that may accept uploads without a login (FTP, TFTP, SMB)
sudo ss -ltnup | grep -E ':(21|69|139|445)\b'
Both exploitation paths need the attacker to get a file onto the box. Anonymous FTP upload, writable TFTP roots, guest SMB shares and web upload folders are exactly how that happens. Close them.
Verification: sudo nft list table inet telnetguard shows both rules, and the counters climb when you test from an untrusted host.
Step 5: Block TCP 23 at the FortiGate
Goal: stop the attack before the packet reaches the server, for every host, including the ones Step 1 missed.
Action: create the address objects and a logged deny policy, then move it above any allow rule.
config firewall address
edit "LINUX-SERVERS"
set subnet 10.0.10.0 255.255.255.0
next
edit "MGMT-HOSTS"
set subnet 10.0.99.0 255.255.255.0
next
end
config firewall policy
edit 0
set name "deny-telnet-to-servers"
set srcintf "wan1" "port3"
set dstintf "port2"
set srcaddr "all"
set dstaddr "LINUX-SERVERS"
set service "TELNET"
set action deny
set schedule "always"
set logtraffic all
next
end
show firewall policy | grep -f deny-telnet-to-servers
config firewall policy
move <deny-policy-id> before <first-allow-policy-id>
end
If you also manage the edge, confirm no VIP or port forward publishes TCP 23 to the Internet: show firewall vip | grep -f 'extport 23'.
GUI verification: Policy and Objects, Firewall Policy. The deny-telnet-to-servers rule sits above the server allow rules, and the hit counter increases when you test from 198.18.50.10.
Step 6: Add a custom IPS signature for the Telnet you kept
Goal: catch the injection itself on any Telnet you still allow from MGMT-HOSTS. Deny policies do not inspect, so this goes on the allow policy.
Action: create two custom signatures that look for a NEW-ENVIRON subnegotiation (IAC SB NEW-ENVIRON, bytes FF FA 27) followed by a loader variable or CREDENTIALS_DIRECTORY, then add them to a sensor.
config ips custom
edit "Telnet.NEW-ENVIRON.LD.Var"
set signature "F-SBID( --name \"Telnet.NEW-ENVIRON.LD.Var\"; --protocol tcp; --dst_port 23; --flow from_client; --pattern \"|FF FA 27|\"; --context packet; --pattern \"LD_\"; --context packet; --distance 0; )"
set action block
set log enable
set status enable
next
edit "Telnet.NEW-ENVIRON.CredDir"
set signature "F-SBID( --name \"Telnet.NEW-ENVIRON.CredDir\"; --protocol tcp; --dst_port 23; --flow from_client; --pattern \"|FF FA 27|\"; --context packet; --pattern \"CREDENTIALS_DIRECTORY\"; --context packet; --distance 0; )"
set action block
set log enable
set status enable
next
end
get ips custom "Telnet.NEW-ENVIRON.LD.Var" | grep rule-id
get ips custom "Telnet.NEW-ENVIRON.CredDir" | grep rule-id
config ips sensor
edit "telnet-guard"
config entries
edit 1
set rule <ld-rule-id> <creddir-rule-id>
set status enable
set action block
set log-packet enable
next
end
next
end
config firewall policy
edit <mgmt-telnet-allow-policy-id>
set utm-status enable
set ips-sensor "telnet-guard"
next
end
Step 7: Hunt and detect on the host
Goal: know if someone already tried it, and get alerted if they try again.
Action: look for loader or credential variables in live process environments, and audit every exec of telnetlogin and login.
# Live processes carrying suspicious variables (expect some
# legitimate CREDENTIALS_DIRECTORY hits from systemd services)
sudo grep -l -E 'LD_PRELOAD|LD_LIBRARY_PATH|CREDENTIALS_DIRECTORY' \
/proc/[0-9]*/environ 2>/dev/null
# Where does telnetlogin live on this box?
dpkg -L telnetd-ssl 2>/dev/null | grep telnetlogin
# Audit every exec of telnetlogin and login
sudo auditctl -w /usr/lib/telnetlogin -p x -k telnet_login
sudo auditctl -w /usr/bin/login -p x -k telnet_login
sudo ausearch -k telnet_login -i | tail -n 40
The pattern to alert on is a root shell whose parent chain is in.telnetd then telnetlogin then login, with no matching PAM authentication success in the auth log. Any EDR that records process trees (FortiEDR included) can express that as a rule. Make the auditctl watches permanent in /etc/audit/rules.d/ once you are happy with them.
Verification and Validation
# On the server: nothing on 23
sudo ss -ltn 'sport = :23'
# From the untrusted host 198.18.50.10
nc -vz -w3 10.0.10.20 23
# Expected: timed out (FortiGate drops it) or connection refused (daemon gone)
# Re-run the fleet sweep from Step 1
sudo nmap -p 23 --open 10.0.0.0/16 | grep -c '23/tcp open'
# Expected: 0, or only hosts you documented as exceptions
diagnose sniffer packet any 'host 10.0.10.20 and tcp port 23' 4 5
# Expected: SYNs arrive on wan1 or port3, nothing leaves port2
execute log filter category traffic
execute log filter field dstport 23
execute log display
# Expected: action="deny" entries for policy deny-telnet-to-servers
To prove the IPS tripwire fires, use a netkit or inetutils Telnet client from a management host against a lab box and send a harmless variable that matches the pattern:
telnet
telnet> environ define LD_TEST 1
telnet> environ export LD_TEST
telnet> open 10.0.10.20
Expected: the session is reset and the FortiGate logs an IPS event for Telnet.NEW-ENVIRON.LD.Var. Only run this against a lab host; on a vulnerable box the variable really is injected.
Troubleshooting and Gotchas
1. Port 23 is still open after the purge
Something else owns it: inetutils-telnetd, BusyBox telnetd, or an xinetd file left behind. Find the binary and its package:
sudo ss -ltnp 'sport = :23'
sudo readlink -f /proc/<pid>/exe
dpkg -S "$(sudo readlink -f /proc/<pid>/exe)"
Remove that package too. Inetutils telnetd is not affected by this CVE, but it had its own critical bugs in 2026 and there is no reason to keep it.
2. The deny policy never gets hits
Either the traffic never crosses the FortiGate (client and server share a VLAN) or an allow rule above it matches first. Trace one connection attempt:
diagnose debug flow filter clear
diagnose debug flow filter daddr 10.0.10.20
diagnose debug flow filter dport 23
diagnose debug flow show function-name enable
diagnose debug flow trace start 10
diagnose debug enable
# reproduce the connection, then stop the trace
diagnose debug disable
If you see Denied by forward policy check (policy <id>) with the wrong ID, fix the order. If you see nothing at all, the traffic is switched locally, and you need segmentation (separate VLANs routed through the FortiGate) before the policy can help.
3. You patched telnetd for CVE-2026-28372 and assumed you were done
That fix lives in GNU inetutils. Netkit telnetd is separate code with separate packages. Check the source package from Step 2. If it says netkit-telnet or netkit-telnet-ssl, you are still exposed until Debian ships a fix that names CVE-2026-141380, or until you remove it.
Bottom Line
Telnet in 2026 is a liability with a login prompt. The fix Debian will eventually ship (revert the || is_uservar change, drop ACCEPT_USERVAR, whitelist the environment in telnetlogin) is the right one, but you do not need it to be safe: purge telnetd, deny TCP 23 at the FortiGate, keep the daemon off root, close anonymous upload paths, and watch for root shells that skipped PAM.
Sources
- oss-security: Pre-authentication environment injection in netkit telnetd, CVE-2026-141380 (Liad Levy)
- Debian Security Tracker entry for CVE-2026-141380
- The CyberSec Guru: CVE-2026-141380, a 2015 Debian patch turned telnetd into a pre-auth root exploit
- SecurityOnline: CVE-2026-141380 netkit telnetd pre-auth RCE (CVSS 9.8)
- InfoSecMonkey: Anatomy of a Remote Code Execution Attack
No fluff. Just the config that works.