From 025a3e2baf18605dd319042457c31b64cc552c9c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 19 Jun 2026 09:42:27 +0800 Subject: [PATCH] vim-patch:9.2.0479: [security]: runtime(tar): command injection in tar plugin Problem: [security]: runtime(tar): command injection in tar plugin (Christopher Lusk) Solution: Use the correct shellescape(args, 1) form for a :! command Github Advisory: https://github.com/vim/vim/security/advisories/GHSA-2fpv-9ff7-xg5w https://github.com/vim/vim/commit/3fb5e58fbc63d86a3e65f1a141b0d67af2aa38a1 Co-authored-by: Christian Brabandt --- runtime/autoload/tar.vim | 1 + test/old/testdir/test_plugin_tar.vim | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/runtime/autoload/tar.vim b/runtime/autoload/tar.vim index c492e1fe4d..c0e9bf2f88 100644 --- a/runtime/autoload/tar.vim +++ b/runtime/autoload/tar.vim @@ -24,6 +24,7 @@ " 2026 Apr 09 by Vim Project: fix bug with dotted filename (#19930) " 2026 Apr 15 by Vim Project: fix more path traversal issues (#19981) " 2026 Apr 16 by Vim Project: use g:tar_secure in tar#Extract() +" 2026 May 14 by Vim Project: use correct shellescape() call in Vimuntar() " " Contains many ideas from Michael Toren's " diff --git a/test/old/testdir/test_plugin_tar.vim b/test/old/testdir/test_plugin_tar.vim index 2152fe701e..706ef0d89b 100644 --- a/test/old/testdir/test_plugin_tar.vim +++ b/test/old/testdir/test_plugin_tar.vim @@ -321,3 +321,23 @@ func Test_extract_with_dotted_filename() call delete('X.txt') bw! endfunc + +func Test_extract_command_injection() + throw 'SKipped: Nvim does not support :Vimuntar' + CheckExecutable gunzip + CheckExecutable touch + var tgz = eval('0z1F8B08087795056A000364756D6D792E74617200EDCE2B12C2300004D01C254' .. + '7480269CE534080A8495BD1DBF3996106C3A08A7ACFACD8157B59A7690BFB4A0FC3707C666E357D' .. + 'E65BC8B5A47CC8A5D61A522EA5B510D3CEBF5ED679197B8CE17CEDB7F9D4C76FBB5F3D000000000' .. + '000000000FCD11D32415E2C00280000') + var dirname = tempname() + + mkdir(dirname, 'R') + var tar = dirname .. "/';%$(touch pwned)'.tgz" + writefile(tgz, tar) + new + exe "e " .. fnameescape(tar) + exe ":Vimuntar " .. dirname + assert_false(filereadable(dirname .. "/pwned")) + bw! +endfunc