[vim/vim] runtime(zip): block single leading slash and absolute paths in Extract (PR #19976)

3 views
Skip to first unread message

q1uf3ng

unread,
Apr 14, 2026, 11:15:03 AMApr 14
to vim/vim, Subscribed

zip#Write(): the regex from commit 6836599 does not match a single
leading slash (/path). On Windows this resolves to the current
drive root (e.g. C:\path), bypassing the check.

Fix: simplify the regex to '^\%(\a:[\\/]\|[\\/]\)' so any leading
slash or backslash is matched.

zip#Extract(): has no absolute path check at all. Add the same
checks used in zip#Write() for both Unix and Windows.


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/19976

Commit Summary

  • fe3dd80 runtime(zip): also block single leading slash and absolute paths in Extract

File Changes

(1 file)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19976@github.com>

Christian Brabandt

unread,
Apr 15, 2026, 12:08:00 PMApr 15
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#19976)

thanks


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19976/c4253607221@github.com>

Christian Brabandt

unread,
Apr 15, 2026, 12:11:36 PMApr 15
to vim/vim, Subscribed

@chrisbra commented on this pull request.


In runtime/autoload/zip.vim:

> @@ -505,6 +505,18 @@ fun! zip#Extract()
     call s:Mess('Error', "***error*** (zip#Browse) Path Traversal Attack detected, not extracting!")
     return
   endif
+  " block absolute paths
+  if has("unix")
+    if fname =~ '^/'
+      call s:Mess('Error', "***error*** (zip#Extract) Path Traversal Attack detected, not extracting!")
+      return
+    endif
+  else
+    if fname =~ '^\%(\a:[\\/]\|[\\/]\)'

I guess we could simplify the whole Unix/Linux detection and just use this pattern for all systems.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19976/review/4115089569@github.com>

Christian Brabandt

unread,
Apr 15, 2026, 12:15:12 PMApr 15
to vim/vim, Subscribed

Closed #19976 via 351a16c.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19976/issue_event/24535954587@github.com>

Reply all
Reply to author
Forward
0 new messages