/

CVE-2026-44713

Severity:

HIGH RISK

(8.8)

OS Command Injection in pam_usb tmux Helper

CVE-2026-44713

Deferred

Vulnerability type

Category:

OS Command Injection

CWE:

CWE-78, CWE-116

Impact:

Privilege Escalation to Root via Command Injection

Severity:

HIGH RISK

(8.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

pam_usb versions prior to 0.8.7 contain an OS command injection flaw in the tmux helper that builds a shell command from the user's $TMUX environment variable without proper sanitization.

By crafting a malicious TMUX value containing unescaped double-quotes, an attacker can break out of the intended command line and execute arbitrary shell commands, which run with root privileges inside the PAM stack.

Affected context

The vulnerability appears in pam_usb deployments on Linux systems that:

  • Use the tmux-related integration code in src/tmux.c
  • Invoke pam_usb within authentication flows where the $TMUX environment variable is present and trusted
  • Construct shell commands using data derived from environment variables and execute them via popen()

It is most relevant on systems where tmux is commonly used, and PAM is configured to call pam_usb as part of login or session management.

Exploit preconditions

  • Attack surface: Local login or session establishment on systems using pam_usb with the tmux helper.
  • Required access: Ability to influence or set the $TMUX environment variable for a session that will trigger the vulnerable PAM code (e.g., user-controlled shell, SSH session, or other process launching authentication with inherited environment).
  • Trigger point: Execution of the pam_usb module code path that calls src/tmux.c, which reads $TMUX, splits it on commas, and interpolates the socket-path into a shell command passed to popen().
  • Why exploitation is possible: The socket-path component derived from $TMUX is injected into a double-quoted shell argument without sanitization or escaping. A double-quote character in the attacker-controlled value prematurely terminates the quoted string, allowing arbitrary shell syntax to be appended and interpreted by the shell that popen() spawns as root.

Why this happens

The root cause is direct interpolation of untrusted input into a shell command string that is then executed by popen() with elevated privileges.

The code in src/tmux.c assumes that parsing $TMUX (splitting on commas and taking the socket path) produces a safe value and embeds it directly into a double-quoted portion of a shell command. No escaping or validation is applied, and the shell command is executed through popen() as part of the PAM stack running as root. This aligns with CWE-78: Improper Neutralization of Special Elements used in an OS Command and CWE-116: Improper Encoding or Escaping of Output, because shell metacharacters such as double-quotes are not neutralized before being passed to a shell interpreter.

Potential impact

  • Execution of arbitrary shell commands as root on the affected system
  • Local privilege escalation from an unprivileged user to full root access
  • Installation of persistent backdoors or modification of system authentication configuration
  • Exfiltration or destruction of sensitive system files and credentials
  • Lateral movement within the environment by pivoting from the compromised host

General mitigation guidance

Effective mitigation focuses on removing shell interpretation from the code path and strictly controlling how external commands are constructed:

  • Replace dynamic shell command construction with direct invocation of underlying functionality using APIs or execve-style calls that do not invoke a shell.
  • If a helper binary must be called, pass arguments as an array (e.g., execv/execve/posix_spawn) rather than building command strings; never allow user-controlled data to be interpreted as shell syntax.
  • Apply strict validation to environment-derived values like $TMUX: parse them with a clear schema, allow only expected characters (e.g., path-safe characters), and reject or ignore data that fails validation.
  • Introduce proper output encoding/escaping when data must flow into command contexts, ensuring that metacharacters such as quotes, backticks, semicolons, and ampersands are either disallowed or safely escaped.
  • Run PAM modules and helper code according to least-privilege principles where possible, limiting the effect of any unexpected command execution.

How teams detect issues like this

Detection usually combines code-centric analysis with configuration review:

  • Static analysis: Add rules to identify calls to popen(), system(), or similar APIs where the command string incorporates data from environment variables (e.g., getenv("TMUX")) or other untrusted sources. Flag string concatenation or formatting functions that join these inputs into shell commands.
  • Code review: During manual reviews of PAM modules and authentication helpers, pay attention to any use of shell commands, especially in root or setuid code. Look for patterns where environment variables, command-line arguments, or configuration values are interpolated into command strings.
  • Policy enforcement: Establish secure coding guidelines that prohibit shell-based command execution in privileged components, or require justification and sanitization review when such patterns are unavoidable.
  • Automated tooling: Use linters or security scanners capable of tracing tainted data from environment variables into command execution APIs, and integrate them into CI pipelines for early detection.

Sources

SourceLink
github.comgithub.com/mcdope/pam_usb/security/advisories/GHSA-822m-whrh-vrj8

Frequently asked

questions

It is primarily a local privilege escalation issue. However, if a remote access path (such as SSH or another service) allows an attacker to control or influence the $TMUX environment variable for an authentication session that triggers pam_usb, the vulnerability can be exploited from a remote entry point.

An attacker needs the ability to start or influence a session that uses pam_usb and to control the $TMUX environment variable for that session. In many configurations, an unprivileged local user can set environment variables in their shell or remote login session, satisfying this requirement.

The most robust fix is to eliminate shell-based command execution in privileged code and instead call the required functionality directly or via non-shell exec primitives with properly separated arguments. Any remaining use of popen() or similar APIs should avoid incorporating unsanitized environment data and must strictly escape or validate any input that reaches a command boundary.

Preventing similar issues requires a combination of secure coding standards and tooling: treat environment variables as untrusted input, forbid command-string construction in privileged components, apply strict input validation and output encoding for any data that might reach interpreters, and enforce these practices through code review and automated static analysis integrated into the development lifecycle.

Find out what's already
exploitable in your codebase.