/

CVE-2026-41500

Severity:

CRITICAL RISK

(9.8)

Command Injection in Electerm macOS Update Handler

CVE-2026-41500

Analyzed

Vulnerability type

Category:

Command Injection

CWE:

CWE-77

Impact:

Arbitrary Command Execution on macOS Hosts

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 versions prior to 3.3.8 contain a command injection vulnerability in the macOS update logic, where untrusted release information is passed directly into an exec("open ...") shell command.

An attacker who can control or influence the releaseInfo.name field in the remote update metadata may execute arbitrary commands on the user's macOS system with the privileges of the Electerm process.

Affected context

The vulnerability occurs in Electerm's macOS-specific helper function runMac() within npm/install.js, which is responsible for opening downloaded releases or installers.

It becomes relevant when Electerm:

  • Retrieves remote release metadata that includes a releaseInfo.name value, and
  • Constructs a shell command that invokes open on that name using exec, and
  • Does so without sanitizing or validating the contents of the name field.

Any deployment scenario where update or release information can be influenced by an untrusted or partially trusted source is potentially affected.

Exploit preconditions

  • Attack surface: Local desktop / workstation running Electerm on macOS.
  • Required access: Ability to manipulate or intercept the remote release metadata, specifically the releaseInfo.name value (for example, via a compromised update source, man-in-the-middle on the update channel, or any mechanism that lets an attacker supply crafted release names).
  • Trigger point: Invocation of the runMac() function that uses exec("open " + releaseInfo.name) or similar to launch the downloaded artifact.
  • Why exploitation is possible: The code directly concatenates untrusted data into a shell command executed via exec, allowing shell metacharacters, command separators, or injected arguments to be interpreted by the underlying shell.

Why this happens

This is a classic command injection problem as described by CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection').

The vulnerable pattern is:

  • Accept untrusted input (releaseInfo.name) from a remote source.
  • Concatenate this value into a command string passed to exec, which invokes a shell.
  • Perform no validation, escaping, or restriction of allowed characters or formats.

Because shells interpret characters like ;, &&, |, backticks, and others with special meaning, an attacker can craft a releaseInfo.name that terminates the intended open command and appends arbitrary system commands, which then run with the user's privileges.

Potential impact

  • Execute arbitrary system commands on the user's macOS device with the privileges of the Electerm process.
  • Install additional malware or backdoors on the affected workstation.
  • Read, modify, or exfiltrate sensitive data accessible to the user account.
  • Alter Electerm configuration or SSH keys to compromise remote servers.
  • Use the compromised host as a foothold for lateral movement inside the user's network.

General mitigation guidance

Effective mitigation focuses on eliminating the direct concatenation of untrusted data into shell commands and minimizing the need for shell invocation at all:

  • Prefer calling OS APIs or high-level libraries that open files or URLs without involving a shell, or use execFile/spawn-style APIs that pass arguments as an array rather than a single command string.
  • Introduce strict validation for any values used to form commands, enforcing a whitelist of allowed formats (for example, filenames or URLs) and rejecting any value containing shell metacharacters or unexpected patterns.
  • Normalize and sanitize untrusted fields before use, reducing them to safe character sets and known-good paths.
  • Apply least-privilege principles to the Electerm process and its helper scripts so that, even if command execution occurs, the impact is constrained.
  • Treat all remotely sourced release metadata as untrusted input and design the update flow so it never needs to be interpreted by a shell.

How teams detect issues like this

Detection can target both the code patterns that introduce command injection risk and runtime behavior:

  • Static analysis: Configure rules to flag uses of exec, child_process.exec, or similar APIs when they involve string concatenation with variables derived from network or remote sources. Look for patterns like exec("open " + userInput) or template literals combining commands and variables.
  • Code review: During manual review, scrutinize any command construction paths, especially in update or installation scripts. Red flags include use of shell metacharacters, unvalidated filenames, or URLs embedded into command strings.
  • Policy enforcement: Establish development guidelines and lint rules that forbid using generic exec with untrusted input, mandating safer process-spawning APIs and input validation.
  • Runtime monitoring: On endpoints, monitor for unusual child processes spawned by Electerm, particularly shells or commands that are not part of the normal update lifecycle.

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-wxw2-rwmh-vr8f

Frequently asked

questions

Yes, if an attacker can influence the remote release metadata or intercept the update channel, they can potentially trigger command execution on users' macOS systems without local interaction beyond normal update workflows.

The attacker needs the ability to control or tamper with the releaseInfo.name field that Electerm uses when building the open command. This could occur through a compromised update server, DNS hijacking, TLS interception in insecure configurations, or any similar control over the update metadata source.

The most robust fix is to avoid passing untrusted data into shell commands altogether. Use APIs that accept arguments as structured parameters (e.g., execFile or OS-native file-opening mechanisms), apply strict whitelisting validation to any external values, and remove the need for a shell to interpret strings.

Adopt a secure coding standard that:

  • Treats all external data as untrusted.
  • Prohibits generic exec or shell invocation with concatenated strings.
  • Encourages parameterized process execution and strong input validation.
  • Integrates static analysis and code review checks specifically focused on command construction, especially in installer and updater logic.
Find out what's already
exploitable in your codebase.