Vim for Windows ships a high‑severity local code‑execution flaw that can let a malicious file in a project folder run with the privileges of the user simply because the editor invoked an external command; the bug is tracked as CVE‑2025‑66476 and is fixed in Vim v9.1.1947 — users and administrators should update immediately and apply defensive mitigations until all installations are patched.
Vim is a ubiquitous, open‑source, command‑line text editor used by developers, sysadmins, and power users across platforms. On Windows, Vim sometimes needs to call external programs (for example, to run a grep, apply a filter, run a make command, or execute a shell command). Because of Windows’ legacy executable search semantics, if an executable with the same name as the intended system utility exists in the current working directory, Windows can resolve and run that local copy instead of the system binary. That behaviour is at the heart of CVE‑2025‑66476. The vulnerability manifests when Vim running on Windows invokes external tools via cmd.exe or internal functions that cause the shell to resolve executable names. If an attacker can place a trojanized binary — for example, a file named findstr.exe — into a directory that a user later opens with Vim, commands that invoke findstr (such as :grep) can end up executing the attacker’s program. This is not a remote network exploit: it is a local, context‑driven search‑path problem that can nevertheless deliver arbitrary code execution under the rights of the active user.
Source: MSRC Security Update Guide - Microsoft Security Response Center
Background
Vim is a ubiquitous, open‑source, command‑line text editor used by developers, sysadmins, and power users across platforms. On Windows, Vim sometimes needs to call external programs (for example, to run a grep, apply a filter, run a make command, or execute a shell command). Because of Windows’ legacy executable search semantics, if an executable with the same name as the intended system utility exists in the current working directory, Windows can resolve and run that local copy instead of the system binary. That behaviour is at the heart of CVE‑2025‑66476. The vulnerability manifests when Vim running on Windows invokes external tools via cmd.exe or internal functions that cause the shell to resolve executable names. If an attacker can place a trojanized binary — for example, a file named findstr.exe — into a directory that a user later opens with Vim, commands that invoke findstr (such as :grep) can end up executing the attacker’s program. This is not a remote network exploit: it is a local, context‑driven search‑path problem that can nevertheless deliver arbitrary code execution under the rights of the active user. What the advisory and databases say
- The fix is included in Vim v9.1.1947; the advisory and Git commit explain the mitigation and the change.
- The vulnerability is tracked as CVE‑2025‑66476 and has been assigned a CVSS v3.1 base score of 7.8 (High) with the vector string AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H — indicating a local attack vector, low complexity, no privileges required, and a high impact on confidentiality, integrity, and availability.
- Public security mailing lists and vulnerability aggregators published analysis and reproduction steps shortly after disclosure; the issue was reported to the Vim project via Trend Micro’s Zero Day Initiative (ZDI).
Technical details — how the flaw is triggered and how the fix works
The underlying mechanism
On Windows, executable resolution historically examines the current directory early in the search order. If a program performs a relative executable lookup (e.g., "findstr"), Windows or the invoking shell may find and run a file named findstr.exe that exists in the current working directory before searching system folders. Vim, when issuing external commands through cmd.exe or running filters, relied on this behavior and consequently could be tricked into launching a local, attacker‑supplied binary.Demonstration flow (reproduction summary)
- An attacker places a trojanized executable named like a common Windows utility (for example, findstr.exe) inside a repository or project folder.
- A user opens a file in that folder using Vim or gVim on Windows.
- The user invokes a command in Vim that triggers an external program (e.g., :grep "text" *.txt).
- Because the current directory is searched first, the trojanized findstr.exe in the folder is executed instead of the legitimate system binary, allowing arbitrary code execution with the user’s privileges.
The fix implemented in v9.1.1947
The official patch changes Vim’s Windows code path to temporarily set an environment variable that prevents the default resolution of the current directory when launching external executables. Concretely, the code sets the NoDefaultCurrentDirectoryInExePath indicator so the shell will not search the current directory first when resolving executable names, restoring the previous environment afterwards. This approach preserves functionality while closing the attack window. The change and rationale are documented in the commit that introduced the patch.Impact: who is affected and how bad is this
Affected software
- All Vim for Windows installations prior to v9.1.1947 are impacted. The advisory lists versions earlier than 9.1.1947 as vulnerable.
What an attacker can do
- An attacker able to place a file in a directory that a user later opens with Vim can cause Vim to execute arbitrary code. The executed code runs with the same privileges as the user running the editor, enabling standard post‑compromise activities: credential theft, backdoor installation, lateral movement (subject to environment), and data exfiltration. Because the attack leverages a well‑known Windows quirk rather than a memory corruption or sandbox escape, it can be straightforward to weaponize in many contexts.
Scope and realistic risk scenarios
- Developers and contributors who routinely clone unknown repositories or open project folders downloaded from the internet are at elevated risk. Similarly, users who open files from shared network drives, untrusted USB media, or mail attachments can be targeted. Because the attack requires placing an executable in a directory the victim later opens, the threat is local but highly practical against workflows where code and data are shared.
Active exploitation: status as of disclosure
- At the time of disclosure and the first advisories, there was no widespread public reporting of in‑the‑wild exploitation campaigns targeting this CVE, and public repositories of exploit code did not show a broadly shared, weaponized PoC. Databases and aggregators list the vulnerability and the CVSS score but do not report active exploitation metadata. That said, because the vulnerability is trivial to test and exploit in controlled settings, defenders should assume the possibility of rapid weaponization and act quickly.
Detection and hunting guidance
Detection focuses on finding evidence of suspicious binaries placed within project and working directories, and on monitoring process creation events where Vim or gVim launches unexpected child processes.- Search for suspicious executables in repositories and project folders, names like findstr.exe, grep.exe, sort.exe, or other utility names that Vim may invoke. Use these search patterns across users' workspace directories:
- Windows PowerShell:
Get-ChildItem -Path C:\Users*\Projects -Filter *.exe -Recurse | Where-Object {$_.Name -in "findstr.exe","sort.exe","grep.exe"} - Audit process creation logs to see whether Vim/gVim spawned unexpected child processes from non‑system folders (Event Tracing for Windows / Sysmon rules can record parent/child relationships and command lines). Configure Sysmon to log process creations and correlate child processes started by vim.exe/gvim.exe with non‑system paths.
- Monitor file system changes in shared folders and source directories to detect addition of executable files that match typical system utility names. Endpoint detection tools should flag newly created executables with names matching common Windows utilities when they appear in user workspace directories.
- If an incident is suspected, capture the executable and perform static/dynamic analysis in an isolated environment before running it; check file hashes and cross‑reference against known good system binaries.
Mitigations, workarounds and recommended actions
Immediate steps for all users and administrators
- Update Vim to v9.1.1947 or later immediately. The vendor patch addresses the root cause by ensuring the current directory is not used as the default in external command resolution. This is the primary corrective action.
- Avoid opening files in untrusted directories. Treat any folder obtained from unknown sources (public repos, email attachments, USB drives, shared network folders) as untrusted. Until patched, do not open files from those locations with Vim on Windows.
- Use administrative policy and endpoint controls to block execution of unexpected binaries. Enforce application allow‑listing or endpoint protections that prevent execution of unsigned executables from user workspace paths.
- Scan developer workspaces for suspicious binaries. Use automated scripts or endpoint management tools to detect and remove executables with names that mimic system utilities.
Workaround for environments that cannot patch immediately
- Configure environments to avoid resolving the current directory first when launching executables in a way that impacts Vim. The fix implemented in Vim sets the NoDefaultCurrentDirectoryInExePath indicator before starting external commands; administrators can apply similar environment hardening at the OS or session level where feasible. Microsoft documents the semantics of this setting and functions that consult it; setting the environment variable or using updated shell semantics to exclude the current directory from the executable search path can reduce exposure. Testing is required before wide deployment, as the change can affect legitimate workflows that rely on executing local executables.
For teams using shared build or CI systems
- Ensure CI runners and shared build machines run updated Vim builds or avoid invoking user‑interactive editors on untrusted sources. Where automated tools may call into editor functions, validate inputs and ensure working directories are sanitized.
Guidance for developers and packagers
- Ship the patched binary (v9.1.1947 or later) in installers and package repositories, and update package metadata so downstream distributions can push the update. Verify code signatures and publish hashes for released assets.
- If distributing editor integrations or plugins that spawn external tools, make those plugins explicitly reference absolute paths or otherwise validate the executable they intend to launch. Avoid relying on implicit PATH resolution that could pick up local trojanized binaries.
- Add unit and integration tests in Windows CI that exercise scenarios involving external tool invocation from within the editor to ensure search path behavior is secure and remains so in future releases.
Enterprise risk assessment and remediation checklist
- Inventory: Identify all systems where Vim/gVim is installed on Windows (including developer laptops, build agents, and shared workstations). Prioritize systems where users open third‑party code frequently.
- Patch: Deploy v9.1.1947 to all affected endpoints via standard software distribution channels (package manager, MSI updates, chocolatey/Scoop, or enterprise software deployment).
- Compensating controls: Implement application allow‑listing, run‑time execution control, and endpoint detection rules to block or alert on unexpected child‑process launches originating from Vim/gVim.
- Monitoring: Enable Sysmon or EDR process creation logging to keep an eye on suspicious parent/child process relationships and untrusted executables launching from workspace directories.
- Education: Tell developers and users not to execute unknown files and to treat new executables in project folders as suspicious. Encourage verifying repository content before opening files in the editor.
Caveats and things to watch
- This issue is not a remote, unauthenticated code execution vulnerability — it requires the attacker to place a file into a directory a user opens. However, supply‑chain, social engineering, and shared storage scenarios make that requirement realistic in many operational environments. The local prerequisite does not materially reduce the severity for many development workflows.
- The public disclosure included a benign reproduction method. While no large‑scale exploitation was reported at disclosure, the attack surface is easy to test and therefore attractive to low‑effort opportunistic attackers. Assume the potential for rapid PoC creation and exploitation.
- Any workaround that changes how the current directory is treated by the OS should be validated thoroughly: some workflows legitimately rely on running local helper utilities in a project folder. Where those workflows exist, prefer the vendor patch over global environment changes.
Hardening examples and quick checks
- Quick PowerShell search to find suspicious executables in a user's workspace:
Get-ChildItem -Path C:\Users -Include findstr.exe,sort.exe,grep.exe -Recurse -ErrorAction SilentlyContinue | Select-Object FullName,Length,LastWriteTime- Sysmon rule snippet (conceptual) to monitor suspicious vim child processes:
- Log ProcessCreate events where ParentImage ends with
\vim.exeor\gvim.exeand the ChildImage path is not in%SystemRoot%or other trusted folders; alert on non‑system paths. - Verify Vim version:
- Launch
gvim --versionorvim --version. - Confirm the version string contains
v9.1.1947or greater. - If packaging via system package managers, check package version metadata before deployment.
Conclusion
CVE‑2025‑66476 is a straightforward but impactful search‑path vulnerability in Vim for Windows that can allow arbitrary code execution when a user opens a file in a directory containing a trojanized executable. The issue is fixed in Vim v9.1.1947; organizations and users should prioritize applying that patch, scanning developer and project folders for suspicious executables, and tightening endpoint controls to detect unexpected child processes spawned by editors. The fix is simple and available — apply it, harden workspaces, and treat any untrusted repository content with caution.Source: MSRC Security Update Guide - Microsoft Security Response Center