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)

Đang mở Phù hợp với người mới
#1,657 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
Vim Script
Star
7.9k
Fork
691
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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.vim line 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
  1. Attacker tricks victim into opening sftp://attacker.com/payload;touch /tmp/pwned
  2. MacVim's netrw constructs tmpfile containing ;touch /tmp/pwned
  3. The sftp command executes with the unescaped tmpfile suffix, 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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với runtime/pack/dist/opt/netrw/autoload/netrw.vim tại dòng 1822 và so sánh với bản sửa lỗi Vim 405e2fb6 từ phiên bản 9.2.0383. Xác minh đường dẫn URL sftp:// và file: bị ảnh hưởng bằng lệnh grep được nêu trong issue; hoàn tất nghĩa là tmpfile được escaped và bản sửa lỗi upstream đã có.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
macos, vim
Lĩnh vực
desktop, security
Loại issue
Lỗi
Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
76/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.