The vulnerability allows for remote code execution by exploiting the 'mirror' mode in OpenShell. An attacker could place malicious files in a sandbox's hooks directory. During the mirroring process, these malicious hooks were being copied to the host's workspace because the synchronization function did not exclude any directories.
The root cause of the vulnerability is the replaceDirectoryContents function located in extensions/openshell/src/mirror.ts. The original implementation of this function would clear the target directory and then copy all files and directories from the source. It lacked any filtering or exclusion capabilities.
The patch in commit c02ee8a3a4cb390b23afdf21317aa8b2096854d1 rectifies this flaw. It modifies replaceDirectoryContents to accept an excludeDirs option and then filters which directories are deleted from the target and copied from the source. The call site in extensions/openshell/src/backend.ts within the OpenShellSandboxBackendImpl class was also updated to pass excludeDirs: ["hooks"] to replaceDirectoryContents, preventing the hooks directory from being synchronized.
Therefore, the replaceDirectoryContents function is the central point of the vulnerability. Any runtime profile captured during exploitation would show this function being executed as it performs the unsafe directory mirroring.