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 anexec("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
rootwhere 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.

