/

CVE-2026-34060

Severity:

CRITICAL RISK

(9.8)

Code Injection in Ruby LSP Gemfile Generation

CVE-2026-34060

Analyzed

Vulnerability type

Category:

Code Injection

CWE:

CWE-94

Impact:

Arbitrary Code Execution on Developer Workstations

Severity:

CRITICAL RISK

(9.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Ruby LSP interpolated the rubyLsp.branch VS Code workspace setting directly into a generated Gemfile without sanitization, enabling arbitrary Ruby code execution.

A malicious project containing a crafted .vscode/settings.json could trigger this behavior as soon as a user opens the workspace in VS Code with the vulnerable Ruby LSP extension enabled.

Affected context

This vulnerability affects environments where:

  • The Ruby LSP extension is installed in VS Code (Shopify.ruby-lsp or ruby-lsp versions prior to the patched releases), and
  • Workspaces use the rubyLsp.branch setting in .vscode/settings.json, and
  • The extension generates or modifies a Gemfile based on that configuration and then evaluates or runs it.

It is most relevant when developers clone and open untrusted or third-party repositories that may contain malicious VS Code workspace settings.

Exploit preconditions

  • Attack surface: Local development environment via VS Code workspace configuration.
  • Required access: Ability for an attacker to provide or influence a project directory opened in VS Code, including writing .vscode/settings.json.
  • Trigger point: Opening a project in VS Code with Ruby LSP enabled so that it processes the rubyLsp.branch setting and generates a Gemfile.
  • Why exploitation is possible: The rubyLsp.branch value is interpolated into Gemfile content without sanitization or restriction, and the resulting Gemfile is evaluated or executed by Ruby tooling, allowing attacker-controlled Ruby code to run.

Why this happens

The root cause is unsanitized code injection arising from directly embedding a configuration value into executable Ruby code.

Specifically, the rubyLsp.branch setting from .vscode/settings.json is treated as trusted input and interpolated into a dynamically generated Gemfile.

Because Gemfiles are Ruby code executed by Bundler or Ruby, any injected Ruby expressions in this field can be executed when the Gemfile is processed.

This aligns with CWE-94: Improper Control of Generation of Code ('Code Injection'), where user-controllable data is used to construct executable code without proper validation, escaping, or constraint on the allowed input.

Potential impact

  • Execution of arbitrary Ruby code in the context of the developer's machine.
  • Installation of malicious gems or modification of Gemfile behavior to introduce backdoors.
  • Exfiltration of local files, SSH keys, or access tokens from the developer environment.
  • Persistence mechanisms added to the development environment via Ruby scripts or gems.
  • Lateral movement into connected services (e.g., source control, CI systems) using stolen credentials.

General mitigation guidance

Effective mitigation focuses on treating configuration values as untrusted and ensuring they cannot directly influence executable code:

  • Constrain configuration fields like rubyLsp.branch to a strict, well-defined set of safe values (e.g., whitelisted branch names or patterns).
  • Avoid interpolating configuration directly into Ruby code; instead, pass values as data (e.g., environment variables, structured config) and not as code fragments.
  • When dynamic generation of code-like files (such as Gemfiles) is unavoidable, apply strict sanitization and escaping rules that prevent injection of Ruby syntax.
  • Separate configuration parsing from code execution, ensuring that configuration is validated before any related code paths are executed.
  • Run extension-related code with least privilege and minimize assumptions about the trustworthiness of workspace-level settings.

How teams detect issues like this

Detection can combine code-level analysis with development workflow checks:

  • Use static analysis to flag patterns where configuration or user-controlled data are concatenated or interpolated into source files, Gemfiles, or other executable artifacts.
  • During code review, look for logic that generates Gemfiles or scripts from user or workspace settings, especially when using string interpolation or eval-like behaviors.
  • Implement policy checks in CI to prevent new instances of dynamic code generation from untrusted configuration without explicit security review.
  • Apply configuration linting rules to extension codebases to ensure workspace settings are only used in non-executable contexts or are strictly validated.

Sources

SourceLink
github.comgithub.com/Shopify/ruby-lsp/releases/tag/v0.26.9
github.comgithub.com/Shopify/ruby-lsp/security/advisories/GHSA-c4r5-fxqw-vh93

Frequently asked

questions

It primarily targets local developer environments, but it is exploitable remotely in the sense that an attacker can publish or distribute a malicious repository. When a developer clones and opens that repository in VS Code with a vulnerable Ruby LSP installed, arbitrary code execution can occur.

An attacker needs the ability to influence the code workspace a developer opens, typically by providing a repository or project folder containing a crafted .vscode/settings.json. They do not need direct access to the developer's machine or VS Code.

The safest pattern is to stop treating configuration values as code. Restrict configuration fields to well-validated, non-executable values (e.g., simple strings from a whitelist) and avoid interpolating them into files that will be executed by interpreters or build tools.

Architect tools so that configuration is always handled as data, never as executable logic. Combine strict input validation, clear trust boundaries for workspace settings, code review focused on dynamic file generation, and automated static analysis rules that flag any use of configuration data in code generation or evaluation paths.

Find out what's already
exploitable in your codebase.