macvim-dev / macvim-dev/macvim
[Security] MacVim affected by GHSA-cwgx-gcj7-6qh8 — command injection via backtick expansion in tag filenames (vim < 9.2.0357)
まだ誰も着手していません。
- 主要言語
- Vim Script
- スター
- 7.9k
- フォーク
- 691
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
Summary
MacVim's src/tag.c expands backtick expressions in tag file tagname fields when processing wildcard patterns. A malicious tags file containing a backtick expression like `touch /tmp/pwned` as a filename causes arbitrary shell command execution when a user issues a :tag command. The fix from vim 9.2.0357 (c78194e4) has not been applied to macvim r183.
Vulnerability Details
- GHSA: GHSA-cwgx-gcj7-6qh8
- CVE: CVE-2026-41411
- Upstream fix (vim): 9.2.0357 (commit
c78194e4ee65bab5fef3b4f8de8f4e6ee47fbaa6, 2026-04-15) - Affected code:
src/tag.cline 4141 - Vulnerability type: CWE-78 — OS Command Injection
Root Cause
In src/tag.c, when a tag filename matches as a wildcard pattern, the filename is expanded — which includes backtick expansion (shell command substitution):
/* src/tag.c line 4141 (macvim r183) */
if (expand && mch_has_wildcard(fname))
Since backtick expressions (e.g., `cmd`) satisfy mch_has_wildcard(), they are expanded via the shell. A malicious tags file containing:
main `touch /tmp/pwned` /^int main/;" f
causes touch /tmp/pwned to execute when the user runs :tag main.
Attack Scenario
- Attacker provides a malicious
tagsfile in the project (e.g., via repository or build system) - Victim opens a file in MacVim with
set tags=Xtagspointing to the malicious file - Victim issues
:tag mainor another tag navigation command - MacVim expands the backtick expression and executes arbitrary shell commands
Verification
$ grep -n 'mch_has_wildcard.*fname' src/tag.c
4141: if (expand && mch_has_wildcard(fname))
Missing the guard && vim_strchr(fname, '\') == NULL`. Patch 9.2.0357 not present:
$ git log --all --oneline | grep -i '9.2.0357\|backtick.*tag\|cwgx'
(no output)
Suggested Fix
Merge vim patches up to at least 9.2.0357. The fix adds a backtick exclusion:
/* Fixed (vim 9.2.0357): disallow backticks, they could execute arbitrary shell commands */
if (expand && mch_has_wildcard(fname) && vim_strchr(fname, '`') == NULL)
References
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
src/tag.c の 4141 行付近を読み、Vim 9.2.0357 のコミット c78194e4 と比較してください。タグ処理によってバッククォートを含むファイル名が展開されなくなっていることを確認し、通常のワイルドカードによるタグナビゲーションは維持されていることを確認してください。この issue には名前付きのリグレッションテストがないため、検証のために既存のタグテストを調べてください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- c, macos, vim
- 領域
- desktop, security
- issue の種類
- バグ
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 静か
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 76/100