/

CVE-2026-43943

Severity:

HIGH RISK

(7.8)

OS Command Injection in electerm SFTP Editor Integration

CVE-2026-43943

Analyzed

Vulnerability type

Category:

OS Command Injection

CWE:

CWE-78, CWE-88

Impact:

Remote Code Execution on Client System

Severity:

HIGH RISK

(7.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 SFTP "open with system editor" and "edit with custom editor" features previously passed remote filenames directly into a local shell command without sanitization, allowing shell metacharacters in filenames to be interpreted as commands.

If an attacker controls the SSH server or can influence filenames on the user's system, they may craft a malicious filename that, when edited through electerm, leads to arbitrary code execution on the victim's machine with the user's privileges.

Affected context

This vulnerability occurs on client machines running electerm when users use the SFTP file browser to open or edit files with the system editor or a custom editor.

It is most relevant when:

  • The user connects to an untrusted or compromised SSH/SFTP server, or
  • The attacker can influence filenames on locations the user will browse with electerm.

The problem manifests at the point where electerm constructs and executes a local command line that embeds the remote filename without proper quoting or escaping.

Exploit preconditions

  • Attack surface: electerm client on the end-user's machine, specifically the SFTP "open with system editor" or "edit with custom editor" feature.
  • Required access: Ability to control or influence the target filename, typically by:
  • Controlling the SSH/SFTP server and creating files with malicious names, or
  • Having write access to directories the user will browse via SFTP.
  • User interaction: The victim must choose to open/edit the attacker-controlled file using the vulnerable feature.
  • Trigger point: electerm spawns a local system command that includes the filename unquoted or unsanitized.
  • Why exploitation is possible: Shell metacharacters embedded in the filename are interpreted by the local command shell, turning parts of the filename into executable commands (CWE-78 / CWE-88).

Why this happens

The core issue is improper construction of command lines that include user-controllable data—in this case, filenames obtained over SFTP.

Instead of passing the filename as a separate, safely-escaped argument to the editor process, electerm interpolated the raw filename into a shell command string.

Shells interpret special characters (such as ;, &, |, backticks, or $()), so a filename containing these characters is not treated as inert data but as part of the command itself.

This aligns with CWE-78 (Improper Neutralization of Special Elements used in an OS Command) and CWE-88 (Argument Injection or Modification), where user input is directly embedded into commands without strict quoting or argument separation.

Potential impact

  • Execution of arbitrary commands on the victim's workstation with the victim's user privileges.
  • Installation of malware, backdoors, or credential stealers on the client system.
  • Lateral movement within the victim's network using the compromised host.
  • Exfiltration or destruction of local files accessible to the victim's account.
  • Abuse of the victim's SSH keys or other secrets stored on the machine.

General mitigation guidance

Effective mitigation typically focuses on safe command construction and reducing trust in remote filenames:

  • Invoke editors without going through a command shell; pass the filename as a discrete argument to the process API (e.g., spawn/exec with argument arrays).
  • Apply strict quoting or escaping routines for any data that must cross a shell boundary, and avoid building commands via string concatenation.
  • Normalize and validate filenames received from remote servers, rejecting or safely handling names containing dangerous metacharacters.
  • Provide security-conscious defaults for external tool integration, limiting how much of the command line is user-configurable and disallowing uncontrolled substitution of remote values.
  • Run the client application with least privilege and avoid granting it elevated OS permissions, so that a compromise has limited blast radius.

How teams detect issues like this

Detection can rely on a combination of code-level analysis and behavioral review:

  • Static analysis: Search for command execution APIs (e.g., exec, spawn, child_process.exec in Node.js or equivalents) where arguments are constructed using string concatenation with values derived from remote filenames or SFTP listings.
  • Code review cues: Identify flows where remote or user-controlled filenames are:
  • Interpolated into command strings, or
  • Passed through to shells instead of safe process APIs.
  • Policy enforcement: Establish coding guidelines that ban direct shell invocation with untrusted data and require the use of argument-array-based process spawning.
  • Automated tooling: Use SAST tools and linters configured with rules specific to command injection to flag unsafe command construction patterns in pull requests.

Sources

SourceLink
github.comgithub.com/electerm/electerm/commit/24ce7103e264cffe6eb5476c0506a2379e6f8333
github.comgithub.com/electerm/electerm/releases/tag/v3.7.9
github.comgithub.com/electerm/electerm/security/advisories/GHSA-q4p8-8j9m-8hxj

Frequently asked

questions

Yes, in a client-side sense. An attacker controlling an SSH/SFTP server (or able to influence filenames on it) can set up malicious filenames. When a user connects with electerm and edits those files via the vulnerable feature, the attacker's payload executes on the user's local machine.

The attacker typically needs the ability to create or rename files on a server the victim will browse with electerm. This often means controlling the remote SSH/SFTP server or having write access to directories the victim uses. The actual code execution happens on the victim's local system once they interact with the file.

Avoid passing untrusted data through a shell. Use process-spawning APIs that accept arguments as arrays and treat filenames as opaque data, not as part of a command string. Apply strict escaping and validation when crossing any shell boundary and minimize user-configurable command templates.

Design integrations with external tools so that remote or user-controlled values never influence the structure of commands. Enforce internal guidelines that ban string-built shell commands with dynamic content, adopt secure wrappers or helper libraries for process execution, and integrate static analysis rules that flag command construction using untrusted inputs during CI.

Find out what's already
exploitable in your codebase.