CVE-2025-34075: Vagrant HashiCorp Vagrant Has Code Injection Vulnerability

MODERATE
Advisory Identifier: GHSA-hqp6-mjw3-f586
CWE-668 CWE-94 CWE-276
Published
Advisory Summary

CVE-2025-34075 is a MODERATE hashicorp vagrant has code injection vulnerability (CWE-668: Exposure of Resource to Wrong Sphere) affecting Vagrant libraries in the RubyGems ecosystem. The issue involves hashicorp vagrant has code injection vulnerability through default synced folders. Remediation is available by upgrading affected packages to version 2.4.7.

CVE-2025-34075 at a Glance

CVE Identifier CVE-2025-34075
GHSA Identifier GHSA-hqp6-mjw3-f586
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-668: Exposure of Resource to Wrong Sphere
Affected Product Vagrant
Package Ecosystem RubyGems
Published Date
Last Updated

How to Fix CVE-2025-34075

To remediate this vulnerability, upgrade all affected Vagrant dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

vagrant fixed: 2.4.7
Upgrade vagrant to 2.4.7
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for vagrant

How to Check if You Are Affected

To determine whether your application is affected by CVE-2025-34075, inspect your project dependencies for Vagrant:

inspect dependencies for vagrant

Analyze the terminal output to locate any version of Vagrant in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.4.7), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-668: Exposure of Resource to Wrong Sphere, where the product exposes a resource to the wrong control sphere, providing unintended actors with inappropriate access to the resource. In Vagrant, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

An authenticated virtual machine escape vulnerability exists in HashiCorp Vagrant versions 2.4.6 and below when using the default synced folder configuration. By design, Vagrant automatically mounts the host system’s project directory into the guest VM under /vagrant (or C:\vagrant on Windows). This includes the Vagrantfile configuration file, which is a Ruby script evaluated by the host every time a vagrant command is executed in the project directory. If a low-privileged attacker obtains shell access to the guest VM, they can append arbitrary Ruby code to the mounted Vagrantfile. When a user on the host later runs any vagrant command, the injected code is executed on the host with that user’s privileges. While this shared-folder behavior is well-documented by Vagrant, the security implications of Vagrantfile execution from guest-writable storage are not explicitly addressed. This effectively enables guest-to-host code execution in multi-tenant or adversarial VM scenarios.

CVE-2025-34075 Affected Vagrant Versions

1 component(s)
Fixed Versions:
2.4.7
Product / Package Ecosystem Affected Versions Fixed Version
vagrant
RubyGems
≥ 2.2.10
< 2.4.7
2.4.7

References

Frequently Asked Questions

What is CVE-2025-34075?
CVE-2025-34075 is a security vulnerability in Vagrant involving HashiCorp Vagrant has code injection vulnerability through default synced folders under CWE-668: Exposure of Resource to Wrong Sphere.
Which Vagrant versions are affected?
Affected versions include releases prior to 2.4.7 across affected packages: vagrant.
What version fixes CVE-2025-34075?
Upgrading to 2.4.7 (or the latest patched release for your respective branch) resolves the vulnerability.
Is vagrant affected?
Yes, vagrant is affected in releases prior to 2.4.7. Upgrade your dependency to 2.4.7 or later.
What CWE is associated with CVE-2025-34075?
CVE-2025-34075 is classified under CWE-668: Exposure of Resource to Wrong Sphere (The product exposes a resource to the wrong control sphere, providing unintended actors with inappropriate access to the resource.).
How can I check RubyGems dependencies for CVE-2025-34075?
Run the dependency tree command: 'inspect dependencies for vagrant'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-hqp6-mjw3-f586",
  "modified" : "2025-07-05T01:47:56Z",
  "published" : "2025-07-02T21:32:00Z",
  "aliases" : [ "CVE-2025-34075" ],
  "summary" : "HashiCorp Vagrant has code injection vulnerability through default synced folders",
  "details" : "An authenticated virtual machine escape vulnerability exists in HashiCorp Vagrant versions 2.4.6 and below when using the default synced folder configuration. By design, Vagrant automatically mounts the host system’s project directory into the guest VM under /vagrant (or C:\\vagrant on Windows). This includes the Vagrantfile configuration file, which is a Ruby script evaluated by the host every time a vagrant command is executed in the project directory. If a low-privileged attacker obtains shell access to the guest VM, they can append arbitrary Ruby code to the mounted Vagrantfile. When a user on the host later runs any vagrant command, the injected code is executed on the host with that user’s privileges.\n\nWhile this shared-folder behavior is well-documented by Vagrant, the security implications of Vagrantfile execution from guest-writable storage are not explicitly addressed. This effectively enables guest-to-host code execution in multi-tenant or adversarial VM scenarios.",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:L/AC:L/AT:P/PR:L/UI:A/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "vagrant"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.2.10"
      }, {
        "fixed" : "2.4.7"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-34075"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/hashicorp/vagrant/issues/13688"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/hashicorp/vagrant/commit/abe87b2fdc124ef426c016d44d2f6f4792f0cbe3"
  }, {
    "type" : "WEB",
    "url" : "https://developer.hashicorp.com/vagrant"
  }, {
    "type" : "WEB",
    "url" : "https://developer.hashicorp.com/vagrant/docs/synced-folders/basic_usage"
  }, {
    "type" : "WEB",
    "url" : "https://developer.hashicorp.com/vagrant/docs/vagrantfile"
  }, {
    "type" : "ADVISORY",
    "url" : "https://github.com/advisories/GHSA-hqp6-mjw3-f586"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/hashicorp/vagrant"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/rubysec/ruby-advisory-db/blob/master/gems/vagrant/CVE-2025-34075.yml"
  }, {
    "type" : "WEB",
    "url" : "https://raw.githubusercontent.com/rapid7/metasploit-framework/master/modules/exploits/multi/local/vagrant_synced_folder_vagrantfile_breakout.rb"
  }, {
    "type" : "WEB",
    "url" : "https://vulncheck.com/advisories/hashicorp-vagrant-synced-folder-vagrantfile-breakout"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-276", "CWE-668", "CWE-94" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2025-07-03T12:59:35Z",
    "nvd_published_at" : "2025-07-02T20:15:29Z"
  }
}