Summary
Electerm versions 3.0.6 to before 3.8.15 contain a flaw in how they process command-line options and deep-link parameters, enabling arbitrary local code execution.
If a user is tricked into clicking a crafted electerm:// URL or opening a malicious shortcut/command that launches Electerm with attacker-controlled options, the attacker's commands may run on the victim's machine.
Affected context
The vulnerability arises in desktop environments where Electerm is installed and registered as a handler for electerm:// deep links or is commonly launched via shortcuts or command-line invocations.
It becomes relevant when:
- The application accepts CLI
--optsor deep-link parameters that influence how sessions, commands, or scripts are executed - Input from URLs, shortcuts, or shell commands is not sufficiently validated or constrained before being used in execution contexts
- Users can be socially engineered into activating crafted links or opening untrusted shortcut files
Exploit preconditions
- Attack surface: Local desktop environment where Electerm is installed (e.g., via browser deep links, OS-level URI handlers, desktop shortcuts, or shell commands).
- Required access: Ability to deliver or control the electerm:// link, shortcut, or command invocation that the victim will execute (e.g., via email, chat, web page, or shared file).
- User interaction: User must click the crafted deep link or open/run the crafted shortcut/command that launches Electerm with attacker-specified options.
- Trigger point: Application startup or option parsing, where Electerm interprets
--optsor deep-link parameters and maps them to actions such as running commands or scripts. - Why exploitation is possible: Untrusted option values are treated as trusted instructions, allowing attacker-controlled data to be injected into execution paths without adequate validation, whitelisting, or context separation.
Why this happens
This issue stems from Electerm's option and deep-link handling logic treating externally supplied parameters as trusted configuration and, in some cases, as executable instructions.
Parameters from electerm:// URLs, CLI --opts, or shortcuts appear to be passed into code paths that can start sessions, run commands, or invoke scripts with insufficient sanitization or restriction.
Conceptually, this maps to:
- CWE-94: Improper Control of Generation of Code ('Code Injection') where untrusted data can influence what is executed.
- Contributing factors from CWE-20: Improper Input Validation, since there is no strong validation or whitelisting of allowed options/values.
- A related angle of CWE-829: Inclusion of Functionality from Untrusted Control Sphere, as external, attacker-controlled launch contexts (links/shortcuts) can steer Electerm into executing unintended functionality.
The insecure pattern is allowing configuration-like inputs that originate outside the application's trust boundary (links, shortcuts, CLI) to directly drive executable behavior.
Potential impact
- Execution of arbitrary commands under the privileges of the current desktop user
- Installation of malware or backdoors on the victim's system
- Access to sensitive SSH keys, session data, or files accessible to that user
- Lateral movement to remote systems reachable via Electerm sessions (SSH, RDP, VNC, etc.)
- Integrity and confidentiality compromise of local and remote environments used through Electerm
General mitigation guidance
Effective mitigation focuses on reducing the trust placed in deep-link and CLI inputs and breaking the path from user-controlled options to code execution:
- Constrain option semantics: Treat CLI and deep-link parameters as declarative configuration only, never as direct command strings or script bodies.
- Strong input validation: Apply strict whitelisting of allowed options and value formats; reject or ignore unknown or malformed options rather than attempting to interpret them.
- Execution separation: Route any behavior that may execute commands or scripts through hardened, parameterized APIs instead of composing shell commands or dynamically evaluating code.
- Context-aware parsing: Ensure electerm:// handlers and
--optsparsing clearly distinguish between data and executable behavior, and avoid interpolating user-supplied values into execution contexts. - Least privilege by design: Where possible, minimize the privileges under which Electerm runs and limit its ability to spawn privileged or system-wide processes.
- Safe default behavior: When launched with ambiguous or unexpected options, default to a safe, non-executing mode (e.g., show a prompt or ignore suspicious parameters).
How teams detect issues like this
Detection can be approached through both code-level and behavior-level analysis:
- Static analysis: Search for code paths where deep-link parameters, CLI
--opts, or shortcut-provided arguments are used in constructing commands, invoking shell APIs, or feeding directly into evaluation functions. - Code review signals:
- Parsing of electerm:// URLs or command-line arguments followed by calls to process spawning, shell execution, or dynamic code evaluation.
- Lack of strict validation or whitelisting around parameters that control what commands execute or which scripts load.
- Any logic that concatenates user-controlled input into command strings or script paths.
- Policy enforcement: Define secure coding guidelines that forbid direct execution from deep-link or CLI input and enforce them in pull requests (e.g., via pre-commit hooks or CI checks).
- Runtime monitoring: On enterprise endpoints, use EDR or application control solutions to flag unusual process trees originating from Electerm, such as shells, script interpreters, or administrative tools spawned with unexpected arguments.

