[Security] MacVim affected by GHSA-85ch-p2qr-m5gx — netrw OS command injection via sftp:/file: URL tempfile suffix (vim < 9.2.0383)
还没有人认领这个 Issue。
评估
调研方向
从 runtime/pack/dist/opt/netrw/autoload/netrw.vim 第 1822 行开始,并将其与 9.2.0383 版本中的 Vim 修复 405e2fb6 进行比较。使用 issue 中显示的 grep 命令验证受影响的 sftp:// 和 file: URL 路径;完成的标准是 tmpfile 已被 escaped 且 upstream 修复已存在。
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- Vim Script
- 星标
- 7.9k
- 派生
- 690
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
macvim-dev/macvim 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
macvim-dev/macvim#1697 · 6 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 76/100
macvim-dev/macvim#1658 ·
-
难度 2/5 1-3 小时 新手友好度 76/100
macvim-dev/macvim#1655 ·
-
难度 2/5 半天 新手友好度 72/100
macvim-dev/macvim#1653 ·
-
难度 4/5 3-5 天 新手友好度 48/100
macvim-dev/macvim#1696 · 1 条评论 ·
查看 macvim-dev/macvim 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 68/100
luisbocanegra/plasma-smart-video-wallpaper-reborn#325 ·
维护者通常 1 天内回复
-
area: workspaces bug difficulty:2 help wanted S3: minor
难度 2/5 1-3 小时 新手友好度 86/100
manaflow-ai/cmux#16085 ·
维护者通常 1 天内回复
-
bug via-triage
难度 2/5 1-3 小时 新手友好度 78/100
pingdotgg/t3code#14452 · 1 条评论 ·
维护者通常 1 天内回复
-
Mod: Draft Status: Confirmed
难度 2/5 1-3 小时 新手友好度 72/100
FreeCAD/FreeCAD#33096 · 1 个 reaction ·
维护者通常 1 天内回复