Summary
Electerm's runWidget function constructs file paths by directly concatenating user-controlled widget identifiers and exposes this behavior to the renderer process via IPC without validation.
If an attacker can execute JavaScript in the renderer (for example through a malicious plugin or webview XSS), they can use path traversal to load and execute arbitrary JavaScript files from the victim's filesystem with the full privileges of the Electerm process.
Affected context
This vulnerability affects Electerm instances where:
- The desktop application exposes the
runWidgetfunction fromsrc/app/widgets/load-widget.jsto the renderer via asynchronous IPC. - Widget identifiers provided by the renderer are used to build filesystem paths with direct string concatenation.
- The renderer context can be influenced, extended, or scripted (e.g., through plugins, embedded webviews, or other dynamic content).
In such deployments, any JavaScript execution obtained in the renderer can pivot into privileged local code execution via the vulnerable IPC handler.
Exploit preconditions
- Attack surface: Electerm's renderer process, including:
- Malicious or compromised plugins
- Untrusted content rendered in built-in webviews
- Any XSS or DOM injection vectors within the renderer
- Required access: Ability to run arbitrary JavaScript in the renderer context (no direct OS-level access required).
- Trigger point: Invocation of the exposed
runWidgetIPC endpoint with a crafted widget identifier that includes path traversal sequences (e.g.,../). - Why exploitation is possible:
runWidgetbuilds paths from user-supplied identifiers using naive string concatenation.- There is no sanitization, canonicalization, or restriction to a trusted base directory.
- The resulting path is used to load and execute JavaScript files, implicitly trusting any file reachable via traversal.
Why this happens
The core issue is a path traversal vulnerability combined with unsafe dynamic script loading:
- The backend side of the Electron-style application exposes
runWidgetto the renderer via IPC and treats incoming widget identifiers as trusted. - It concatenates these identifiers directly into filesystem paths without normalization or validation against a whitelist or fixed base directory.
- It then loads and executes the targeted JavaScript file, assuming it is a legitimate widget.
This maps to:
- CWE-22: Improper Limitation of a Pathname to a Restricted Directory, because attackers can traverse outside the intended widget directory using sequences such as
../. - CWE-829: Inclusion of Functionality from Untrusted Control Sphere, because the application allows the renderer to dictate which local file to load and run as code, effectively turning arbitrary files on disk into executable code within the Electerm process.
Potential impact
- Execution of arbitrary JavaScript from the local filesystem with the privileges of the Electerm process.
- Full compromise of the user account under which Electerm is running (reading/modifying files, accessing SSH keys, and other sensitive data).
- Hijacking or tampering with SSH/SFTP/RDP/VNC sessions handled by Electerm.
- Installation of persistent malware or backdoors through the compromised environment.
- Lateral movement by abusing stored credentials and remote session capabilities.
General mitigation guidance
Effective mitigation focuses on strict path handling, reducing trust in renderer-supplied identifiers, and hardening code-loading behavior:
- Constrain file loading to a fixed, canonical directory:
- Resolve requested paths to an absolute, canonical form and verify they remain within a predefined widget directory before loading.
- Reject any path that attempts traversal outside this directory.
- Treat renderer input as untrusted:
- Apply explicit input validation on widget identifiers (e.g., allow only whitelisted names or IDs).
- Prefer mapping identifiers to known widget metadata instead of accepting raw paths.
- Avoid arbitrary dynamic code loading:
- Replace file-based dynamic
require/importlogic with a statically defined registry of allowed widgets. - If dynamic loading is unavoidable, introduce a manifest that explicitly enumerates permitted files.
- Apply least-privilege and sandboxing:
- Restrict the Electerm process's filesystem permissions to the minimum required.
- Use Electron/Electerm configuration patterns that limit the renderer's capabilities and IPC surface.
- Harden the IPC boundary:
- Treat all IPC calls as external inputs; validate, sanitize, and enforce strict schemas on data from the renderer.
How teams detect issues like this
Detection can combine code-level analysis with runtime monitoring:
- Static analysis and code inspection:
- Search for IPC handlers that accept renderer input and directly concatenate it into filesystem paths or module loaders.
- Flag patterns where
../or user-controlled path segments can influencerequire,import,fs.readFile, or similar APIs. - Identify any use of dynamic
require/eval-like constructs sourced from IPC payloads. - Security-focused code review:
- Review Electron/Electerm IPC boundaries to ensure they do not expose sensitive file operations or dynamic code loading.
- Examine all widget loading mechanisms and verify paths are validated and constrained.
- Automated tooling:
- Use SAST tools configured with rules for CWE-22 and CWE-829 to highlight unsafe path construction and untrusted file inclusion.
- Integrate these checks into CI to prevent reintroduction of similar patterns.
- Runtime monitoring (where feasible):
- Log IPC invocations to
runWidgetand similar handlers, especially when paths include suspicious traversal sequences. - Monitor for unexpected reads or code loads from outside known widget directories.

