macvim-dev / macvim-dev/macvim
[Security] MacVim affected by GHSA-85ch-p2qr-m5gx — netrw OS command injection via sftp:/file: URL tempfile suffix (vim < 9.2.0383)
まだ誰も着手していません。
- 主要言語
- Vim Script
- スター
- 7.9k
- フォーク
- 691
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
Summary
MacVim bundles the netrw plugin (runtime/pack/dist/opt/netrw/autoload/netrw.vim) which passes an unescaped tmpfile variable to a shell command when fetching remote files via sftp:// or file: URLs. A crafted URL with a shell metacharacter in the filename suffix causes arbitrary command execution. The fix from vim 9.2.0383 (405e2fb6) has not been applied to macvim r183.
Vulnerability Details
- GHSA: GHSA-85ch-p2qr-m5gx
- CVE: CVE-2026-42307
- Upstream fix (vim): 9.2.0383 (commit
405e2fb6c2e35e09cb64e0f92c1efdafd6b3978a, 2026-04-21) - Affected code:
runtime/pack/dist/opt/netrw/autoload/netrw.vimline 1822 - Vulnerability type: CWE-78 — OS Command Injection
Root Cause
In the sftp reading path, tmpfile (derived from the remote URL's filename suffix) is passed to the sftp command unescaped:
" runtime/pack/dist/opt/netrw/autoload/netrw.vim line 1822 (macvim r183)
call netrw#os#Execute(s:netrw_silentxfer."!".g:netrw_sftp_cmd." ".netrw#os#Escape(g:netrw_machine.":".b:netrw_fname,1)." ".tmpfile)
tmpfile is constructed from the remote filename suffix (e.g., the extension part of sftp://host/foo.txt;id). When tmpfile contains shell metacharacters like ;, &&, or |, they are executed by the shell.
Attack Scenario
- Attacker tricks victim into opening
sftp://attacker.com/payload;touch /tmp/pwned - MacVim's netrw constructs
tmpfilecontaining;touch /tmp/pwned - The sftp command executes with the unescaped
tmpfilesuffix, running the injected command
Verification
$ grep -n 'netrw_sftp_cmd.*tmpfile' runtime/pack/dist/opt/netrw/autoload/netrw.vim
1822: call netrw#os#Execute(s:netrw_silentxfer."!".g:netrw_sftp_cmd." ".netrw#os#Escape(...)..." ".tmpfile)
The fix netrw#os#Escape(tmpfile,1) is absent. Patch 9.2.0383 not present:
$ git log --all --oneline | grep -i '9.2.0383\|sftp\|85ch'
(no output)
Suggested Fix
Merge vim patches up to at least 9.2.0383. The fix escapes tmpfile:
" Fixed (vim 9.2.0383):
call netrw#os#Execute(s:netrw_silentxfer."!".g:netrw_sftp_cmd." ".netrw#os#Escape(g:netrw_machine.":".b:netrw_fname,1)." ".netrw#os#Escape(tmpfile,1))
References
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
runtime/pack/dist/opt/netrw/autoload/netrw.vim の1822行目から始め、バージョン9.2.0383のVimの修正405e2fb6と比較します。Issueに示されているgrepコマンドを使って、影響を受けるsftp://およびfile:のURLパスを確認します。tmpfileがescapedされ、upstreamの修正が存在すれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- macos, vim
- 領域
- desktop, security
- issue の種類
- バグ
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 静か
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 76/100