/

CVE-2026-41501

Severity:

CRITICAL RISK

(9.8)

Command Injection in electerm Linux Installer Script

CVE-2026-41501

Analyzed

Vulnerability type

Category:

Command Injection

CWE:

CWE-77

Impact:

Arbitrary Command Execution

Severity:

CRITICAL RISK

(9.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

electerm's Linux installer script previously concatenated attacker-controlled remote version strings directly into an exec("rm -rf ...") shell command.

If an attacker can influence the remote version value, they may inject arbitrary shell commands that execute with the privileges of the process running the installer.

Affected context

This vulnerability occurs within electerm's Node.js-based installation workflow for Linux, specifically in npm/install.js inside the runLinux() function.

The issue is relevant when installation logic fetches or accepts version information from a remote or otherwise untrusted source and passes it directly to a shell command without sanitization.

Systems where installation scripts are run with elevated privileges (e.g., using sudo) are at increased risk, as injected commands may inherit those privileges.

Exploit preconditions

  • Attack surface: The electerm installation/update process on Linux systems.
  • Required access: Ability to control or tamper with the remote version string consumed by runLinux() (e.g., via a compromised update source, man-in-the-middle on version checks, or any integration that allows untrusted input to influence the version value).
  • Trigger point: Execution of the vulnerable runLinux() function, which constructs an exec("rm -rf ...") command using the attacker-controlled version string.
  • Why exploitation is possible: The remote version value is interpolated directly into a shell command without proper quoting, validation, or escaping, allowing shell metacharacters to terminate the intended command and append arbitrary payloads.

Why this happens

The core problem maps to CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection').

The installer's runLinux() function builds a shell command by string concatenation, embedding the remote version string into an rm -rf invocation and passing the result to exec().

Because the version string is treated as trusted and not sanitized or constrained to a safe character set, shell metacharacters (such as ;, &&, |) can alter the structure of the command line.

This pattern—constructing shell commands from untrusted input rather than using parameterized APIs or strict validation—creates a direct path from data to code execution.

Potential impact

  • Arbitrary shell command execution with the privileges of the user (or root, if the installer is run with elevated privileges).
  • Deletion or modification of arbitrary files and directories beyond the intended cleanup target.
  • Installation of backdoors, malware, or persistence mechanisms on the host system.
  • Exfiltration of sensitive data such as SSH keys, configuration files, or credentials.
  • Use of the compromised host as a pivot point for lateral movement within a network.

General mitigation guidance

Effective mitigation focuses on eliminating direct use of untrusted data in shell commands and enforcing strict boundaries around installer inputs.

Recommended defensive patterns include:

  • Avoid building shell commands via string concatenation; prefer API-level file operations (e.g., fs.rm, fs.rmdir) or parameterized process execution without invoking a shell.
  • Constrain version and similar identifiers to a well-defined, minimal character set (e.g., alphanumerics, dots, hyphens) and enforce these constraints before use.
  • Centralize input validation for data that influences command execution paths, ensuring all such values are validated or rejected early.
  • Run installers and update mechanisms with the least privileges required, avoiding root where possible to limit blast radius.
  • Design update and version-checking mechanisms to treat remote data as untrusted, applying integrity checks and transport protections as a complement to local validation.

How teams detect issues like this

Teams can detect and prevent similar issues using a combination of automated and manual techniques:

  • Static analysis: Configure rules to flag uses of child_process.exec (or similar APIs) where command strings interpolate variables, especially those derived from network or configuration input.
  • Code review: Treat any shell invocation as a high-risk area; reviewers should look for string concatenation, template literals with variables, and absent validation for inputs that reach command execution.
  • Security linters & policies: Integrate linters or security scanners into CI pipelines that enforce policies such as "no unvalidated data in shell commands" and prefer safer execution APIs.
  • Runtime monitoring: Where feasible, monitor installer or update processes for unexpected outbound connections or suspicious command patterns, although primary prevention should be at the code level.

Sources

SourceLink
github.comgithub.com/electerm/electerm/commit/59708b38c8a52f5db59d7d4eff98e31d573128ee
github.comgithub.com/electerm/electerm/releases/tag/v3.3.8
github.comgithub.com/electerm/electerm/security/advisories/GHSA-8x35-hph8-37hq

Frequently asked

questions

Exploitability depends on whether an attacker can influence the remote version value consumed by the installer. If the version source or its transport can be controlled or tampered with, the vulnerability may allow reliable arbitrary command execution during installation.

Not necessarily. Local access is not required if the attacker can compromise or intercept the mechanism that provides the version string (such as a remote update endpoint). However, if only local configuration controls the version, an attacker would need local or supply-chain access to modify it.

Replace shell-based operations that depend on variable input with library or system calls that do not invoke a shell, and strictly validate any remaining inputs that influence command parameters. Avoid passing dynamic data into exec-style APIs wherever possible.

Establish coding guidelines that forbid direct inclusion of untrusted data in shell commands, enforce input validation standards for configuration and network-derived values, and integrate static analysis and security review checkpoints around installer and update code paths.

Find out what's already
exploitable in your codebase.