Summary
Several workspace-level settings in the Ruby LSP VS Code extension could override the path to the Ruby executable, the version manager executables, or the Bundler Gemfile used at startup. A malicious repository containing a .vscode/settings.json could set these values to attacker-controlled targets. Opening and trusting the repository would then execute code with the privileges of the developer.
The Ruby LSP gem and clients of the language server in other editors are not affected.
Details
The settings rubyLsp.rubyExecutablePath, rubyLsp.bundleGemfile, and the path settings under rubyLsp.rubyVersionManager (the asdf, mise, rbenv, rv executable paths and chrubyRubies) did not declare "scope": "machine" in vscode/package.json. As a result, they could be set from a workspace .vscode/settings.json file.
When activation ran with a workspace-supplied value for rubyExecutablePath, the value was interpolated into a shell command and executed through Node's shell-invoking subprocess call. Shell metacharacters in the value were interpreted by the user's shell, allowing arbitrary command execution. The related version-manager path settings followed the same pattern and could lead to the same outcome through their respective managers. Similarly, bundleGemfile controlled which Gemfile Bundler evaluated at startup, which could also result in code execution through Bundler.
Impact
Code execution with the privileges of the user who opens and trusts the malicious project. Exploitation requires the developer to open a workspace containing an attacker-supplied .vscode/settings.json and accept the VS Code Workspace Trust prompt. Once the user has trusted the workspace, the affected settings could redirect the Ruby executable, the version manager executables, or the Bundler Gemfile to attacker-controlled targets.
This vulnerability is in the VS Code extension only. The ruby-lsp gem is not affected.
Remediation
VS Code extension version 0.10.4 and later restrict the affected settings to user and machine scope only. Workspace .vscode/settings.json files can no longer set them. The extension also declares a capabilities.untrustedWorkspaces block listing rubyLsp.rubyExecutablePath, rubyLsp.customRubyCommand, rubyLsp.rubyVersionManager, and rubyLsp.bundleGemfile in restrictedConfigurations, ensuring these settings are ignored in untrusted workspaces.
VS Code extensions auto-update by default, so most users will receive the fix without action. Users who have disabled auto-updates should update to extension version >= 0.10.4.
Action required if you previously set any of these in workspace settings: the values will now be silently ignored when set at the workspace level. Move them to user or machine settings to retain the configuration.
Summary
Several workspace-level settings in the Ruby LSP VS Code extension could override the path to the Ruby executable, the version manager executables, or the Bundler
Gemfileused at startup. A malicious repository containing a.vscode/settings.jsoncould set these values to attacker-controlled targets. Opening and trusting the repository would then execute code with the privileges of the developer.The Ruby LSP gem and clients of the language server in other editors are not affected.
Details
The settings
rubyLsp.rubyExecutablePath,rubyLsp.bundleGemfile, and the path settings underrubyLsp.rubyVersionManager(theasdf,mise,rbenv,rvexecutable paths andchrubyRubies) did not declare"scope": "machine"invscode/package.json. As a result, they could be set from a workspace.vscode/settings.jsonfile.When activation ran with a workspace-supplied value for
rubyExecutablePath, the value was interpolated into a shell command and executed through Node's shell-invoking subprocess call. Shell metacharacters in the value were interpreted by the user's shell, allowing arbitrary command execution. The related version-manager path settings followed the same pattern and could lead to the same outcome through their respective managers. Similarly,bundleGemfilecontrolled which Gemfile Bundler evaluated at startup, which could also result in code execution through Bundler.Impact
Code execution with the privileges of the user who opens and trusts the malicious project. Exploitation requires the developer to open a workspace containing an attacker-supplied
.vscode/settings.jsonand accept the VS Code Workspace Trust prompt. Once the user has trusted the workspace, the affected settings could redirect the Ruby executable, the version manager executables, or the BundlerGemfileto attacker-controlled targets.This vulnerability is in the VS Code extension only. The
ruby-lspgem is not affected.Remediation
VS Code extension version
0.10.4and later restrict the affected settings to user and machine scope only. Workspace.vscode/settings.jsonfiles can no longer set them. The extension also declares acapabilities.untrustedWorkspacesblock listingrubyLsp.rubyExecutablePath,rubyLsp.customRubyCommand,rubyLsp.rubyVersionManager, andrubyLsp.bundleGemfileinrestrictedConfigurations, ensuring these settings are ignored in untrusted workspaces.VS Code extensions auto-update by default, so most users will receive the fix without action. Users who have disabled auto-updates should update to extension version >= 0.10.4.
Action required if you previously set any of these in workspace settings: the values will now be silently ignored when set at the workspace level. Move them to user or machine settings to retain the configuration.