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.namevalue, and - Constructs a shell command that invokes
openon that name usingexec, 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.namevalue (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 usesexec("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 likeexec("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
execwith 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.

