Summary
A path traversal vulnerability in electerm allows a malicious SFTP server to control a filename used when opening a file with the system editor. If a user connects to an untrusted SFTP server and invokes the affected editing workflow, attacker-controlled paths may cause content to be written outside the intended temporary directory.
Affected context
The issue occurs in electerm's SFTP file-editing workflow, specifically when a server-provided filename is passed to path resolution without sufficient sanitization. It is relevant when a user connects to a malicious or compromised SFTP server and uses the system-editor feature on a remotely referenced file.
Exploit preconditions
- Attack surface: SFTP client file-editing functionality
- Required access: A user must connect electerm to an attacker-controlled or compromised SFTP server
- Trigger point: The user invokes the system editor for an SFTP file
- Why exploitation is possible: Server-controlled filename data is interpolated into path resolution without enforcing confinement to the intended temporary directory
Why this happens
The vulnerability results from treating a server-controlled filename as a trusted filesystem path. When that value is incorporated into path.resolve without canonicalization and boundary validation, traversal components or other path manipulations can escape the intended directory. This behavior maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, commonly known as path traversal.
Potential impact
- Attacker-controlled content may be written outside the temporary directory
- Sensitive local files may be overwritten or corrupted
- Application or user configuration may be modified
- Arbitrary file writes could contribute to code execution depending on the target path and operating-system controls
- Local data integrity and confidentiality may be affected
General mitigation guidance
Mitigation generally focuses on treating all remote filenames as untrusted and enforcing a strict directory boundary.
Common defensive patterns include:
- Resolve paths against a fixed trusted base directory, then verify the canonical result remains within that directory
- Reject absolute paths, traversal segments, symbolic-link escapes, and platform-specific alternate path forms
- Generate local temporary filenames instead of reusing server-provided names
- Separate remote metadata from local filesystem paths
- Apply least-privilege permissions to the client process and temporary-directory contents
- Avoid opening or writing files in security-sensitive locations based solely on remote input
How teams detect issues like this
Organizations can look for:
- Static analysis findings where remote filenames flow into path.join, path.resolve, filesystem writes, or editor-launch routines
- Code review signals involving missing canonicalization, directory-boundary checks, or rejection of absolute and traversal paths
- Tests that use traversal sequences, absolute paths, symbolic links, and platform-specific path formats
- Runtime policy controls that restrict write operations to approved temporary directories
Automated code review and SAST tools may help identify untrusted path data reaching filesystem APIs, but findings should be validated against actual path-confinement logic.

