The vulnerability in Electerm (<= 3.8.8) allows for persistent local code execution through the import of malicious bookmarks or compromised sync targets. The root cause is insufficient validation and sanitization of data from these external sources. An attacker can craft a bookmark with specific fields (exec*, runScripts, etc.) that, when processed by the application, result in the execution of arbitrary commands on the user's machine.
The analysis of the commits between the vulnerable version v3.8.8 and the patched version v3.9.5 reveals the fixes and pinpoints the vulnerable functions.
-
Unsanitized Tab Creation: The Store.addTab function was a primary sink for the vulnerability. It was called directly with data received from IPC events, including opening deep links or command-line arguments. This data was not sanitized, allowing malicious properties to be passed, leading to code execution. The fix was to introduce a sanitizing function, ipcOpenTab, which filters out dangerous properties before calling addTab.
-
Path Traversal in Local Terminals: The TerminalLocal class constructor was vulnerable to path traversal. When creating a local terminal session from a bookmark, the executable path was constructed using properties from the bookmark. A malicious bookmark could use .. in the path to break out of the intended directory and execute other binaries on the system.
-
Insecure Bookmark Import: The functionality for importing bookmarks from a JSON file was insecure. It parsed the file and directly used the objects to create bookmarks, trusting the structure and content. This allowed an attacker to inject bookmarks with malicious executable properties. The fix involved refactoring the import logic and ensuring that imported data is properly handled.
By identifying these key areas, we can conclude that the core of the vulnerability lies in the improper handling of untrusted data from bookmarks and other external sources, leading to multiple paths for code execution.